// The admin page's only script, and it is optional: every page works without // it. It adds Copy buttons for embed lines and asks before a delete. for (const b of document.querySelectorAll("button.copy[data-copy]")) { b.addEventListener("click", async () => { const text = b.getAttribute("data-copy") || ""; try { await navigator.clipboard.writeText(text); } catch { const input = b.previousElementSibling; if (input && "select" in input) { input.select(); document.execCommand("copy"); } } const was = b.textContent; b.textContent = "Copied"; setTimeout(() => (b.textContent = was), 1500); }); } for (const f of document.querySelectorAll("form[action='/images/delete']")) { f.addEventListener("submit", (e) => { const name = f.querySelector("input[name=name]")?.value ?? "this image"; if (!confirm(`Delete ${name} from the vault? This cannot be undone.`)) e.preventDefault(); }); }