Add custom overlay feature with configuration options for text and image
This commit is contained in:
@@ -58,6 +58,9 @@ const CONFIG = {
|
||||
enableKeyboardControls: true,
|
||||
alwaysShowArrows: false,
|
||||
hideArrowsOnMobile: true,
|
||||
enableCustomOverlay: false,
|
||||
customOverlayText: "",
|
||||
customOverlayImageUrl: "",
|
||||
enableCustomMediaIds: true,
|
||||
enableSeasonalContent: false,
|
||||
customMediaIds: "",
|
||||
@@ -3777,6 +3780,88 @@ const slidesInit = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const renderCustomOverlay = () => {
|
||||
let activeOverlayText = CONFIG.customOverlayText;
|
||||
let activeOverlayImage = CONFIG.customOverlayImageUrl;
|
||||
let isSeasonOverride = false;
|
||||
|
||||
if (CONFIG.enableSeasonalContent && CONFIG.seasonalSections) {
|
||||
try {
|
||||
const sections = JSON.parse(CONFIG.seasonalSections || "[]");
|
||||
const now = new Date();
|
||||
const currentMonth = now.getMonth() + 1;
|
||||
const currentDay = now.getDate();
|
||||
|
||||
for (const section of sections) {
|
||||
const startMonth = parseInt(section.StartMonth);
|
||||
const startDay = parseInt(section.StartDay);
|
||||
const endMonth = parseInt(section.EndMonth);
|
||||
const endDay = parseInt(section.EndDay);
|
||||
|
||||
let isActive = false;
|
||||
if (startMonth === endMonth) {
|
||||
if (currentMonth === startMonth && currentDay >= startDay && currentDay <= endDay) {
|
||||
isActive = true;
|
||||
}
|
||||
} else if (startMonth < endMonth) {
|
||||
if (currentMonth > startMonth && currentMonth < endMonth) {
|
||||
isActive = true;
|
||||
} else if (currentMonth === startMonth && currentDay >= startDay) {
|
||||
isActive = true;
|
||||
} else if (currentMonth === endMonth && currentDay <= endDay) {
|
||||
isActive = true;
|
||||
}
|
||||
} else { // Wraps around year
|
||||
if (currentMonth > startMonth || currentMonth < endMonth) {
|
||||
isActive = true;
|
||||
} else if (currentMonth === startMonth && currentDay >= startDay) {
|
||||
isActive = true;
|
||||
} else if (currentMonth === endMonth && currentDay <= endDay) {
|
||||
isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isActive) {
|
||||
if (section.OverlayText || section.OverlayImageUrl) {
|
||||
isSeasonOverride = true;
|
||||
if (section.OverlayText) activeOverlayText = section.OverlayText;
|
||||
if (section.OverlayImageUrl) activeOverlayImage = section.OverlayImageUrl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("🎬 Media Bar:", "Error parsing seasonal sections for overlay:", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CONFIG.enableCustomOverlay && !isSeasonOverride) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeOverlayText && !activeOverlayImage) return;
|
||||
|
||||
const overlayContainer = document.createElement("div");
|
||||
overlayContainer.className = "custom-overlay-container";
|
||||
|
||||
if (activeOverlayImage) {
|
||||
const img = document.createElement("img");
|
||||
img.className = "custom-overlay-image";
|
||||
img.src = activeOverlayImage;
|
||||
overlayContainer.appendChild(img);
|
||||
} else if (activeOverlayText) {
|
||||
const p = document.createElement("p");
|
||||
p.className = "custom-overlay-text";
|
||||
p.textContent = activeOverlayText;
|
||||
overlayContainer.appendChild(p);
|
||||
}
|
||||
|
||||
const slidesContainer = document.getElementById("slides-container");
|
||||
if (slidesContainer) {
|
||||
slidesContainer.appendChild(overlayContainer);
|
||||
}
|
||||
};
|
||||
|
||||
if (CONFIG.enableClientSideSettings) {
|
||||
MediaBarEnhancedSettingsManager.init();
|
||||
const isClientSideEnabled = MediaBarEnhancedSettingsManager.getSetting('enabled', true);
|
||||
@@ -3875,6 +3960,8 @@ const slidesInit = async () => {
|
||||
|
||||
initArrowNavigation();
|
||||
|
||||
renderCustomOverlay();
|
||||
|
||||
await SlideshowManager.loadSlideshowData();
|
||||
|
||||
SlideshowManager.initTouchEvents();
|
||||
|
||||
Reference in New Issue
Block a user