Browse Source

Improved cache update handling

master
Igor Zhukov 11 years ago
parent
commit
0ca4a721ea
  1. 29
      app/index.html

29
app/index.html

@ -59,6 +59,35 @@ @@ -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…
Cancel
Save