Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Forked from 1yzo/e.js
Last active June 16, 2019 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/c028560a3386ed0759c2f4b7ed4cbb52 to your computer and use it in GitHub Desktop.
Save Noitidart/c028560a3386ed0759c2f4b7ed4cbb52 to your computer and use it in GitHub Desktop.
if (typeof unreg !== 'undefined') unreg();
function logOnline() {
console.log('ONLINE', new Date().toLocaleTimeString())
}
function logOffline() {
console.log('offline', new Date().toLocaleTimeString())
}
function reg() {
window.addEventListener('online', logOnline);
window.addEventListener('offline', logOffline);
}
function unreg() {
window.removeEventListener('online', logOnline);
window.removeEventListener('offline', logOffline);
}
reg();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment