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

@ -24,7 +24,6 @@
<footer class="darkbg"> <footer class="darkbg">
<span>Pyrom commit <a href="{{ "https://git.poto.cafe/yagich/pyrom/commit/" + __commit }}">{{ __commit[:8] }}</a></span> <span>Pyrom commit <a href="{{ "https://git.poto.cafe/yagich/pyrom/commit/" + __commit }}">{{ __commit[:8] }}</a></span>
</footer> </footer>
<script src="{{ "/static/js/copy-code.js" | cachebust }}"></script>
<script src="{{ "/static/js/ui.js" | cachebust }}"></script> <script src="{{ "/static/js/ui.js" | cachebust }}"></script>
<script src="{{ "/static/js/date-fmt.js" | cachebust }}"></script> <script src="{{ "/static/js/date-fmt.js" | cachebust }}"></script>
</body> </body>

View File

@ -1,7 +0,0 @@
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)
})
}

View File

@ -144,4 +144,13 @@ document.addEventListener("DOMContentLoaded", () => {
openLightbox(belongingTo, idx); 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)
})
};
}); });