adventskalender/2025/js/background.js aktualisiert

This commit is contained in:
2025-11-08 10:57:19 +00:00
parent bc01e7729f
commit 4128c30b60

View File

@@ -19,14 +19,15 @@
const sim = getSimulatedDay(); const sim = getSimulatedDay();
if (DEV_MODE && sim) dayToShow = sim; if (DEV_MODE && sim) dayToShow = sim;
const padded = (dayToShow >= 1 && dayToShow <= 24) ? String(dayToShow).padStart(2, "0") : "Basisbild"; const padded = (dayToShow >= 1 && dayToShow <= 24)
? String(dayToShow).padStart(2, "0")
: "Basisbild";
const filename = padded; const filename = padded;
const basePath = `/${YEAR}/assets/images/`; // <=== hier angepasst! const basePath = `/${YEAR}/assets/images/`;
// === Favicon setzen (.webp) === // === Favicon-Logik ===
setFavicon(`${basePath}1920/webp/${filename}.webp`); function setFavicon(path) {
function setFavicon(path) {s
let link = document.querySelector('link[rel="icon"]'); let link = document.querySelector('link[rel="icon"]');
if (!link) { if (!link) {
link = document.createElement("link"); link = document.createElement("link");
@@ -37,6 +38,11 @@
link.href = path; link.href = path;
} }
// === Setze Favicon direkt ===
const faviconPath = `${basePath}1920/webp/${filename}.webp`;
setFavicon(faviconPath);
// === Hintergrundbilder ===
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
const picture = document.querySelector(".kalenderbild picture"); const picture = document.querySelector(".kalenderbild picture");
const img = picture?.querySelector("img"); const img = picture?.querySelector("img");
@@ -58,7 +64,7 @@
source.setAttribute("srcset", newSrcset); source.setAttribute("srcset", newSrcset);
}); });
// === <img> (JPEG-Fallback) responsiv setzen === // === <img> (JPEG-Fallback) ===
const jpegSrcset = breakpoints const jpegSrcset = breakpoints
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpg ${bp}w`) .map(bp => `${basePath}${bp}/jpeg/${filename}.jpg ${bp}w`)
.join(", "); .join(", ");
@@ -68,7 +74,6 @@
img.setAttribute("sizes", "100vw"); img.setAttribute("sizes", "100vw");
console.log(`[Bratonien] Kalenderbild gesetzt für Tag ${filename}`); console.log(`[Bratonien] Kalenderbild gesetzt für Tag ${filename}`);
setFavicon(`${basePath}1920/webp/${filename}.webp`); console.log(`[Bratonien] Favicon gesetzt: ${faviconPath}`);
console.log(`[Bratonien] Favicon gesetzt für Tag ${filename}`);
}); });
})(); })();