diff --git a/adventskalender/2025/js/background.js b/adventskalender/2025/js/background.js new file mode 100644 index 0000000..6d6a08a --- /dev/null +++ b/adventskalender/2025/js/background.js @@ -0,0 +1,43 @@ +// ============================================================ +// Adventskalender 2025 – Hintergrundwechsel nach Tag +// ============================================================ + +(function() { + const pathYear = window.location.pathname.match(/(\d{4})/); + const YEAR = pathYear ? parseInt(pathYear[1], 10) : new Date().getFullYear(); + const DEV_MODE = window.location.search.includes("dev"); + const STORAGE_BASE = `bratonien_${YEAR}_lock`; + + // === Hilfsfunktion: simulierten Tag aus lock.js übernehmen === + function getSimulatedDay() { + if (!DEV_MODE) return null; + const val = localStorage.getItem(`${STORAGE_BASE}_simday`); + return val ? parseInt(val, 10) : null; + } + + // === Aktuellen oder simulierten Tag bestimmen === + const now = new Date(); + let dayToShow = now.getMonth() === 11 ? now.getDate() : 0; // Dezember = 11 + + // DEV-Override + const sim = getSimulatedDay(); + if (DEV_MODE && sim) { + dayToShow = sim; + } + + // === Bildpfad bestimmen === + let imgPath = "assets/picture/Basisbild.png"; + if (dayToShow >= 1 && dayToShow <= 24) { + const padded = String(dayToShow).padStart(2, "0"); + imgPath = `assets/picture/${padded}.png`; + } + + // === Anwendung auf das Kalenderbild === + window.addEventListener("DOMContentLoaded", () => { + const kalenderBild = document.querySelector(".kalenderbild img"); + if (!kalenderBild) return; + + kalenderBild.src = imgPath; + console.log(`[Bratonien] Hintergrund gesetzt: ${imgPath}`); + }); +})(); \ No newline at end of file