Day01 Fehlerbehebung

This commit is contained in:
2025-11-10 14:34:40 +01:00
parent 02b520bbff
commit 729b4a2d59
3 changed files with 81 additions and 19 deletions

View File

@@ -2,10 +2,10 @@
<h3>🎁 Türchen 01</h3> <h3>🎁 Türchen 01</h3>
<!-- === Basisbild (Platzhalter oder Hauptmotiv) === --> <!-- === Basisbild (Platzhalter oder Hauptmotiv) ===
<div class="image-wrapper"> <div class="image-wrapper">
<picture> <picture>
<!-- AVIF --> <!-- AVIF
<source <source
type="image/avif" type="image/avif"
srcset=" srcset="
@@ -19,7 +19,7 @@
/2025/assets/images/3840/avif/Basisbild.avif 3840w" /2025/assets/images/3840/avif/Basisbild.avif 3840w"
sizes="100vw"> sizes="100vw">
<!-- WebP --> <!-- WebP
<source <source
type="image/webp" type="image/webp"
srcset=" srcset="
@@ -33,7 +33,7 @@
/2025/assets/images/3840/webp/Basisbild.webp 3840w" /2025/assets/images/3840/webp/Basisbild.webp 3840w"
sizes="100vw"> sizes="100vw">
<!-- JPEG-Fallback --> <!-- JPEG-Fallback
<img <img
src="/2025/assets/images/1366/jpeg/Basisbild.jpeg" src="/2025/assets/images/1366/jpeg/Basisbild.jpeg"
srcset=" srcset="
@@ -49,7 +49,7 @@
alt="Bratonien Adventskalender Tag 01" alt="Bratonien Adventskalender Tag 01"
decoding="async"> decoding="async">
</picture> </picture>
</div> </div> -->
<!-- === Daumenkino-Video === --> <!-- === Daumenkino-Video === -->
@@ -87,9 +87,9 @@
</div> </div>
<!-- === Hintergrundmusik (optional) === --> <!-- === Hintergrundmusik (optional) ===
<audio id="bgmusic" autoplay loop> <audio id="bgmusic" autoplay loop>
<source src="/2025/assets/sounds/FallingSnow.mp3" type="audio/mpeg"> <source src="/2025/assets/sounds/FallingSnow.mp3" type="audio/mpeg">
</audio> </audio> -->
</section> </section>

View File

