<html manifest="appcache" content>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1 >Status Cache</h1>
<button id="valueStatus" onclick="cacheStatus()">Status Cache</button>
<?php
// put your code here
?>
</body>
</html>
<script type="text/javascript">
var appCache = window.applicationCache;
function cacheStatus(){
switch (appCache.status)
{ case "UNCACHED":
appCache.status='UNCACHED'; break;
case appCache.IDLE: // IDLE == 1
appCache.status='IDLE'; break;
case appCache.CHECKING: // CHECKING == 2
appCache.status= 'CHECKING'; break;
case appCache.DOWNLOADING: // DOWNLOADING == 3
appCache.status= 'DOWNLOADING'; break;
case appCache.UPDATEREADY: // UPDATEREADY == 4
appCache.status= 'UPDATEREADY'; break;
case appCache.OBSOLETE: // OBSOLETE == 5
appCache.status= 'OBSOLETE'; break;
default: appCache.status='UKNOWN CACHE STATUS'; break; };
return appCache.status;
}
if(cacheStatus()==0 || cacheStatus()==null){
document.getElementById("valueStatus").innerHTML="Sin Cambios";
}else{
document.getElementById("valueStatus").innerHTML=cacheStatus();
}
//De esta forma se le permite al usuario actualizar a la version mas reciente,si es que lo desea
window.addEventListener('load',function(e)
{
window.applicationCache.addEventListener('updateready',function (e)
{
if(window.applicationCache.status==window.applicationCache.UPDATEREADY)
{
//Broswer downloaded new app cache
//Swap it in and reload the page to get the new cache
window.applicationCache.swapCache();
if(confirm("A new version is available,Load it?"))
{
window.location.reload();
}
}else{
alert("Without changes in manifiest");
//The manifiest didn't changed.Nothing new to server
}
},false);
},false);
function handleCacheEvent(){}
function handleCacheError(e){
alert("Error: Fallo al descargar la cache");
}
//Ejecutado despues del primer cacheado del manifiesto
appCache.addEventListener('cached',handleCacheEvent(),false);
//Buscando una actualizacion.Este evento es el primero que se dispara en la secuencia
//checking for a update .Always the first event fired in the sequence
appCache.addEventListener('checking',handleCacheEvent(),false);
//An update was found.The browser is fetching resources
//Una actualizacion fue encontrada.El v¡navegador esta estrayendo los recursos
appCache.addEventListener('downloading',handleCacheEvent(),false);
//Fired if The manifiest return a 404 or 410.
//This results in the aplication cache being deleted
appCache.addEventListener('obsolete',handleCacheEvent(),false);
//Fired for each resource listed in the manifiest as it is being fetched
appCache.addEventListener('progress',handleCacheEvent(),false);
//Fired when the manifiest resources have been newly redownloaded
appCache.addEventListener('updateready',handleCacheEvent(),false);
</script>
<script src="js/TestOnline.js" type="text/javascript"></script>