Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement