Download pool/shard010/JavaScript/0062740_offline-detection.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 692 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard010/JavaScript/0062740_offline-detection.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard010/JavaScript/0062740_offline-detection.js
-
curl -L -o 0062740_offline-detection.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard010/JavaScript/0062740_offline-detection.js
692 Bytes
| /** | |
| * A basic example of how to use event listeners to detect a change of online/offline status and | |
| * to give the user some sort of feedback, in this case by adding the `offline` class to the body | |
| * to allow styling. | |
| */ | |
| (function () { | |
| 'use strict'; | |
| let updateOnlineStatus = function () { | |
| let state = navigator.onLine ? 'online' : 'offline'; | |
| document.body.className = state; | |
| }; | |
| console.info('2. Offline detection running'); | |
| window.addEventListener('load', () => { | |
| window.addEventListener('online', updateOnlineStatus); | |
| window.addEventListener('offline', updateOnlineStatus); | |
| updateOnlineStatus(); | |
| }); | |
| }()); | |