aboutsummaryrefslogtreecommitdiffhomepage
path: root/script.js
diff options
context:
space:
mode:
authorIgor Tolmachev <me@igorek.dev>2024-04-23 20:45:13 +0900
committerIgor Tolmachev <me@igorek.dev>2024-04-23 20:49:44 +0900
commit622b3504520be1b3e09d5798c5e946248fcfa8da (patch)
tree8ae9913d820c6f7c27567196f85f61bfde5f5603 /script.js
parent93b7de928e8ab59396fcd5ac263aed37afc5ec85 (diff)
downloadpages-622b3504520be1b3e09d5798c5e946248fcfa8da.tar.gz
pages-622b3504520be1b3e09d5798c5e946248fcfa8da.zip
Change copy behavior
Diffstat (limited to 'script.js')
-rw-r--r--script.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/script.js b/script.js
index b16142f..2f428b9 100644
--- a/script.js
+++ b/script.js
@@ -1,16 +1,16 @@
1function copy(text, tooltip) { 1function 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
9window.onload = () => { 9window.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);