adventskalender/2025/js/popup.js aktualisiert

This commit is contained in:
2025-11-05 21:38:09 +00:00
parent 87008ab64b
commit 81bc5cfd00

View File

@@ -61,14 +61,14 @@ window.openPopup = openPopup;
// ============================================================ // ============================================================
// Ergänzung: Gesperrte Türchen Popup mit Zufallsspruch + Zeitangabe // Ergänzung: Gesperrte Türchen Popup mit Zufallsspruch + Countdown-Angabe
// ============================================================ // ============================================================
window.showLockedPopup = function (day) { window.showLockedPopup = function (day) {
const sprueche = [ const sprueche = [
"🎁 Na na na, hier wird nicht geschummelt!", "🎁 Na na na, hier wird nicht geschummelt!",
"❄️ Geduld ist auch eine Form von Magie.", "❄️ Geduld ist auch eine Form von Magie.",
"🎅 Ho ho ho zu früh! Versuch es später nochmal.", "🎅 Ho ho ho zu früh! Versuchs später nochmal.",
"⏳ Die Tür klemmt noch vielleicht morgen?", "⏳ Die Tür klemmt noch vielleicht morgen?",
"🍪 Kein Plätzchen für Ungeduldige!", "🍪 Kein Plätzchen für Ungeduldige!",
"🎄 Schön, dass du neugierig bist aber noch ist Geheimniszeit!", "🎄 Schön, dass du neugierig bist aber noch ist Geheimniszeit!",
@@ -83,15 +83,25 @@ window.showLockedPopup = function (day) {
const yearMatch = document.title.match(/\d{4}/); const yearMatch = document.title.match(/\d{4}/);
const year = yearMatch ? parseInt(yearMatch[0], 10) : new Date().getFullYear(); const year = yearMatch ? parseInt(yearMatch[0], 10) : new Date().getFullYear();
const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0); // 11 = Dezember const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0); // 11 = Dezember
const now = new Date();
// hübsches deutsches Datum let diff = unlockDate - now;
const options = { day: "2-digit", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit" }; if (diff < 0) diff = 0;
const dateText = unlockDate.toLocaleString("de-DE", options).replace(" um", ",");
const totalMinutes = Math.floor(diff / 60000);
const days = Math.floor(totalMinutes / (60 * 24));
const hours = Math.floor((totalMinutes % (60 * 24)) / 60);
const minutes = totalMinutes % 60;
let timeText = "";
if (days > 0) timeText += `${days} Tag${days !== 1 ? "en" : ""}`;
if (hours > 0) timeText += `${timeText ? ", " : ""}${hours} Stunde${hours !== 1 ? "n" : ""}`;
if (minutes > 0 || timeText === "") timeText += `${timeText ? " und " : ""}${minutes} Minute${minutes !== 1 ? "n" : ""}`;
popupContent.innerHTML = ` popupContent.innerHTML = `
<h2>Türchen ${day} ist noch geschlossen</h2> <h2>Türchen ${day} ist noch geschlossen</h2>
<p>${zufall}</p> <p>${zufall}</p>
<p style="margin-top: 10px; opacity: 0.8;">🔓 Öffnet sich am <strong>${dateText}</strong></p> <p style="margin-top: 10px; opacity: 0.8;">🔓 Öffnet in <strong>${timeText}</strong></p>
`; `;
popupOverlay.classList.add("active"); popupOverlay.classList.add("active");