Day01 Fehlerbehebung
This commit is contained in:
@@ -5,6 +5,8 @@ const popupBox = document.getElementById("popup-box");
|
||||
const popupContent = document.getElementById("popup-content");
|
||||
const popupClose = document.getElementById("popup-close");
|
||||
|
||||
let activeSound = null; // aktuell laufender Hintergrundsound
|
||||
|
||||
// === Platzhalterfunktion ===
|
||||
function placeholder(text) {
|
||||
return `
|
||||
@@ -65,9 +67,9 @@ function openPopup(day) {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// --- Soundeffekt FallingSnow ---
|
||||
const sound = new Audio("/2025/assets/sounds/FallingSnow.mp3");
|
||||
sound.volume = 0.5;
|
||||
sound.play().catch(() => {});
|
||||
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");
|
||||
@@ -114,7 +116,7 @@ window.showLockedPopup = function (day) {
|
||||
|
||||
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
|
||||
const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0);
|
||||
const now = new Date();
|
||||
|
||||
let diff = unlockDate - now;
|
||||
@@ -140,9 +142,24 @@ window.showLockedPopup = function (day) {
|
||||
};
|
||||
|
||||
// === Schließen ===
|
||||
popupClose.addEventListener("click", () => popupOverlay.classList.remove("active"));
|
||||
popupClose.addEventListener("click", () => {
|
||||
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 (e.target === popupOverlay) {
|
||||
popupOverlay.classList.remove("active");
|
||||
if (activeSound) {
|
||||
activeSound.pause();
|
||||
activeSound.currentTime = 0;
|
||||
activeSound = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// === Export für door-open.js ===
|
||||
|
||||
Reference in New Issue
Block a user