Refactor renderer.js to update text colors based on sky mode and time of day
This commit is contained in:
47
renderer.js
47
renderer.js
@@ -45,6 +45,7 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Farben für Sky-Mode
|
// Farben für Sky-Mode
|
||||||
const DAY_COLOR = [173, 216, 230];
|
const DAY_COLOR = [173, 216, 230];
|
||||||
const NIGHT_COLOR = [0, 0, 50];
|
const NIGHT_COLOR = [0, 0, 50];
|
||||||
@@ -75,29 +76,42 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|||||||
if (enabled) {
|
if (enabled) {
|
||||||
updateBackground();
|
updateBackground();
|
||||||
skyIntervalId = setInterval(updateBackground, 60_000);
|
skyIntervalId = setInterval(updateBackground, 60_000);
|
||||||
function updateTitleColor() {
|
function updateAllTextColors() { setTextColor('sky'); }
|
||||||
const hour = new Date().getHours();
|
updateAllTextColors();
|
||||||
if (hour >= 18 || hour < 6) {
|
titleIntervalId = setInterval(updateAllTextColors, 60_000); // damit sich die Farbe nachts/tags ändert
|
||||||
titleEl.style.color = '#fff';
|
|
||||||
treeviewEl.style.color = '#fff';
|
|
||||||
titleArrow.style.color = '#fff';
|
|
||||||
} else {
|
|
||||||
titleEl.style.color = '';
|
|
||||||
treeviewEl.style.color = '';
|
|
||||||
titleArrow.style.color = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateTitleColor();
|
|
||||||
//titleIntervalId = setInterval(updateTitleColor, 60_000);
|
|
||||||
} else {
|
} else {
|
||||||
panel.style.backgroundColor = '';
|
panel.style.backgroundColor = '';
|
||||||
titleEl.style.color = '';
|
setTextColor('default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialSky = await window.settingsAPI.getSkyMode();
|
const initialSky = await window.settingsAPI.getSkyMode();
|
||||||
applySkyMode(initialSky);
|
applySkyMode(initialSky);
|
||||||
window.addEventListener('skymode-changed', e => applySkyMode(e.detail));
|
window.addEventListener('skymode-changed', e => applySkyMode(e.detail));
|
||||||
|
|
||||||
|
|
||||||
|
function setTextColor(mode) {
|
||||||
|
// Default: Schwarz
|
||||||
|
let textColor = '#111';
|
||||||
|
if (mode === 'sky') {
|
||||||
|
const hour = new Date().getHours();
|
||||||
|
// Sky-Mode: Tagsüber schwarz, nachts weiß
|
||||||
|
textColor = (hour >= 18 || hour < 6) ? '#fff' : '#111';
|
||||||
|
}
|
||||||
|
titleEl.style.color = textColor;
|
||||||
|
treeviewEl.style.color = textColor;
|
||||||
|
titleArrow.style.color = textColor;
|
||||||
|
// Auch die Pagination einfärben:
|
||||||
|
paginationEl.style.color = textColor;
|
||||||
|
// Falls Treeview geöffnet und HTML gerendert: auch alle Spans darin einfärben
|
||||||
|
if (treeviewEl.querySelectorAll) {
|
||||||
|
treeviewEl.querySelectorAll('.tree-file, .tree-dir').forEach(el => el.style.color = textColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function basename(fullPath) {
|
function basename(fullPath) {
|
||||||
return fullPath.replace(/.*[\\/]/, '');
|
return fullPath.replace(/.*[\\/]/, '');
|
||||||
}
|
}
|
||||||
@@ -525,7 +539,8 @@ async function startLiveCountdown(folderObj, msLeft) {
|
|||||||
const folder = folderObj.path;
|
const folder = folderObj.path;
|
||||||
await updateInteractionBar(folderObj);
|
await updateInteractionBar(folderObj);
|
||||||
titleEl.textContent = folder;
|
titleEl.textContent = folder;
|
||||||
|
setTextColor(document.body.classList.contains('sky-mode') ? 'sky' : 'default');
|
||||||
|
|
||||||
// --- Seitenwahl beim Ordnerwechsel ---
|
// --- Seitenwahl beim Ordnerwechsel ---
|
||||||
let usePage = page;
|
let usePage = page;
|
||||||
if (!usePage || folder !== lastFolderPath) {
|
if (!usePage || folder !== lastFolderPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user