adventskalender/2025/js/background.js aktualisiert
This commit is contained in:
@@ -21,23 +21,21 @@
|
|||||||
|
|
||||||
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 = "assets/images/";
|
const basePath = `/${YEAR}/assets/images/`; // <=== hier angepasst!
|
||||||
|
|
||||||
// === Favicon setzen (.webp) ===
|
// === Favicon setzen (.webp) ===
|
||||||
// Aufruf:
|
setFavicon(`${basePath}1920/webp/${filename}.webp`);
|
||||||
setFavicon(`assets/images/1920/webp/${filename}.webp`);
|
|
||||||
|
|
||||||
// Funktion:
|
function setFavicon(path) {
|
||||||
function setFavicon(path) {
|
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");
|
link.rel = "icon";
|
||||||
link.rel = "icon";
|
link.type = "image/png";
|
||||||
link.type = "image/png";
|
document.head.appendChild(link);
|
||||||
document.head.appendChild(link);
|
}
|
||||||
|
link.href = path;
|
||||||
}
|
}
|
||||||
link.href = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
const picture = document.querySelector(".kalenderbild picture");
|
const picture = document.querySelector(".kalenderbild picture");
|
||||||
@@ -55,17 +53,17 @@ function setFavicon(path) {
|
|||||||
if (!format) return;
|
if (!format) return;
|
||||||
|
|
||||||
const newSrcset = breakpoints
|
const newSrcset = breakpoints
|
||||||
.map(bp => `assets/images/${bp}/${format}/${filename}.${format} ${bp}w`)
|
.map(bp => `${basePath}${bp}/${format}/${filename}.${format} ${bp}w`)
|
||||||
.join(", ");
|
.join(", ");
|
||||||
source.setAttribute("srcset", newSrcset);
|
source.setAttribute("srcset", newSrcset);
|
||||||
});
|
});
|
||||||
|
|
||||||
// === <img> (JPEG-Fallback) responsiv setzen ===
|
// === <img> (JPEG-Fallback) responsiv setzen ===
|
||||||
const jpegSrcset = breakpoints
|
const jpegSrcset = breakpoints
|
||||||
.map(bp => `assets/images/${bp}/jpeg/${filename}.jpg ${bp}w`)
|
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpg ${bp}w`)
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
img.setAttribute("src", `assets/images/1920/jpeg/${filename}.jpg`);
|
img.setAttribute("src", `${basePath}1920/jpeg/${filename}.jpg`);
|
||||||
img.setAttribute("srcset", jpegSrcset);
|
img.setAttribute("srcset", jpegSrcset);
|
||||||
img.setAttribute("sizes", "100vw");
|
img.setAttribute("sizes", "100vw");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user