From 5eea4466457dac89514244b828df135192797a4a Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 22 Nov 2014 18:23:19 +0100 Subject: [PATCH] Add method to manage cache --- cache.manifest | 6 +++--- inc/myco.js | 36 ++++++++++++++++++++++++++++++++++++ index.html | 4 ++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/cache.manifest b/cache.manifest index f0f8947..912f31a 100644 --- a/cache.manifest +++ b/cache.manifest @@ -1,7 +1,5 @@ CACHE MANIFEST - -NETWORK: -* +# Date : 2014/11/22 - Version : 11 CACHE: index.html @@ -45,3 +43,5 @@ inc/lib/uuid.js inc/lib/typeahead.bundle.js inc/lib/moment.min.js +NETWORK: +* diff --git a/inc/myco.js b/inc/myco.js index d33af35..c030cad 100644 --- a/inc/myco.js +++ b/inc/myco.js @@ -950,6 +950,35 @@ pleaseWaitHide=function() { $('#please_wait_modal').modal('hide'); } +/************************** + * Cache / Update + *************************/ + +onUpdateReady=function() { + myconfirm( + "Une nouvelle version de l'application est disponible. Voulez-vous lancer la mise à jour ?", + onConfirmUpdate,null,{} + ); +} + +onConfirmUpdate=function() { + window.applicationCache.swapCache(); + location.reload(); +} + +_checkForUpgrade=false; +updateApp = function() { + _checkForUpgrade=true; + window.applicationCache.update(); +} + +onNoUpdate = function() { + if (_checkForUpgrade) { + _checkForUpgrade=false; + alert('Aucune mise à jour disponible'); + } +} + /********************* * Activate *********************/ @@ -1030,4 +1059,11 @@ $( document ).ready( function() { view_home(); pleaseWaitHide(); + + $('#update_app').bind('click',updateApp); + window.applicationCache.addEventListener('updateready', onUpdateReady); + window.applicationCache.addEventListener('noupdate', onNoUpdate); + if(window.applicationCache.status === window.applicationCache.UPDATEREADY) { + onUpdateReady(); + } } ); diff --git a/index.html b/index.html index 3c2ae12..2ceabbb 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,5 @@ - - + MyCo @@ -186,6 +185,7 @@ span.cat-color { Connexion +
  • Mise à jour de l'application