Spaces:
Running
Running
Download src/update.js from davanstrien/phonon-reader: direct link, hf CLI and curl.
- Browser
- Download file 697 Bytes
-
https://huggingface.co/spaces/davanstrien/phonon-reader/resolve/main/src/update.js
- Command line
-
hf download hf://spaces/davanstrien/phonon-reader/src/update.js
-
curl -L -o update.js https://huggingface.co/spaces/davanstrien/phonon-reader/resolve/main/src/update.js
697 Bytes
| // Pick up new versions on the next launch instead of the one after: when a new | |
| // service worker takes over, reload — unless a conversion or playback is running, | |
| // in which case wait until it's idle. | |
| if ('serviceWorker' in navigator) { | |
| const hadController = !!navigator.serviceWorker.controller; | |
| const busy = () => !document.getElementById('ex-bar')?.classList.contains('hidden') | |
| || !document.getElementById('audio')?.paused; | |
| navigator.serviceWorker.addEventListener('controllerchange', () => { | |
| if (!hadController) return; // first install: nothing stale to replace | |
| const tryReload = () => (busy() ? setTimeout(tryReload, 3000) : location.reload()); | |
| tryReload(); | |
| }); | |
| } | |