web/_site/assets/js/user/copy.js
Aliberk Sandıkçı a1919b5abd update
2024-04-13 12:54:20 +03:00

16 lines
No EOL
602 B
JavaScript

async function addToClipboard(id) {
var copyText = document.getElementById(id);
navigator.clipboard.writeText(copyText.innerHTML);
var copyButton = document.getElementById(id+"-button");
copyButton.setAttribute("aria-label", "Copied!");
copyButton.setAttribute("data-balloon-pos", "up");
copyButton.setAttribute("data-balloon-visible", "1");
// hide message after 2s
setTimeout(() => {
copyButton.removeAttribute("aria-label");
copyButton.removeAttribute("data-balloon-pos");
copyButton.removeAttribute("data-balloon-visible");
}, 2000);
}