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() {
var app = this.result[0];
var latest = $.ajax({url:'manifest-web.webapp'});
latest.onload = function() {
if( this.response ) {
var lapp = JSON.parse(this.response);
alert(lapp.version);
alert(app.manifest.version);
if( lapp.version != app.manifest.version &&
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.onsuccess = function() {
alert('The app was installed successfuly');
}
ins.onerror = function() {
alert('There was an error installing app')
console.log(this.error);
var selfApp = navigator.mozApps.getSelf();
selfApp.onsuccess = function() {
if(this.result) {
latest.onload = function() {
if( this.response ) {
var lapp = JSON.parse(this.response);
alert(lapp.version);
alert(app.manifest.version);
if( lapp.version != app.manifest.version &&
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.onsuccess = function() {
alert('The app was installed successfuly');
}
ins.onerror = function() {
alert('There was an error installing app')
console.log(this.error);
}
}
}
}
}