adventskalender/2025/js/popup.js aktualisiert

This commit is contained in:
2025-11-05 21:37:03 +00:00
parent 95bf370c5c
commit 87008ab64b

View File

@@ -61,14 +61,14 @@ window.openPopup = openPopup;
// ============================================================ // ============================================================
// Ergänzung: Gesperrte Türchen Popup mit Zufallsspruch // Ergänzung: Gesperrte Türchen Popup mit Zufallsspruch + Zeitangabe
// ============================================================ // ============================================================
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! Versuchs später nochmal.", "🎅 Ho ho ho zu früh! Versuch es 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!",
@@ -79,9 +79,19 @@ window.showLockedPopup = function (day) {
const zufall = sprueche[Math.floor(Math.random() * sprueche.length)]; const zufall = sprueche[Math.floor(Math.random() * sprueche.length)];
// Zeitpunkt berechnen
const yearMatch = document.title.match(/\d{4}/);
const year = yearMatch ? parseInt(yearMatch[0], 10) : new Date().getFullYear();
const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0); // 11 = Dezember
// hübsches deutsches Datum
const options = { day: "2-digit", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit" };
const dateText = unlockDate.toLocaleString("de-DE", options).replace(" um", ",");
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>
`; `;
popupOverlay.classList.add("active"); popupOverlay.classList.add("active");