From 37c8bb014fcdc5bc7425ecf0db4b887a87ce9184 Mon Sep 17 00:00:00 2001 From: Bratonien Cosplay Date: Mon, 10 Nov 2025 14:45:18 +0100 Subject: [PATCH] Fehlerkorrekturen --- adventskalender/2025/content/day01.html | 4 +- adventskalender/2025/js/background.js | 13 ++++-- adventskalender/2025/js/popup.js | 60 ++++++++++++------------- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/adventskalender/2025/content/day01.html b/adventskalender/2025/content/day01.html index 3e12831..15658c5 100644 --- a/adventskalender/2025/content/day01.html +++ b/adventskalender/2025/content/day01.html @@ -87,9 +87,9 @@ - --> + \ No newline at end of file diff --git a/adventskalender/2025/js/background.js b/adventskalender/2025/js/background.js index 49a2200..49d3d2b 100644 --- a/adventskalender/2025/js/background.js +++ b/adventskalender/2025/js/background.js @@ -51,10 +51,15 @@ if (!picture || !img || !sources) return; - // === Daumenkino (nur für Tag 1) === + // === Daumenkino (nur für Tag 1, wenn Popup geladen wurde) === if (dayToShow === 1) { - const thumbkino = document.querySelector(".thumbkino-video"); - if (thumbkino) { + document.addEventListener("day01-loaded", () => { + const thumbkino = document.querySelector(".thumbkino-video"); + if (!thumbkino) { + console.warn("[Bratonien] Kein Daumenkino-Element gefunden."); + return; + } + const formats = ["webm", "mp4"]; const resolutions = [ "nHD", @@ -90,7 +95,7 @@ thumbkino.play().catch(() => {}); console.log(`[Bratonien] Daumenkino gesetzt für Tag ${padded}`); - } + }); } const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840]; diff --git a/adventskalender/2025/js/popup.js b/adventskalender/2025/js/popup.js index 019a681..1c1b665 100644 --- a/adventskalender/2025/js/popup.js +++ b/adventskalender/2025/js/popup.js @@ -13,8 +13,7 @@ function placeholder(text) {

${text}

(Inhalt wird noch produziert)

-
- `; + `; } // === Inhalte 1–24 (Platzhalter) === @@ -50,7 +49,7 @@ function openPopup(day) { const data = popupData[day]; if (!data) return; - const tag = String(day).padStart(2, '0'); + const tag = String(day).padStart(2, "0"); const url = `/2025/content/day${tag}.html`; fetch(url) @@ -62,28 +61,36 @@ function openPopup(day) { popupContent.innerHTML = `

${data.title}

${html}`; popupOverlay.classList.add("active"); - // === Tag 1: Soundeffekt + Daumenkino starten === + // === Event an background.js senden, sobald day01 geladen ist === + if (day === 1) { + document.dispatchEvent(new CustomEvent("day01-loaded")); + } + + // === Tag 1: Sound + Daumenkino starten === if (day === 1) { setTimeout(() => { try { - // --- Soundeffekt FallingSnow --- - activeSound = new Audio("/2025/assets/sounds/FallingSnow.mp3"); - activeSound.volume = 0.5; - activeSound.play().catch(() => {}); - - // --- Daumenkino-Video (Fallback-Start) --- + const bg = popupContent.querySelector("#bgmusic"); const thumbkino = popupContent.querySelector(".thumbkino-video"); + + if (bg) { + bg.volume = 0.5; + bg.currentTime = 0; + bg.play().catch(() => {}); + activeSound = bg; + } + if (thumbkino) { thumbkino.muted = true; thumbkino.loop = true; thumbkino.play().catch(() => {}); } } catch (err) { - console.warn("FallingSnow oder Daumenkino konnten nicht abgespielt werden:", err); + console.warn("Audio oder Video konnten nicht gestartet werden:", err); } - }, 250); // leichte Verzögerung nach DOM-Einbindung + }, 250); } else { - // === alle anderen Tage: nur Video-Autoplay sicherstellen === + // === alle anderen Tage: nur Video-Autoplay sichern === setTimeout(() => { const videos = popupContent.querySelectorAll("video[autoplay]"); videos.forEach(v => v.play().catch(() => {})); @@ -91,7 +98,6 @@ function openPopup(day) { } }) .catch(err => { - // === Fallback auf Platzhalterinhalt === popupContent.innerHTML = `

${data.title}

${data.content}`; popupOverlay.classList.add("active"); console.warn(`Türchen ${day}: HTML konnte nicht geladen werden. Fallback verwendet.`, err); @@ -130,37 +136,31 @@ window.showLockedPopup = function (day) { 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" : ""}`; + if (minutes > 0 || timeText === "") + timeText += `${timeText ? " und " : ""}${minutes} Minute${minutes !== 1 ? "n" : ""}`; popupContent.innerHTML = `

Türchen ${day} ist noch geschlossen

${zufall}

🔓 Öffnet in ${timeText}

`; - popupOverlay.classList.add("active"); }; -// === Schließen === -popupClose.addEventListener("click", () => { +// === Schließen – Overlay oder X-Button === +popupClose.addEventListener("click", closePopup); +popupOverlay.addEventListener("click", e => { + if (e.target === popupOverlay) closePopup(); +}); + +function closePopup() { popupOverlay.classList.remove("active"); if (activeSound) { activeSound.pause(); activeSound.currentTime = 0; activeSound = null; } -}); - -popupOverlay.addEventListener("click", e => { - if (e.target === popupOverlay) { - popupOverlay.classList.remove("active"); - if (activeSound) { - activeSound.pause(); - activeSound.currentTime = 0; - activeSound = null; - } - } -}); +} // === Export für door-open.js === window.openPopup = openPopup; \ No newline at end of file