Verzweiflungstat

This commit is contained in:
2025-11-10 15:12:56 +01:00
parent 6e407b8bfc
commit ca5476750b

View File

@@ -58,30 +58,33 @@ 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");
// Event für background.js // === Event für background.js (nach DOM-Initialisierung) ===
if (day === 1) { if (day === 1) {
setTimeout(() => { setTimeout(() => {
document.dispatchEvent(new CustomEvent("day01-loaded")); document.dispatchEvent(new CustomEvent("day01-loaded"));
}, 100); console.log("[popup.js] Event 'day01-loaded' ausgelöst");
}, 300);
} }
// Medien starten // === Medien starten ===
setTimeout(() => { setTimeout(() => {
const bg = popupContent.querySelector("#bgmusic"); const bg = popupContent.querySelector("#bgmusic");
const videos = popupContent.querySelectorAll("video"); const videos = popupContent.querySelectorAll("video");
// Hintergrundmusik (nur Tag 1)
if (day === 1 && bg) { if (day === 1 && bg) {
bg.volume = 0.5; bg.volume = 0.5;
bg.currentTime = 0; bg.currentTime = 0;
bg.play().catch(() => {}); bg.play().catch(err => console.warn("Audio konnte nicht gestartet werden:", err));
} }
// Alle Videos im Popup starten (autoplay / loop)
videos.forEach(v => { videos.forEach(v => {
v.muted = true; v.muted = true;
v.loop = true; v.loop = true;
v.play().catch(() => {}); v.play().catch(() => {});
}); });
}, 300); }, 500); // 500 ms Zeit für DOM + Quellen
}) })
.catch(err => { .catch(err => {
popupContent.innerHTML = `<h2>${data.title}</h2>${data.content}`; popupContent.innerHTML = `<h2>${data.title}</h2>${data.content}`;
@@ -94,7 +97,7 @@ function openPopup(day) {
function closePopup() { function closePopup() {
popupOverlay.classList.remove("active"); popupOverlay.classList.remove("active");
// Alle Audioelemente im Popup stoppen // Alle Audios im Popup stoppen
popupContent.querySelectorAll("audio").forEach(a => { popupContent.querySelectorAll("audio").forEach(a => {
a.pause(); a.pause();
a.currentTime = 0; a.currentTime = 0;