Fehlerkorrekturen popup.js

This commit is contained in:
2025-11-09 22:25:03 +01:00
parent d744a3b701
commit 139fd1404c

View File

@@ -5,6 +5,16 @@ const popupBox = document.getElementById("popup-box");
const popupContent = document.getElementById("popup-content");
const popupClose = document.getElementById("popup-close");
// === Platzhalterfunktion ===
function placeholder(text) {
return `
<div class="placeholder">
<p><em>${text}</em></p>
<p style="opacity:0.7;">(Inhalt wird noch produziert)</p>
</div>
`;
}
// === Inhalte 124 (Platzhalter) ===
const popupData = {
1: { title: "🎁 Adventskalenderstart + Daumenkino", content: placeholder("QR-Code zum Daumenkino & Intro-Post") },
@@ -33,13 +43,13 @@ const popupData = {
24: { title: "🎬 Danke & Geschenk", content: placeholder("Finale Video & Freebie folgen") }
};
// === Platzhalterfunktion ===
// === Türchen öffnen HTML laden oder Fallback ===
function openPopup(day) {
const data = popupData[day];
if (!data) return;
const tag = String(day).padStart(2, '0');
const url = `/2025/inhalte/tag${tag}.html`;
const url = `/2025/content/tag${tag}.html`;
fetch(url)
.then(res => {
@@ -58,27 +68,7 @@ function openPopup(day) {
});
}
// === Öffnen / Schließen ===
function openPopup(day) {
const data = popupData[day];
if (!data) return;
popupContent.innerHTML = `<h2>${data.title}</h2>${data.content}`;
popupOverlay.classList.add("active");
}
popupClose.addEventListener("click", () => popupOverlay.classList.remove("active"));
popupOverlay.addEventListener("click", e => {
if (e.target === popupOverlay) popupOverlay.classList.remove("active");
});
// === Exportfunktion für door-open.js ===
window.openPopup = openPopup;
// ============================================================
// Ergänzung: Gesperrte Türchen Popup mit Zufallsspruch + Countdown-Angabe
// ============================================================
// === Gesperrte Türchen Zufallsspruch + Countdown ===
window.showLockedPopup = function (day) {
const sprueche = [
"🎁 Na na na, hier wird nicht geschummelt!",
@@ -94,7 +84,6 @@ window.showLockedPopup = function (day) {
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
@@ -121,3 +110,12 @@ window.showLockedPopup = function (day) {
popupOverlay.classList.add("active");
};
// === Schließen ===
popupClose.addEventListener("click", () => popupOverlay.classList.remove("active"));
popupOverlay.addEventListener("click", e => {
if (e.target === popupOverlay) popupOverlay.classList.remove("active");
});
// === Export für door-open.js ===
window.openPopup = openPopup;