hinzugefügt: Grund für Tausch + Discord benachrichtigung + PWA

This commit is contained in:
Honey committed 2026-02-08 19:52:32 +01:00
1 parent dae99a0b76
commit 497faa72db
8 files changed
+175 -48

No files matched your search

+36 -2
View File
@@ -1,11 +1,20 @@
const img = document.getElementById("personImg");
const nameEl = document.getElementById("personName");
const button = document.getElementById("toggleButton");
const reasonInput = document.getElementById("reasonInput");
const lastReasonBox = document.getElementById("lastReasonBox");
const lastReasonText = document.getElementById("lastReasonText");
async function loadStatus() {
const res = await fetch("/status");
const data = await res.json();
showStatus(data.current, false);
// Show last reason if available
if (data.lastReason) {
lastReasonText.textContent = data.lastReason;
lastReasonBox.classList.remove("hidden");
}
}
function showStatus(person, animate = true) {
@@ -40,9 +49,34 @@ function showStatus(person, animate = true) {
button.addEventListener("click", async () => {
const res = await fetch("/toggle", { method: "POST" });
const reason = reasonInput.value.trim();
const res = await fetch("/toggle", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ reason: reason || undefined })
});
const data = await res.json();
showStatus(data.current);
// Update last reason display
if (reason) {
lastReasonText.textContent = reason;
lastReasonBox.classList.remove("hidden");
}
// Clear input
reasonInput.value = "";
});
loadStatus();
// Allow Enter key to trigger switch
reasonInput.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
button.click();
}
});
loadStatus();