From 9b03d2790b8b8db1b5a6755b6130f37e5f7f2455 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 8 Oct 2026 19:44:46 +0300 Subject: WIP --- public/copy.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 public/copy.js (limited to 'public/copy.js') diff --git a/public/copy.js b/public/copy.js new file mode 100644 index 0000000..751f2ae --- /dev/null +++ b/public/copy.js @@ -0,0 +1,14 @@ +document.addEventListener("click", async (e) => { + const el = e.target.closest("[data-copy]"); + if (!el) return; + try { + await navigator.clipboard.writeText(el.dataset.copy); + } catch (err) { + console.error("copy failed:", err); + return; + } + const scope = el.closest("[data-copy-scope]") ?? el; + scope.setAttribute("data-copied", ""); + clearTimeout(scope._copyTimer); + scope._copyTimer = setTimeout(() => scope.removeAttribute("data-copied"), 1500); +}); -- cgit v1.3.1