// ============================================================ // Adventskalender 2025 – Hintergrund- & Favicon-Wechsel 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/images/Basisbild.webp"; if (dayToShow >= 1 && dayToShow <= 24) { const padded = String(dayToShow).padStart(2, "0"); imgPath = `assets/images/${padded}.webp`; } // === Funktion zum Setzen des Favicons === function setFavicon(path) { let link = document.querySelector('link[rel="icon"]'); if (!link) { link = document.createElement("link"); link.rel = "icon"; link.type = "image/png"; document.head.appendChild(link); } link.href = path; } // === Anwendung auf das Kalenderbild & Favicon === window.addEventListener("DOMContentLoaded", () => { const kalenderBild = document.querySelector(".kalenderbild img"); if (kalenderBild) { kalenderBild.src = imgPath; console.log(`[Bratonien] Hintergrund gesetzt: ${imgPath}`); } setFavicon(imgPath); console.log(`[Bratonien] Favicon gesetzt: ${imgPath}`); }); })();