Add method to manage cache

This commit is contained in:
Benjamin Renard 2014-11-22 18:23:19 +01:00 committed by root
parent 427062ff9d
commit 5eea446645
3 changed files with 41 additions and 5 deletions

View file

@ -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:
*

View file

@ -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();
}
} );

View file

@ -1,6 +1,5 @@
<!DOCTYPE html>
<!--<html manifest="cache.manifest">-->
<html>
<html manifest="cache.manifest">
<head>
<title>MyCo</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
@ -186,6 +185,7 @@ span.cat-color {
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class='glyphicon glyphicon-user'></span> <span id='user-name'>Connexion</span> <b class="caret"></b></a>
<ul id="user-menu" class="dropdown-menu"></ul>
</li>
<li><a id='update_app'><span class='glyphicon glyphicon-refresh'></span> Mise à jour de l'application</a></li>
</ul>
</div><!--/.nav-collapse -->