web/_site/assets/js/user/copy.js

16 lines
602 B
JavaScript
Raw Permalink Normal View History

2024-11-15 19:36:06 +03:00
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);
}