Fehlerkorrekturen

This commit is contained in:
2025-11-10 14:45:18 +01:00
parent 729b4a2d59
commit 37c8bb014f
3 changed files with 41 additions and 36 deletions

View File

@@ -87,9 +87,9 @@
</div> </div>
<!-- === Hintergrundmusik (optional) === <!-- === Hintergrundmusik (optional) === -->
<audio id="bgmusic" autoplay loop> <audio id="bgmusic" autoplay loop>
<source src="/2025/assets/sounds/FallingSnow.mp3" type="audio/mpeg"> <source src="/2025/assets/sounds/FallingSnow.mp3" type="audio/mpeg">
</audio> --> </audio>
</section> </section>

View File

@@ -51,10 +51,15 @@
if (!picture || !img || !sources) return; if (!picture || !img || !sources) return;
// === Daumenkino (nur für Tag 1) === // === Daumenkino (nur für Tag 1, wenn Popup geladen wurde) ===
if (dayToShow === 1) { if (dayToShow === 1) {
document.addEventListener("day01-loaded", () => {
const thumbkino = document.querySelector(".thumbkino-video"); const thumbkino = document.querySelector(".thumbkino-video");
if (thumbkino) { if (!thumbkino) {
console.warn("[Bratonien] Kein Daumenkino-Element gefunden.");
return;
}
const formats = ["webm", "mp4"]; const formats = ["webm", "mp4"];
const resolutions = [ const resolutions = [
"nHD", "nHD",
@@ -90,7 +95,7 @@
thumbkino.play().catch(() => {}); thumbkino.play().catch(() => {});
console.log(`[Bratonien] Daumenkino gesetzt für Tag ${padded}`); console.log(`[Bratonien] Daumenkino gesetzt für Tag ${padded}`);
} });
} }
const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840]; const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840];

View File

@@ -13,8 +13,7 @@ function placeholder(text) {
<div class="placeholder"> <div class="placeholder">
<p><em>${text}</em></p> <p><em>${text}</em></p>
<p style="opacity:0.7;">(Inhalt wird noch produziert)</p> <p style="opacity:0.7;">(Inhalt wird noch produziert)</p>
</div> </div>`;
`;
} }
// === Inhalte 124 (Platzhalter) === // === Inhalte 124 (Platzhalter) ===
@@ -50,7 +49,7 @@ 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/content/day${tag}.html`; const url = `/2025/content/day${tag}.html`;
fetch(url) fetch(url)
@@ -62,28 +61,36 @@ function openPopup(day) {
popupContent.innerHTML = `<h2>${data.title}</h2>${html}`; popupContent.innerHTML = `<h2>${data.title}</h2>${html}`;
popupOverlay.classList.add("active"); 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) { if (day === 1) {
setTimeout(() => { setTimeout(() => {
try { try {
// --- Soundeffekt FallingSnow --- const bg = popupContent.querySelector("#bgmusic");
activeSound = new Audio("/2025/assets/sounds/FallingSnow.mp3");
activeSound.volume = 0.5;
activeSound.play().catch(() => {});
// --- Daumenkino-Video (Fallback-Start) ---
const thumbkino = popupContent.querySelector(".thumbkino-video"); const thumbkino = popupContent.querySelector(".thumbkino-video");
if (bg) {
bg.volume = 0.5;
bg.currentTime = 0;
bg.play().catch(() => {});
activeSound = bg;
}
if (thumbkino) { if (thumbkino) {
thumbkino.muted = true; thumbkino.muted = true;
thumbkino.loop = true; thumbkino.loop = true;
thumbkino.play().catch(() => {}); thumbkino.play().catch(() => {});
} }
} catch (err) { } 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 { } else {
// === alle anderen Tage: nur Video-Autoplay sicherstellen === // === alle anderen Tage: nur Video-Autoplay sichern ===
setTimeout(() => { setTimeout(() => {
const videos = popupContent.querySelectorAll("video[autoplay]"); const videos = popupContent.querySelectorAll("video[autoplay]");
videos.forEach(v => v.play().catch(() => {})); videos.forEach(v => v.play().catch(() => {}));
@@ -91,7 +98,6 @@ function openPopup(day) {
} }
}) })
.catch(err => { .catch(err => {
// === Fallback auf Platzhalterinhalt ===
popupContent.innerHTML = `<h2>${data.title}</h2>${data.content}`; popupContent.innerHTML = `<h2>${data.title}</h2>${data.content}`;
popupOverlay.classList.add("active"); popupOverlay.classList.add("active");
console.warn(`Türchen ${day}: HTML konnte nicht geladen werden. Fallback verwendet.`, err); console.warn(`Türchen ${day}: HTML konnte nicht geladen werden. Fallback verwendet.`, err);
@@ -130,37 +136,31 @@ window.showLockedPopup = function (day) {
let timeText = ""; let timeText = "";
if (days > 0) timeText += `${days} Tag${days !== 1 ? "en" : ""}`; if (days > 0) timeText += `${days} Tag${days !== 1 ? "en" : ""}`;
if (hours > 0) timeText += `${timeText ? ", " : ""}${hours} Stunde${hours !== 1 ? "n" : ""}`; 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 = ` 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 in <strong>${timeText}</strong></p> <p style="margin-top: 10px; opacity: 0.8;">🔓 Öffnet in <strong>${timeText}</strong></p>
`; `;
popupOverlay.classList.add("active"); popupOverlay.classList.add("active");
}; };
// === Schließen === // === Schließen Overlay oder X-Button ===
popupClose.addEventListener("click", () => { popupClose.addEventListener("click", closePopup);
popupOverlay.classList.remove("active"); popupOverlay.addEventListener("click", e => {
if (activeSound) { if (e.target === popupOverlay) closePopup();
activeSound.pause();
activeSound.currentTime = 0;
activeSound = null;
}
}); });
popupOverlay.addEventListener("click", e => { function closePopup() {
if (e.target === popupOverlay) {
popupOverlay.classList.remove("active"); popupOverlay.classList.remove("active");
if (activeSound) { if (activeSound) {
activeSound.pause(); activeSound.pause();
activeSound.currentTime = 0; activeSound.currentTime = 0;
activeSound = null; activeSound = null;
} }
} }
});
// === Export für door-open.js === // === Export für door-open.js ===
window.openPopup = openPopup; window.openPopup = openPopup;