Fehlerkorrekturen popup.js
This commit is contained in:
@@ -5,6 +5,16 @@ const popupBox = document.getElementById("popup-box");
|
|||||||
const popupContent = document.getElementById("popup-content");
|
const popupContent = document.getElementById("popup-content");
|
||||||
const popupClose = document.getElementById("popup-close");
|
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 1–24 (Platzhalter) ===
|
// === Inhalte 1–24 (Platzhalter) ===
|
||||||
const popupData = {
|
const popupData = {
|
||||||
1: { title: "🎁 Adventskalenderstart + Daumenkino", content: placeholder("QR-Code zum Daumenkino & Intro-Post") },
|
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") }
|
24: { title: "🎬 Danke & Geschenk", content: placeholder("Finale Video & Freebie folgen") }
|
||||||
};
|
};
|
||||||
|
|
||||||
// === Platzhalterfunktion ===
|
// === Türchen öffnen – HTML laden oder Fallback ===
|
||||||
function openPopup(day) {
|
function openPopup(day) {
|
||||||
const data = popupData[day];
|
const data = popupData[day];
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
const tag = String(day).padStart(2, '0');
|
const tag = String(day).padStart(2, '0');
|
||||||
const url = `/2025/inhalte/tag${tag}.html`;
|
const url = `/2025/content/tag${tag}.html`;
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
@@ -58,27 +68,7 @@ function openPopup(day) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Öffnen / Schließen ===
|
// === Gesperrte Türchen – Zufallsspruch + Countdown ===
|
||||||
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
|
|
||||||
// ============================================================
|
|
||||||
|
|
||||||
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!",
|
||||||
@@ -94,7 +84,6 @@ 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 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
|
||||||
@@ -121,3 +110,12 @@ window.showLockedPopup = function (day) {
|
|||||||
|
|
||||||
popupOverlay.classList.add("active");
|
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;
|
||||||
Reference in New Issue
Block a user