diff options
Diffstat (limited to 'script.js')
| -rw-r--r-- | script.js | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -1,16 +1,16 @@ | |||
| 1 | function copy(text, tooltip) { | 1 | function copy(text, tooltip) { |
| 2 | return () => { | 2 | return () => { |
| 3 | navigator.clipboard.writeText(text); | 3 | navigator.clipboard.writeText(text); |
| 4 | tooltip.textContent = "[copied]"; | 4 | tooltip.textContent = " []"; |
| 5 | setTimeout(() => (tooltip.textContent = "[click to copy]"), 1000); | 5 | setTimeout(() => (tooltip.textContent = " []"), 1000); |
| 6 | }; | 6 | }; |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | window.onload = () => { | 9 | window.onload = () => { |
| 10 | document.querySelectorAll(".copy").forEach((element) => { | 10 | document.querySelectorAll(".copy").forEach((element) => { |
| 11 | const tooltip = document.createElement("span"); | 11 | const tooltip = document.createElement("span"); |
| 12 | tooltip.classList.add("copy-tooltip"); | 12 | tooltip.classList.add("copy-button"); |
| 13 | tooltip.textContent = "[click to copy]"; | 13 | tooltip.textContent = " []"; |
| 14 | 14 | ||
| 15 | element.onclick = copy(element.attributes["copy-text"]?.value, tooltip); | 15 | element.onclick = copy(element.attributes["copy-text"]?.value, tooltip); |
| 16 | element.appendChild(tooltip); | 16 | element.appendChild(tooltip); |