@@ -19,7 +19,8 @@
const sim = getSimulatedDay(); const sim = getSimulatedDay();
if (DEV_MODE && sim) dayToShow = sim; if (DEV_MODE && sim) dayToShow = sim;
const padded = (dayToShow >= 1 && dayToShow <= 24) const padded =
dayToShow >= 1 && dayToShow <= 24
? String(dayToShow).padStart(2, "0") ? String(dayToShow).padStart(2, "0")
: "Basisbild"; : "Basisbild";
@@ -50,23 +51,67 @@
if (!picture || !img || !sources) return; if (!picture || !img || !sources) return;
// === Daumenkino (nur für Tag 1) ===
if (dayToShow === 1) {
const thumbkino = document.querySelector(".thumbkino-video");
if (thumbkino) {
const formats = ["webm", "mp4"];
const resolutions = [
"nHD",
"FWVGA",
"qHD",
"HD",
"HDplus",
"FullHD",
"1440p",
"4K",
];
const breakpoints = [640, 854, 960, 1280, 1600, 1920, 2560, 3840];
// alte Quellen entfernen
while (thumbkino.firstChild) thumbkino.removeChild(thumbkino.firstChild);
formats.forEach((format) => {
resolutions.forEach((res, i) => {
const mediaQuery =
i === resolutions.length - 1
? "(min-width: 2561px)"
: `(max-width: ${breakpoints[i]}px)`;
const source = document.createElement("source");
source.src = `/${YEAR}/assets/videos/${res}/${format}/${padded}.${format}`;
source.type = `video/${format}`;
source.media = mediaQuery;
thumbkino.appendChild(source);
});
});
thumbkino.load();
thumbkino.play().catch(() => {});
console.log(`[Bratonien] Daumenkino gesetzt für Tag ${padded}`);
}
}
const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840]; const breakpoints = [420, 768, 1024, 1366, 1600, 1920, 2560, 3840];
// === <source> für AVIF und WebP aktualisieren === // === <source> für AVIF und WebP aktualisieren ===
sources.forEach(source => { sources.forEach((source) => {
const type = source.getAttribute("type"); const type = source.getAttribute("type");
const format = type?.split("/")[1]; // "avif" oder "webp" const format = type?.split("/")[1]; // "avif" oder "webp"
if (!format) return; if (!format) return;
const newSrcset = breakpoints const newSrcset = breakpoints
.map(bp => `${basePath}${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) === // === <img> (JPEG-Fallback) ===
const jpegSrcset = breakpoints const jpegSrcset = breakpoints
.map(bp => `${basePath}${bp}/jpeg/${filename}.jpeg ${bp}w`) .map((bp) => `${basePath}${bp}/jpeg/${filename}.jpeg ${bp}w`)
.join(", "); .join(", ");
img.setAttribute("src", `${basePath}1920/jpeg/${filename}.jpeg`); img.setAttribute("src", `${basePath}1920/jpeg/${filename}.jpeg`);

View File

@@ -5,6 +5,8 @@ const popupBox = document.getElementById("popup-box");
const popupContent = document.getElementById("popup-content"); const popupContent = document.getElementById("popup-content");
const popupClose = document.getElementById("popup-close"); const popupClose = document.getElementById("popup-close");
let activeSound = null; // aktuell laufender Hintergrundsound
// === Platzhalterfunktion === // === Platzhalterfunktion ===
function placeholder(text) { function placeholder(text) {
return ` return `
@@ -65,9 +67,9 @@ function openPopup(day) {
setTimeout(() => { setTimeout(() => {
try { try {
// --- Soundeffekt FallingSnow --- // --- Soundeffekt FallingSnow ---
const sound = new Audio("/2025/assets/sounds/FallingSnow.mp3"); activeSound = new Audio("/2025/assets/sounds/FallingSnow.mp3");
sound.volume = 0.5; activeSound.volume = 0.5;
sound.play().catch(() => {}); activeSound.play().catch(() => {});
// --- Daumenkino-Video (Fallback-Start) --- // --- Daumenkino-Video (Fallback-Start) ---
const thumbkino = popupContent.querySelector(".thumbkino-video"); const thumbkino = popupContent.querySelector(".thumbkino-video");
@@ -114,7 +116,7 @@ window.showLockedPopup = function (day) {
const yearMatch = document.title.match(/\d{4}/); const yearMatch = document.title.match(/\d{4}/);
const year = yearMatch ? parseInt(yearMatch[0], 10) : new Date().getFullYear(); const year = yearMatch ? parseInt(yearMatch[0], 10) : new Date().getFullYear();
const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0); // 11 = Dezember const unlockDate = new Date(year, 11, parseInt(day, 10), 0, 0, 0);
const now = new Date(); const now = new Date();
let diff = unlockDate - now; let diff = unlockDate - now;
@@ -140,9 +142,24 @@ window.showLockedPopup = function (day) {
}; };
// === Schließen === // === Schließen ===
popupClose.addEventListener("click", () => popupOverlay.classList.remove("active")); popupClose.addEventListener("click", () => {
popupOverlay.classList.remove("active");
if (activeSound) {
activeSound.pause();
activeSound.currentTime = 0;
activeSound = null;
}
});
popupOverlay.addEventListener("click", e => { popupOverlay.addEventListener("click", e => {
if (e.target === popupOverlay) popupOverlay.classList.remove("active"); if (e.target === popupOverlay) {
popupOverlay.classList.remove("active");
if (activeSound) {
activeSound.pause();
activeSound.currentTime = 0;
activeSound = null;
}
}
}); });
// === Export für door-open.js === // === Export für door-open.js ===