Update check

This commit is contained in:
Mahdi Dibaiee 2014-02-09 19:57:14 +03:30
parent 8c10812a91
commit 5e98635237

View File

@ -91,9 +91,21 @@ $(document).ready(function() {
var request = navigator.mozApps.getInstalled(); var request = navigator.mozApps.getInstalled();
request.onsuccess = function() { request.onsuccess = function() {
var update;
var selfApp = navigator.mozApps.getSelf();
selfApp.onsuccess = function() {
if( this.result ) update = true;
else update = false;
}
selfApp.onsuccess = function() {
update = false;
}
var app = this.result[0]; var app = this.result[0];
if( !app && confirm('A new version is available, do you want to update?') ) { if( !app ) {
var ins = navigator.mozApps.install('mdibaiee.github.io/Sketchy/Web/manifest-web.webapp'); if( update ) confirm('A new version is available, do you want to update?')
else confirm('Do you want to Install this app?');
var ins = navigator.mozApps.install('http://mdibaiee.github.io/Sketchy/Web/manifest-web.webapp');
ins.onsuccess = function() { ins.onsuccess = function() {
alert('The app was installed successfuly'); alert('The app was installed successfuly');
} }