move copy-code.js into ui.js
This commit is contained in:
@ -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)
|
||||
})
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user