diff options
| author | Tolmachev Igor <me@igorek.dev> | 2026-02-01 23:14:59 +0300 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2026-02-01 23:14:59 +0300 |
| commit | 1228f1df1725075514ea68943c2e87c2a05029b6 (patch) | |
| tree | e22bc98f923277b255791249ddf460711fe341d5 /script.js | |
| download | mumble_guide_pages-1228f1df1725075514ea68943c2e87c2a05029b6.tar.gz mumble_guide_pages-1228f1df1725075514ea68943c2e87c2a05029b6.zip | |
Add site
Diffstat (limited to 'script.js')
| -rw-r--r-- | script.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/script.js b/script.js new file mode 100644 index 0000000..9afcb2c --- /dev/null +++ b/script.js | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | window.onload = () => { | ||
| 2 | document.querySelectorAll(".copy").forEach((element) => { | ||
| 3 | const tooltip = document.createElement("span"); | ||
| 4 | tooltip.textContent = " [copy]"; | ||
| 5 | tooltip.style.fontSize = "0.8em"; | ||
| 6 | tooltip.style.opacity = "0.7"; | ||
| 7 | element.appendChild(tooltip); | ||
| 8 | |||
| 9 | element.addEventListener("click", () => { | ||
| 10 | try { | ||
| 11 | navigator.clipboard.writeText(element.attributes["copy-text"]?.value); | ||
| 12 | tooltip.textContent = " [copied]"; | ||
| 13 | } catch (error) { | ||
| 14 | tooltip.textContent = " [error]"; | ||
| 15 | } | ||
| 16 | setTimeout(() => (tooltip.textContent = " [copy]"), 1000); | ||
| 17 | }); | ||
| 18 | }); | ||
| 19 | }; | ||
