added deck progress

This commit is contained in:
2026-04-22 00:54:47 -07:00
parent 1b7d752e4e
commit 59a70fae0c
4 changed files with 152 additions and 74 deletions
+27 -19
View File
@@ -35,6 +35,8 @@
timeFormatEl: document.getElementById("time-format"),
birthDateEl: document.getElementById("birth-date"),
tarotDeckEl: document.getElementById("tarot-deck"),
tarotDeckCacheProgressEl: document.getElementById("tarot-deck-cache-progress"),
tarotDeckCacheProgressLabelEl: document.getElementById("tarot-deck-cache-progress-label"),
tarotDeckCacheStatusEl: document.getElementById("tarot-deck-cache-status"),
stellariumBackgroundEl: document.getElementById("stellarium-background"),
stellariumBackgroundHintEl: document.getElementById("stellarium-background-hint"),
@@ -205,11 +207,13 @@
function formatDeckCacheStatus(status) {
const activeDeckId = String(status?.activeDeckId || normalizeTarotDeck(getElements().tarotDeckEl?.value)).trim().toLowerCase();
const totalDeckCount = Number(status?.totalDeckCount) || 0;
const warmedDeckCount = Number(status?.warmedDeckCount) || 0;
const warmedAllDecks = totalDeckCount > 0 && warmedDeckCount >= totalDeckCount;
const loadedCount = Math.max(0, Number(status?.selectedDeckLoadedCount) || 0);
const totalCount = Math.max(0, Number(status?.selectedDeckTotalCount) || 0);
if (status?.selectedDeckPhase === "loading") {
if (totalCount > 0) {
return `Caching selected deck images to this browser... (${loadedCount}/${totalCount})`;
}
return "Caching selected deck images to this browser...";
}
@@ -217,21 +221,7 @@
return "Selected deck cache warmup hit an error. Images will still load on demand.";
}
if (status?.backgroundPhase === "loading") {
if (warmedDeckCount > 0 && totalDeckCount > 0) {
return `Selected deck cached. Warming remaining decks in background (${warmedDeckCount}/${totalDeckCount}).`;
}
return "Selected deck cached. Warming remaining decks in background...";
}
if (status?.backgroundPhase === "error") {
return "Selected deck cached. Background warmup for other decks stopped early.";
}
if (status?.selectedDeckPhase === "ready" || warmedAllDecks) {
if (warmedAllDecks) {
return "Selected deck cached. All available decks are warmed in this browser.";
}
if (status?.selectedDeckPhase === "ready") {
return `Selected deck cached and ready for fullscreen use (${activeDeckId}).`;
}
@@ -239,12 +229,30 @@
}
function syncDeckCacheStatus(status) {
const { tarotDeckCacheStatusEl } = getElements();
const {
tarotDeckCacheStatusEl,
tarotDeckCacheProgressEl,
tarotDeckCacheProgressLabelEl
} = getElements();
if (!tarotDeckCacheStatusEl) {
return;
}
tarotDeckCacheStatusEl.textContent = formatDeckCacheStatus(status);
const totalCount = Math.max(0, Number(status?.selectedDeckTotalCount) || 0);
const loadedCount = Math.max(0, Number(status?.selectedDeckLoadedCount) || 0);
const derivedPercent = totalCount > 0 ? Math.round((loadedCount / totalCount) * 100) : 0;
const percent = Math.max(0, Math.min(100, Number(status?.selectedDeckPercent) || derivedPercent));
if (tarotDeckCacheProgressEl) {
tarotDeckCacheProgressEl.max = 100;
tarotDeckCacheProgressEl.value = percent;
}
if (tarotDeckCacheProgressLabelEl) {
tarotDeckCacheProgressLabelEl.textContent = `${percent}%`;
}
}
function syncSky(geo, options) {