diff options
| author | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-23 14:48:36 -0700 |
|---|---|---|
| committer | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-23 14:48:36 -0700 |
| commit | 846397e1870a937a4560d86784effa13e8151e2f (patch) | |
| tree | 10bf3e4f55f7eeca015ad5ca0323ebbb7c65b52b /src/static/js | |
| parent | 9fb32f7db48f4b4ef7861699f7d8922d5784390a (diff) | |
add contact info w/ clipboardmain
Diffstat (limited to 'src/static/js')
| -rw-r--r-- | src/static/js/clipboard.js | 16 |
1 files changed, 16 insertions, 0 deletions
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; +} |
