Update check

This commit is contained in:
Mahdi Dibaiee 2014-02-09 21:58:45 +03:30
parent ef8ddaf380
commit 483f681400

View File

@ -93,20 +93,25 @@ $(document).ready(function() {
request.onsuccess = function() { request.onsuccess = function() {
var app = this.result[0]; var app = this.result[0];
var latest = $.ajax({url:'manifest-web.webapp'}); var latest = $.ajax({url:'manifest-web.webapp'});
latest.onload = function() { var selfApp = navigator.mozApps.getSelf();
if( this.response ) { selfApp.onsuccess = function() {
var lapp = JSON.parse(this.response); if(this.result) {
alert(lapp.version); latest.onload = function() {
alert(app.manifest.version); if( this.response ) {
if( lapp.version != app.manifest.version && var lapp = JSON.parse(this.response);
confirm('A new version of this app is available, do you want to update? ' + app.manifest.version + ' to ' + lapp.version )) { alert(lapp.version);
var ins = navigator.mozApps.install('http://mdibaiee.github.io/Sketchy/Web/manifest-web.webapp'); alert(app.manifest.version);
ins.onsuccess = function() { if( lapp.version != app.manifest.version &&
alert('The app was installed successfuly'); confirm('A new version of this app is available, do you want to update? ' + app.manifest.version + ' to ' + lapp.version )) {
} var ins = navigator.mozApps.install('http://mdibaiee.github.io/Sketchy/Web/manifest-web.webapp');
ins.onerror = function() { ins.onsuccess = function() {
alert('There was an error installing app') alert('The app was installed successfuly');
console.log(this.error); }
ins.onerror = function() {
alert('There was an error installing app')
console.log(this.error);
}
}
} }
} }
} }