move copy-code.js into ui.js

This commit is contained in:
2025-08-04 03:25:41 +03:00
parent e33d26c6dc
commit d36e94127e
3 changed files with 9 additions and 8 deletions

View File

@ -144,4 +144,13 @@ document.addEventListener("DOMContentLoaded", () => {
openLightbox(belongingTo, idx);
});
});
// copy code blocks
for (let button of document.querySelectorAll(".copy-code")) {
button.addEventListener("click", async () => {
await navigator.clipboard.writeText(button.value)
button.textContent = "Copied!"
setTimeout(() => {button.textContent = "Copy"}, 1000.0)
})
};
});