// allows user to update app at runtime when cache-manifest is changed on server
console.log("App cache status: " + getCacheStatus(window.applicationCache.status));
var updateCacheHandler = function() {
if( confirm("Update available, update now?") ) {
window.applicationCache.update();
window.applicationCache.swapCache();
window.location.reload(true);
}
window.applicationCache.removeEventListener('updateready', updateCacheHandler);
}
window.applicationCache.addEventListener('updateready', updateCacheHandler, false);
function getCacheStatus(status) {
switch(status.toString()) {
case "0" : return "UNCACHED";
case "1" : return "IDLE";
case "2" : return "CHECKING";
case "3" : return "DOWNLOADING";
case "4" : return "UPDATEREADY";
}
return null;
}