Spaces:
Running
Running
Download static/loading.js from KrishMalik/delta-v: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/KrishMalik/delta-v/resolve/main/static/loading.js
- Command line
-
hf download hf://spaces/KrishMalik/delta-v/static/loading.js
-
curl -L -o loading.js https://huggingface.co/spaces/KrishMalik/delta-v/resolve/main/static/loading.js
1.26 kB
| // Track visible work by page so unrelated preloads cannot hold the bar open. | |
| const DeltaLoading = (() => { | |
| const bar = document.getElementById("site-loading"); | |
| const slow = document.getElementById("site-slow"); | |
| const SLOW_MS = 4000; | |
| const pending = new Set(); | |
| let slowTimer = null; | |
| // The Space can take tens of seconds on a first visit, so say so when the bar stays up. | |
| function refresh() { | |
| const page = document.body.dataset.page; | |
| bar.hidden = !Array.from(pending).some(pages => !pages.length || pages.includes(page)); | |
| if (bar.hidden) { | |
| clearTimeout(slowTimer); | |
| slowTimer = null; | |
| slow.hidden = true; | |
| } else if (slowTimer === null && slow.hidden) { | |
| slowTimer = setTimeout(() => { | |
| slowTimer = null; | |
| slow.hidden = bar.hidden; | |
| }, SLOW_MS); | |
| } | |
| } | |
| function start(...pages) { | |
| pending.add(pages); | |
| refresh(); | |
| return () => { | |
| pending.delete(pages); | |
| refresh(); | |
| }; | |
| } | |
| function track(promise, ...pages) { | |
| const finish = start(...pages); | |
| return Promise.resolve(promise).finally(finish); | |
| } | |
| if (document.readyState !== "complete") { | |
| window.addEventListener("load", start(), { once: true }); | |
| } | |
| return { refresh, start, track }; | |
| })(); | |