adventskalender/2025/js/background.js aktualisiert
This commit is contained in:
@@ -19,14 +19,15 @@
|
||||
const sim = getSimulatedDay();
|
||||
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 basePath = `/${YEAR}/assets/images/`; // <=== hier angepasst!
|
||||
const basePath = `/${YEAR}/assets/images/`;
|
||||
|
||||
// === Favicon setzen (.webp) ===
|
||||
setFavicon(`${basePath}1920/webp/${filename}.webp`);
|
||||
|
||||
function setFavicon(path) {s
|
||||
// === Favicon-Logik ===
|
||||
function setFavicon(path) {
|
||||
let link = document.querySelector('link[rel="icon"]');
|
||||
if (!link) {
|
||||
link = document.createElement("link");
|
||||
@@ -37,6 +38,11 @@
|
||||
link.href = path;
|
||||
}
|
||||
|
||||
// === Setze Favicon direkt ===
|
||||
const faviconPath = `${basePath}1920/webp/${filename}.webp`;
|
||||
setFavicon(faviconPath);
|
||||
|
||||
// === Hintergrundbilder ===
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const picture = document.querySelector(".kalenderbild picture");
|
||||
const img = picture?.querySelector("img");
|
||||
@@ -58,7 +64,7 @@
|
||||
source.setAttribute("srcset", newSrcset);
|
||||
});
|
||||
|
||||
// === <img> (JPEG-Fallback) responsiv setzen ===
|
||||
// === <img> (JPEG-Fallback) ===
|
||||
const jpegSrcset = breakpoints
|
||||
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpg ${bp}w`)
|
||||
.join(", ");
|
||||
@@ -68,7 +74,6 @@
|
||||
img.setAttribute("sizes", "100vw");
|
||||
|
||||
console.log(`[Bratonien] Kalenderbild gesetzt für Tag ${filename}`);
|
||||
setFavicon(`${basePath}1920/webp/${filename}.webp`);
|
||||
console.log(`[Bratonien] Favicon gesetzt für Tag ${filename}`);
|
||||
console.log(`[Bratonien] Favicon gesetzt: ${faviconPath}`);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user