aboutsummaryrefslogtreecommitdiff
path: root/public/app.js
diff options
context:
space:
mode:
authordax <me@dax.ist>2026-08-05 10:31:32 +0100
committerdax <me@dax.ist>2026-08-05 10:31:32 +0100
commitf2e2648e702333ea63ab480f6e1ff4050e2880da (patch)
treeef06d1cd33d0a5345f617c4323af811c077faedf /public/app.js
parent94b4f4c2012da7714e97fc6a14cd165e456b569f (diff)
restore splash overlay
Diffstat (limited to 'public/app.js')
-rw-r--r--public/app.js40
1 files changed, 37 insertions, 3 deletions
diff --git a/public/app.js b/public/app.js
index 6e2b36e..993b40b 100644
--- a/public/app.js
+++ b/public/app.js
@@ -11,6 +11,8 @@ const toastEl = $("#toast")
const progressEl = $("#progress")
const progressFill = $("#progress-fill")
const progressText = $("#progress-text")
+const splash = $("#splash")
+const startBtn = $("#start")
addEventListener("error", (e) => {
toast(`error: ${e.message || "script failed"}`, true)
@@ -674,18 +676,50 @@ async function beginWalk() {
} catch { /* ignore */ }
}
+let hasPhotos = false
+
;(async () => {
try {
const r = await fetch("/api/paths")
const data = await r.json()
- if (data.total) await beginWalk()
- else showImportState()
- } catch {
+ hasPhotos = !!data.total
+ } catch { /* assume empty library */ }
+ if (!hasPhotos) {
+ splash.hidden = true
showImportState()
}
initDirectHint()
})()
+const MIN_READ = 1500
+const splashShownAt = Date.now()
+let splashTimer = 0
+
+function launch() {
+ if (started) return
+ clearTimeout(splashTimer)
+ splash.classList.add("hide")
+ if (hasPhotos) beginWalk()
+ else { started = true; showImportState() }
+}
+
+function noteActivity() {
+ if (started) return
+ const left = MIN_READ - (Date.now() - splashShownAt)
+ if (left <= 0) launch()
+ else {
+ clearTimeout(splashTimer)
+ splashTimer = setTimeout(launch, left)
+ }
+}
+
+startBtn.addEventListener("click", launch)
+addEventListener("pointermove", noteActivity)
+addEventListener("pointerdown", noteActivity)
+addEventListener("keydown", noteActivity)
+addEventListener("wheel", noteActivity)
+addEventListener("touchstart", noteActivity)
+
let toastTimer = 0
function toast(msg, isError = false) {