Files
nico d56be7b2c0 Wichtel-Werkstatt: Secret-Santa-App mit Räumen, Ausschlüssen und Recovery-Links
- FastAPI + SQLite, serverseitig gerenderte Templates, mobil-zuerst
- Admin-Passwort, einseitige Ausschlüsse, eingefrorene Auslosung
- Teilnehmer sehen Ergebnis per Cookie; Einmal-Recovery-Links bei Verlust
- Docker/podman-tauglich (Entrypoint mit Privilegien-Drop, SELinux-:z)
- Unit-Tests für Auslosung, E2E-Testskript (30 Checks)
2026-08-05 16:07:21 +02:00

38 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Wichtel-Werkstatt: Copy-Buttons und Bestätigungsdialoge.
document.addEventListener("click", (event) => {
const button = event.target.closest("[data-copy]");
if (!button) return;
const source = document.querySelector(button.dataset.copy);
if (!source) return;
const text = source.value || source.textContent;
const done = () => {
const original = button.textContent;
button.textContent = "Kopiert ✓";
setTimeout(() => { button.textContent = original; }, 1600);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(done).catch(() => fallbackCopy(source, done));
} else {
fallbackCopy(source, done);
}
});
function fallbackCopy(source, done) {
source.focus();
source.select();
try {
document.execCommand("copy");
done();
} catch {
// Kopieren nicht möglich Text bleibt im Feld zum manuellen Markieren.
}
}
document.addEventListener("submit", (event) => {
const form = event.target.closest("form[data-confirm]");
if (form && !window.confirm(form.dataset.confirm)) {
event.preventDefault();
}
});