aboutsummaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2014-04-16 20:34:21 +0700
committerzefanja <zefanja@freenet.de>2014-04-16 20:34:21 +0700
commit9d42b1160a25aa65785b13e19d5d62ad83aac545 (patch)
treeff02d9f90bc2730df866e6cc0ed8f7364b1990f0 /source
parentd733a5ef698973615fc5ffb21b563373cac48ffb (diff)
downloadbiblez-ng-9d42b1160a25aa65785b13e19d5d62ad83aac545.tar.gz
* update biblez.appcache to allow CORS
Diffstat (limited to 'source')
-rw-r--r--source/moduleManager.js47
1 files changed, 24 insertions, 23 deletions
diff --git a/source/moduleManager.js b/source/moduleManager.js
index 118e199..d865808 100644
--- a/source/moduleManager.js
+++ b/source/moduleManager.js
@@ -65,10 +65,14 @@ enyo.kind({
if (!this.started) {
this.$.spinner.show();
api.get("repos", enyo.bind(this, function (inError, inData) {
- if(!inData)
- this.getRepos();
- else
- this.setupRepoPicker(inData.repos, inData.currentRepo);
+ if(!inError) {
+ if(!inData)
+ this.getRepos();
+ else
+ this.setupRepoPicker(inData.repos, inData.currentRepo);
+ } else {
+ this.handleError(inError);
+ }
}));
}
this.getInstalledModules();
@@ -115,19 +119,11 @@ enyo.kind({
},
getRepos: function () {
- if(navigator.onLine)
+ if(navigator.onLine) {
if(enyo.platform.firefoxOS) {
sword.installMgr.getRepositories(enyo.bind(this, function (inError, inRepos) {
if (!inError) {
- api.put({id: "repos", repos: inRepos, lastRepoUpdate: {time: new Date().getTime()}},
- enyo.bind(this, function (inError, inId) {
- if(!inError)
- this.setupRepoPicker(inRepos);
- else
- this.handleError(inError);
- })
- );
-
+ this.saveRepoData(inRepos);
} else {
this.handleError(inError);
}
@@ -136,25 +132,30 @@ enyo.kind({
var xhr = new enyo.Ajax({url: "http://zefanjas.de/apps/biblezMasterlist.php"});
xhr.go();
xhr.response(this, function (inSender, inRepos) {
- api.put({id: "repos", repos: inRepos, lastRepoUpdate: {time: new Date().getTime()}},
- enyo.bind(this, function (inError, inId) {
- if(!inError)
- this.setupRepoPicker(inRepos);
- else
- this.handleError(inError);
- })
- );
+ this.saveRepoData(inRepos);
});
xhr.error(this, function (inSender, inResponse) {
+ console.log(inSender, inResponse);
this.handleError({message: "Couldn't download MasterList!"});
});
}
- else {
+ } else {
this.$.spinner.stop();
this.handleError({message: $L("You need an internet connection to download modules!")});
}
},
+ saveRepoData: function (inRepos) {
+ api.put({id: "repos", repos: inRepos, lastRepoUpdate: {time: new Date().getTime()}},
+ enyo.bind(this, function (inError, inId) {
+ if(!inError)
+ this.setupRepoPicker(inRepos);
+ else
+ this.handleError(inError);
+ })
+ );
+ },
+
setupRepoPicker: function (inRepos, currentRepo) {
this.currentRepo = currentRepo;
var items = [],