Files
envsitter/site/assets/site.js
T
David Ibia 33b4a72f2c Add documentation site for envsitter and envsitter-guard
Static HTML and CSS with self-hosted Geist fonts and light/dark themes, deployed by pages.yml to https://boxpositron.github.io/envsitter/ (guard page at /guard/).
2026-10-20 15:10:11 +01:00

28 lines
816 B
JavaScript

(() => {
if (!navigator.clipboard || !window.isSecureContext) return;
const status = document.getElementById("copy-status");
const announce = (message) => {
if (status) status.textContent = message;
};
document.querySelectorAll("button[data-copy]").forEach((button) => {
let resetTimer;
button.hidden = false;
button.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(button.dataset.copy);
button.dataset.state = "copied";
announce("Copied to clipboard");
clearTimeout(resetTimer);
resetTimer = setTimeout(() => {
delete button.dataset.state;
announce("");
}, 2000);
} catch {
announce("Copy failed. Select the text and copy it manually.");
}
});
});
})();