-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
30 lines (27 loc) · 861 Bytes
/
scripts.js
File metadata and controls
30 lines (27 loc) · 861 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
25
26
27
28
29
30
(function () {
window.addEventListener ('load', function() {
updateOnlineStatus ();
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
window.applicationCache.addEventListener ("updateready", onUpdateReady, false);
});
function updateOnlineStatus () {
if (navigator.onLine) {
$('.online-status').removeClass ('red').addClass ('green');
$('.online-status').text ("Online");
}
else {
$('.online-status').removeClass ('green').addClass ('red');
$('.online-status').text ("Offline");
}
}
function onUpdateReady () {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// update found reload the app.
window.applicationCache.swapCache ();
window.location.reload ();
} else {
// no update. don't bother.
}
}
})();