aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manifest.deploy2
-rw-r--r--source/App.js7
-rw-r--r--source/about.js2
-rw-r--r--source/api.js37
-rw-r--r--source/main.js15
-rw-r--r--source/moduleManager.js176
6 files changed, 181 insertions, 58 deletions
diff --git a/manifest.deploy b/manifest.deploy
index 3d052fe..101357b 100644
--- a/manifest.deploy
+++ b/manifest.deploy
@@ -1,6 +1,6 @@
{
"name": "BibleZ",
- "version": "1.3.1",
+ "version": "1.3.4",
"description": "BibleZ is an easy to use offline bible reader app for your FirefoxOS device! Enjoy the full bible at your fingertips. <b>Features:</b> <ul><li>many available bibles in different languages (e.g. ESV, KJV, NET (free version), ...)</li><li>notes</li><li>bookmarks</li><li>highlights</li><li>history of last read scriptures</li><li>no internet connection required (only for downloading modules)</li></ul> BibleZ is based on the SWORD Project (http://crosswire.org) and licenced under GPLv3. If you have any problems with this app just send an eMail to <a href:mailto:info@zefanjas.de>info@zefanjas.de</a>!",
"launch_path": "/index.html",
"icons": {
diff --git a/source/App.js b/source/App.js
index b682a83..7146f08 100644
--- a/source/App.js
+++ b/source/App.js
@@ -44,14 +44,17 @@ enyo.kind({
},
openModuleManager: function (inSender, inEvent) {
- if(!enyo.platform.firefoxOS) {
+ /*if(!enyo.platform.firefoxOS) {
this.$.panel.createComponent({name: "moduleManagerDesktop", kind: "biblez.moduleManagerDesktop", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {owner: this}).render();
this.$.panel.selectPanelByName("moduleManagerDesktop");
} else {
this.$.panel.createComponent({name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {owner: this}).render();
this.$.panel.selectPanelByName("moduleManager");
this.$.moduleManager.start();
- }
+ }*/
+ this.$.panel.createComponent({name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {owner: this}).render();
+ this.$.panel.selectPanelByName("moduleManager");
+ this.$.moduleManager.start();
return true;
},
diff --git a/source/about.js b/source/about.js
index 3617fd1..cc41ebf 100644
--- a/source/about.js
+++ b/source/about.js
@@ -10,7 +10,7 @@ enyo.kind({
{kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
{name: "title", content: $L("About BibleZ")}
]},
- {kind: "enyo.Scroller", fit: true, touch: true, components: [
+ {kind: "enyo.Scroller", fit: true, components: [
{classes: "settings-container", style: "text-align: center;", components: [
{tag: "img", src: "assets/biblez128.png"},
{allowHtml: true, content: "BibleZ is based on <a href='https://github.com/zefanja/swordjs' target='_blank'>swordjs</a>, a Javascript library to access the bible modules from the <a href='http://crosswire.org/sword' target='_blank'>SWORD Project</a>.<br><br>BibleZ is licenced under the GPLv3. (<a href='https://github.com/zefanja/biblez-ng' target='_blank'>Source Code</a>)"},
diff --git a/source/api.js b/source/api.js
index 37e8003..1979199 100644
--- a/source/api.js
+++ b/source/api.js
@@ -463,5 +463,42 @@ var api = {
}
});
return inTarget;
+ },
+
+ dynamicSort: function (property) {
+ return function (obj1,obj2) {
+ return obj1[property] > obj2[property] ? 1
+ : obj1[property] < obj2[property] ? -1 : 0;
+ };
+ },
+
+ dynamicSortMultiple: function () {
+ /*
+ * save the arguments object as it will be overwritten
+ * note that arguments object is an array-like object
+ * consisting of the names of the properties to sort by
+ */
+ var props = arguments;
+ return function (obj1, obj2) {
+ var i = 0, result = 0, numberOfProperties = props.length;
+ /* try getting a different result from 0 (equal)
+ * as long as we have extra properties to compare
+ */
+ while(result === 0 && i < numberOfProperties) {
+ result = api.dynamicSort(props[i])(obj1, obj2);
+ i++;
+ }
+ return result;
+ };
+ },
+
+ cleanArray: function (actual){
+ var newArray = [];
+ for(var i = 0; i<actual.length; i++){
+ if (actual[i]){
+ newArray.push(actual[i]);
+ }
+ }
+ return newArray;
}
}; \ No newline at end of file
diff --git a/source/main.js b/source/main.js
index f66cc7c..f583bc9 100644
--- a/source/main.js
+++ b/source/main.js
@@ -74,7 +74,7 @@ enyo.kind({
//{name: "btFont", kind: "onyx.IconButton", src: "assets/font.png", ontap: "handleFontMenu"}
]},
{name: "mainPanel", kind: "Panels", draggable: false, /*index: 2, */fit: true, ondragfinish: "handleChangeChapter", onTransitionStart: "handlePanelIndex", arrangerKind: "LeftRightArranger", margin: 0, classes: "background", components: [
- {name: "verseList", kind: "VerseList", touch: false, thumb: false, touchOverscroll: false, count: 0, onSetupItem: "setVerses", onScroll: "", onScrollStop: "handleScrolling", classes: "enyo-selectable", components: [
+ {name: "verseList", kind: "VerseList", touch: false, thumb: false, touchOverscroll: false, count: 0, onSetupItem: "setVerses", onScroll: "handleOnScroll", classes: "enyo-selectable", components: [
{name: "text", allowHtml: true, style: "display: inline;", ontap: "handleVerseTap", onclick: "handleVerseTap"},
{name: "imgBm", tag: "img", style: "display: inline;", showing: false, src: "assets/bookmark.png"},
{name: "imgNote", tag: "img", type: "note", style: "display: inline; margin: 0 3px;", showing: false, src: "assets/note.png", ontap: "handleVerseTap"}
@@ -119,8 +119,8 @@ enyo.kind({
create: function () {
this.inherited(arguments);
- if(enyo.platform.firefox)
- this.$.verseList.onScroll = "handleScrolling";
+ /*if(enyo.platform.firefox)
+ this.$.verseList.onScroll = "handleScrolling"; */
this.startUp();
//this.$.mainPanel.setIndexDirect(2);
@@ -609,9 +609,14 @@ enyo.kind({
return false;
},
+ handleOnScroll: function (inSender, inEvent) {
+ enyo.job("handleScrolling", this.bindSafely(function () {
+ this.handleScrolling(inSender, inEvent);
+ }), 100);
+ },
+
//handling infinite scrolling
handleScrolling: function (inSender, inEvent) {
- //FIXME implement enyo.job handling scrolling
if(this.verses.length !== 0) {
var b = inEvent.scrollBounds;
var cHeight = b.clientHeight,
@@ -623,7 +628,7 @@ enyo.kind({
this.rowSize = Math.round(b.height / this.verses.length); // this.$.verseList.getRowSize();
this.offset = Math.round(b.top / this.rowSize);
if (this.verses[this.offset] && this.verses[this.offset].osisRef) {
- //this.setPassage({offsetRef: this.verses[this.offset].osisRef});
+ this.setPassage({offsetRef: this.verses[this.offset].osisRef});
}
}
diff --git a/source/moduleManager.js b/source/moduleManager.js
index 44995de..77cb32f 100644
--- a/source/moduleManager.js
+++ b/source/moduleManager.js
@@ -16,7 +16,7 @@ enyo.kind({
{name: "panel", arrangerKind: "CollapsingArranger", fit: true, kind: "Panels", classes: "app-panels", components: [
{name: "panelLang", kind: "enyo.FittableRows", components: [
{classes: "center", components: [{kind: "onyx.Spinner", name: "spinner", classes: "onyx-light center"}]},
- {name: "langList", kind: "List", fit: true, touch: true, onSetupItem: "setupLangItem", components: [
+ {name: "langList", kind: "List", fit: true, onSetupItem: "setupLangItem", components: [
{classes: "item", ontap: "handleLanguage", components: [
{kind: "enyo.FittableColumns", components: [
{name: "langShort", classes: "item-left"},
@@ -27,14 +27,14 @@ enyo.kind({
]}
]},
{name: "panelModules", kind: "enyo.FittableRows", components: [
- {name: "modList", kind: "List", fit: true, touch: true, onSetupItem: "setupModItem", components: [
+ {name: "modList", kind: "List", fit: true, onSetupItem: "setupModItem", components: [
{classes: "item", ontap: "handleModule", components: [
{name: "modName"}
]}
]}
]},
{name: "panelDescription", kind: "enyo.FittableRows", components: [
- {kind: enyo.Scroller, touch: true, fit: true, components: [
+ {kind: enyo.Scroller, fit: true, components: [
{name: "detailsContainer", showing: false, classes: "content-container", components: [
{name: "detailsName", classes: "title"},
//{kind: "onyx.ProgressBar", name: "progressBar", progress: 0, showing: false, showStripes: false},
@@ -64,7 +64,6 @@ enyo.kind({
start: function () {
if (!this.started) {
- //this.$.scrim.show();
this.$.spinner.show();
api.get("repos", enyo.bind(this, function (inError, inData) {
if(!inData)
@@ -118,8 +117,26 @@ enyo.kind({
getRepos: function () {
if(navigator.onLine)
- sword.installMgr.getRepositories(enyo.bind(this, function (inError, inRepos) {
- if (!inError) {
+ 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);
+ })
+ );
+
+ } else {
+ this.handleError(inError);
+ }
+ }));
+ } else {
+ 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)
@@ -128,11 +145,11 @@ enyo.kind({
this.handleError(inError);
})
);
-
- } else {
- this.handleError(inError);
- }
- }));
+ });
+ xhr.error(this, function (inSender, inResponse) {
+ this.handleError({message: "Couldn't download MasterList!"});
+ });
+ }
else {
this.$.spinner.stop();
this.handleError({message: $L("You need an internet connection to download modules!")});
@@ -140,26 +157,28 @@ enyo.kind({
},
setupRepoPicker: function (inRepos, currentRepo) {
+ this.currentRepo = currentRepo;
var items = [],
cw = null;
- inRepos.forEach(function(repo, idx) {
- if ((currentRepo && repo.name === currentRepo.name) || repo.name === "CrossWire") {
+ inRepos.forEach(enyo.bind(this, function(repo, idx) {
+ if ((this.currentRepo && repo.name === this.currentRepo.name) || repo.name === "CrossWire") {
items.push({content: repo.name, index: idx, active: true});
cw = repo;
} else items.push({content: repo.name, index: idx});
- });
+ }));
this.repos = inRepos;
this.$.repoPicker.createComponents(items, {owner: this});
this.$.repoPicker.render();
- if (currentRepo)
- this.getRemoteModules(currentRepo);
+ if (this.currentRepo)
+ this.getRemoteModules(this.currentRepo);
else
this.getRemoteModules(cw);
},
getRemoteModules: function (inRepo) {
+ this.currentRepo = inRepo;
//console.log(inRepo);
api.get("downloadedModules", enyo.bind(this, function (inError, allModules) {
//console.log(inRepo, allModules, this.repos);
@@ -169,22 +188,42 @@ enyo.kind({
this.prepareLangList(this.modules);
} else {
if (navigator.onLine)
- sword.installMgr.getModules(inRepo, enyo.bind(this, function (inError, inModules) {
- //enyo.log(inError, inModules, inModules.length);
- if(!inError) {
- if(!allModules) allModules = {id: "downloadedModules"};
- allModules[inRepo.name.replace(" ", "")] = {modules: inModules, name: inRepo.name};
- api.put(allModules, enyo.bind(this, function (inError, inId) {
- if(inError)
- this.handleError(inError);
- }));
- this.modules = inModules;
- this.prepareLangList(this.modules);
+ if(enyo.platform.firefoxOS) {
+ sword.installMgr.getModules(inRepo, enyo.bind(this, function (inError, inModules) {
+ //enyo.log(inError, inModules, inModules.length);
+ if(!inError) {
+ if(!allModules) allModules = {id: "downloadedModules"};
+ allModules[inRepo.name.replace(" ", "")] = {modules: inModules, name: inRepo.name};
+ api.put(allModules, enyo.bind(this, function (inError, inId) {
+ if(inError)
+ this.handleError(inError);
+ }));
+ this.modules = inModules;
+ this.prepareLangList(this.modules);
- } else {
- this.handleError((inError.message) ? inError.message : inError);
- }
- }));
+ } else {
+ this.handleError((inError.message) ? inError.message : inError);
+ }
+ }));
+ } else {
+ var xhr = new enyo.Ajax({url: "http://zefanjas.de/apps/biblezModules.php"});
+ xhr.go({modUrl: inRepo.url});
+ xhr.response(this, function (inSender, inModules) {
+ inModules = api.cleanArray(inModules).sort(api.dynamicSortMultiple("Lang", "moduleKey"));
+ if(!allModules) allModules = {id: "downloadedModules"};
+ allModules[inRepo.name.replace(" ", "")] = {modules: inModules, name: inRepo.name};
+ api.put(allModules, enyo.bind(this, function (inError, inId) {
+ if(inError)
+ this.handleError(inError);
+ }));
+ this.modules = inModules;
+ this.prepareLangList(this.modules);
+ });
+ xhr.error(this, function (inSender, inResponse) {
+ //console.log(inSender, inResponse);
+ this.handleError({message: "Couldn't download Modules!"});
+ });
+ }
else {
this.$.spinner.stop();
this.handleError({message: $L("You need an internet connection to download modules!")});
@@ -263,24 +302,63 @@ enyo.kind({
this.$.btnInstall.setDisabled(true);
this.$.progressBar.show();
this.$.bottomTB.render();
- sword.installMgr.installModule(this.currentModule.url, enyo.bind(this, function (inError, inModule) {
- if (!inError) {
- this.doInstalled();
- this.getInstalledModules();
- } else {
- console.log(inError);
- this.handleError(inError);
- }
- //console.log(inError, inModule);
- this.$.progressBar.hide();
- this.$.progressBar.setProgress(0);
- this.$.btnInstall.setDisabled(false);
- this.$.btnInstall.hide();
- this.$.btnRemove.show();
- }),
- enyo.bind(this, function (inEvent) {
- this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100);
- }));
+ if(enyo.platform.firefoxOS) {
+ sword.installMgr.installModule(this.currentModule.url, enyo.bind(this, function (inError, inModule) {
+ if (!inError) {
+ this.doInstalled();
+ this.getInstalledModules();
+ this.$.btnInstall.hide();
+ this.$.btnRemove.show();
+ } else {
+ console.log(inError);
+ this.handleError(inError);
+ this.$.btnInstall.show();
+ this.$.btnRemove.hide();
+ }
+ //console.log(inError, inModule);
+
+
+ }),
+ enyo.bind(this, function (inEvent) {
+ this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100);
+ }));
+ } else {
+ var xhr = new XMLHttpRequest({mozSystem: true, mozAnon: true});
+ var url = "http://zefanjas.de/apps/biblezGetModule.php?modKey="+this.currentModule.moduleKey+"&type="+this.currentRepo.type;
+ xhr.open('GET', url, true);
+ xhr.responseType = "blob";
+ xhr.onreadystatechange = enyo.bind(this, function (evt) {
+ //console.log(xhr.readyState, evt, xhr.status);
+ if (xhr.readyState == 4) {
+ if(xhr.status === 200)
+ sword.installMgr.installModule(xhr.response, enyo.bind(this, function (inError, inModule) {
+ if (!inError) {
+ this.doInstalled();
+ this.getInstalledModules();
+ this.$.btnInstall.hide();
+ this.$.btnRemove.show();
+ } else {
+ this.handleError((inError.message) ? inError.message : inError);
+ }
+ this.$.progressBar.hide();
+ this.$.progressBar.setProgress(0);
+ this.$.btnInstall.setDisabled(false);
+ }));
+ else
+ this.handleError({message: "Couldn't download module.", error: xhr.status});
+ }
+ });
+ xhr.onprogress = enyo.bind(this, function (inEvent) {
+ this.$.progressBar.animateProgressTo(inEvent.loaded/4000000*100);
+ });
+ xhr.onerror = enyo.bind(this, function (inError) {
+ this.handleError({message: "Couldn't download Module!"});
+ this.$.btnInstall.show();
+ this.$.btnRemove.hide();
+ });
+ xhr.send(null);
+ }
+
},
removeModule: function (inSender, inEvent) {