always load local manifest at startup

This gives proper content from the start, without requiring the user to check
for updates to get something out of the app.

This also gives us proper URLs for manifest and assets updates.
This commit is contained in:
Frédéric Péters 2015-08-21 22:58:33 +02:00
parent 1f9ff63368
commit 8a3b1aefc9
1 changed files with 26 additions and 0 deletions

View File

@ -116,7 +116,33 @@ var app = {
// Device ready callback
onDeviceReady: function() {
var request = new XMLHttpRequest();
request.open('GET', '../index.json');
request.onload = function() {
if (request.status != 200) {
/* this should never happen */
app.utils.setLoadingMsg("Initialisation de l'application : erreur de chargement");
} else {
var new_manifest = JSON.parse(this.responseText);
for (var attr in new_manifest.meta) {
if (new_manifest.meta.hasOwnProperty(attr)) {
app.manifest.meta[attr] = new_manifest.meta[attr];
}
}
app.manifest.title = new_manifest.title;
app.manifest.content = new_manifest.content;
app.manifest.pages = new_manifest.pages;
app.onDefaultManifestLoaded();
}
};
request.send();
},
onDefaultManifestLoaded: function() {
app.initApplication();
},
initApplication: function() {
// Init fileSystem
app.initFileSystem();