From 846397e1870a937a4560d86784effa13e8151e2f Mon Sep 17 00:00:00 2001 From: Emma Terzioglu Date: Mon, 23 Mar 2026 14:48:36 -0700 Subject: add contact info w/ clipboard --- src/static/js/clipboard.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/static/js/clipboard.js (limited to 'src/static/js/clipboard.js') diff --git a/src/static/js/clipboard.js b/src/static/js/clipboard.js new file mode 100644 index 0000000..5cbad5d --- /dev/null +++ b/src/static/js/clipboard.js @@ -0,0 +1,16 @@ +const copyToClipboard = (v) => { + navigator.clipboard.writeText(v) + .then(alert("text copied to clipboard!")); +} + +const clickEventHandler = (e) => { + e.preventDefault() + const raw = e.target.getAttributeNode("x-content"); + const content = atob(raw.value); + copyToClipboard(content); +} + +const copyables = document.getElementsByClassName("copyable"); +for (const c of copyables) { + c.onclick = clickEventHandler; +} -- cgit v1.2.3