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)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// 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();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user