Improved cache update handling
This commit is contained in:
parent
be608d1c5a
commit
0ca4a721ea
@ -59,6 +59,35 @@
|
||||
<script type="text/javascript" src="js/directives.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
if (!window.applicationCache || !window.addEventListener) {
|
||||
return;
|
||||
}
|
||||
var appCache = window.applicationCache,
|
||||
canceled = false,
|
||||
scheduleUpdate = function () {
|
||||
setTimeout(function () {
|
||||
appCache.update();
|
||||
}, 300000);
|
||||
};
|
||||
|
||||
window.addEventListener('load', function(e) {
|
||||
appCache.addEventListener('updateready', function(e) {
|
||||
if (appCache.status == appCache.UPDATEREADY) {
|
||||
if (!canceled && confirm('A new version of Webogram is available. Load it?')) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
canceled = true;
|
||||
scheduleUpdate();
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
appCache.addEventListener('noupdate', scheduleUpdate, false);
|
||||
appCache.addEventListener('error', scheduleUpdate, false);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user