-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.js
More file actions
24 lines (21 loc) · 788 Bytes
/
main.js
File metadata and controls
24 lines (21 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Register Service Worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('./sw.js')
.then(function (register) {
console.log('PWA service worker ready');
register.update();
})
.catch(function (error) {
console.log('Register failed! Error:' + error);
});
// Check user internet status (online/offline)
function updateOnlineStatus(event) {
if (!navigator.onLine) {
alert('Internet access is not possible!')
}
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
});
}