diff options
author | Irma Lahtinen <ilahtine@local> | 2023-12-12 01:19:38 +0200 |
---|---|---|
committer | Irma Lahtinen <ilahtine@local> | 2023-12-12 01:19:38 +0200 |
commit | 3b8173e94b9228b0761e45174190b237b41d1db8 (patch) | |
tree | f94bc6edf214ae3557b1a5d3c22132e64098778e /static/kys-link-info.js | |
parent | 11ee6577a359862875936fd24b41d141b30ad0cf (diff) |
Adding "link to clipboard" functionality and forcing questions to consist printable characters.
Diffstat (limited to 'static/kys-link-info.js')
-rw-r--r-- | static/kys-link-info.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/static/kys-link-info.js b/static/kys-link-info.js new file mode 100644 index 0000000..f3165b2 --- /dev/null +++ b/static/kys-link-info.js @@ -0,0 +1,20 @@ +const kysLink = document.getElementById("kysLink") +kysLink.onclick = () => { + const link = kysLink.innerHTML + navigator.clipboard.writeText(link) + const linkInfo = document.createElement("div") + linkInfo.className = 'kysInfo' + const linkText = document.createTextNode( + "Linkki " + link + " on kopioitu leikepöydälle." ) + linkInfo.appendChild( linkText ) + document.documentElement.lastChild.append(linkInfo) +} + +setInterval( () => { + Array.from(document.getElementsByClassName('kysInfo')).forEach( (a)=>{ + a.addEventListener('click', (event) => { event.target.remove() } ) + if (a.style.transition=="opacity 2s") a.remove() + a.style.transition="opacity 2s" + a.style.opacity=0; + } ) +}, 5000) |