Skip to content

Instantly share code, notes, and snippets.

@1yzo
Created June 11, 2019 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 1yzo/47656e8509c5001b6879ea1054d40704 to your computer and use it in GitHub Desktop.
Save 1yzo/47656e8509c5001b6879ea1054d40704 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('ONLINE', new Date().toLocaleTimeString())
}
function reg() {
window.addEventListener('online', logOnline);
window.addEventListener('offline', logOffline);
}
function unreg() {
window.removeEventListener('online', logOnline);
window.removeEventListener('offline', logOffline);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment