web/_site/assets/js/user/copy.js
2024-11-15 16:36:06 +00: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);
}