From 120bc074bafd169e7804442d2382a4349ee966d4 Mon Sep 17 00:00:00 2001 From: zefanja Date: Sun, 4 May 2014 20:06:14 +0700 Subject: * added android support (adjust CORS handling) * fixed small size bug in mainView --- biblez.appcache | 2 +- manifest.deploy | 2 +- manifest.desktop | 2 +- source/main.js | 14 +---- source/moduleManager.js | 148 ++++++++++++++++++++++++++---------------------- 5 files changed, 86 insertions(+), 82 deletions(-) diff --git a/biblez.appcache b/biblez.appcache index 0a8fdbd..6825257 100644 --- a/biblez.appcache +++ b/biblez.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# v20 - 2014-04-26 +# v21 - 2014-05-04 CACHE: icon.png index.html diff --git a/manifest.deploy b/manifest.deploy index 9f9af5c..1889856 100644 --- a/manifest.deploy +++ b/manifest.deploy @@ -1,6 +1,6 @@ { "name": "BibleZ", - "version": "1.3.9", + "version": "1.3.10", "description": "BibleZ is an easy to use offline bible reader app for your FirefoxOS device! Enjoy the full bible at your fingertips. Features: 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 info@zefanjas.de!", "launch_path": "/index.html", "icons": { diff --git a/manifest.desktop b/manifest.desktop index 0986433..e5420c2 100644 --- a/manifest.desktop +++ b/manifest.desktop @@ -1,6 +1,6 @@ { "name": "BibleZ", - "version": "1.3.9", + "version": "1.3.10", "description": "BibleZ is an easy to use offline bible reader app for your Firefox! Enjoy the full bible at your fingertips. Features: 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 info@zefanjas.de!", "launch_path": "/biblez-ng/app/index.html", "icons": { diff --git a/source/main.js b/source/main.js index 15f57c9..bd9b96e 100644 --- a/source/main.js +++ b/source/main.js @@ -75,7 +75,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: "handleOnScroll", classes: "enyo-selectable", components: [ + {name: "verseList", kind: "VerseList", 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", content: "", allowHtml: true, style: "display: inline; margin: 0 3px;", showing: false, ontap: "handleVerseTap", onclick: "handleVerseTap"} @@ -175,7 +175,7 @@ enyo.kind({ this.$.mainPanel.selectPanelByName("firstStart"); this.$.mainPanel.resized(); } - this.reflow(); + this.resized(); } else { this.handleError(inError); } @@ -817,16 +817,6 @@ enyo.kind({ return true; }, - handleBackLeft: function (inSender, inEvent) { - this.$.leftBar.destroyClientControls(); - this.$.leftBar.hide(); - this.$.moduleSelector.show(); - this.$.btnPassage.applyStyle("margin-left", "6px;"); - this.$.mainView.resized(); - this.$.verseList.reset(this.offset); - return true; - }, - handlePanelIndex: function (inSender, inEvent) { this.panelIndex = inEvent.toIndex; }, diff --git a/source/moduleManager.js b/source/moduleManager.js index d865808..f3eba4b 100644 --- a/source/moduleManager.js +++ b/source/moduleManager.js @@ -120,25 +120,30 @@ enyo.kind({ getRepos: function () { if(navigator.onLine) { - if(enyo.platform.firefoxOS) { - sword.installMgr.getRepositories(enyo.bind(this, function (inError, inRepos) { - if (!inError) { - this.saveRepoData(inRepos); + if (window.navigator.mozApps) { + var request = navigator.mozApps.getSelf(); + request.onsuccess = enyo.bind(this, function() { + if (request.result && !enyo.platform.firefox) { + sword.installMgr.getRepositories(enyo.bind(this, function (inError, inRepos) { + if (!inError) { + this.saveRepoData(inRepos); + } else { + this.handleError(inError); + } + })); } else { - this.handleError(inError); + var xhr = new enyo.Ajax({url: "http://zefanjas.de/apps/biblezMasterlist.php"}); + xhr.go(); + xhr.response(this, function (inSender, inRepos) { + this.saveRepoData(inRepos); + }); + xhr.error(this, function (inSender, inResponse) { + console.log(inSender, inResponse); + this.handleError({message: "Couldn't download MasterList!"}); + }); } - })); - } else { - var xhr = new enyo.Ajax({url: "http://zefanjas.de/apps/biblezMasterlist.php"}); - xhr.go(); - xhr.response(this, function (inSender, inRepos) { - this.saveRepoData(inRepos); - }); - xhr.error(this, function (inSender, inResponse) { - console.log(inSender, inResponse); - this.handleError({message: "Couldn't download MasterList!"}); }); - } + } //else handle non firefox browser } else { this.$.spinner.stop(); this.handleError({message: $L("You need an internet connection to download modules!")}); @@ -187,31 +192,36 @@ enyo.kind({ this.modules = allModules[inRepo.name.replace(" ", "")].modules; this.prepareLangList(this.modules); } else { - if (navigator.onLine) - 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"}; - this.handleGotRemoteModules(allModules, inModules, inRepo); + if (navigator.onLine) { + if (window.navigator.mozApps) { + var request = navigator.mozApps.getSelf(); + request.onsuccess = enyo.bind(this, function() { + if (request.result && !enyo.platform.firefox) { + sword.installMgr.getModules(inRepo, enyo.bind(this, function (inError, inModules) { + //enyo.log(inError, inModules, inModules.length); + if(!inError) { + if(!allModules) allModules = {id: "downloadedModules"}; + this.handleGotRemoteModules(allModules, inModules, inRepo); + } else { + this.handleError((inError.message) ? inError.message : inError); + } + })); } else { - this.handleError((inError.message) ? inError.message : inError); + 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"}; + this.handleGotRemoteModules(allModules, inModules, inRepo); + }); + xhr.error(this, function (inSender, inResponse) { + this.handleError({message: "Couldn't download Modules!"}); + }); } - })); - } 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"}; - this.handleGotRemoteModules(allModules, inModules, inRepo); - }); - xhr.error(this, function (inSender, inResponse) { - this.handleError({message: "Couldn't download Modules!"}); }); - } - else { + } //else handle non firefox browser + } else { this.$.spinner.stop(); this.handleError({message: $L("You need an internet connection to download modules!")}); } @@ -300,39 +310,43 @@ enyo.kind({ this.$.btnInstall.setDisabled(true); this.$.progressBar.show(); this.$.bottomTB.render(); - if(enyo.platform.firefoxOS) { - this.$.progressBar.setShowStripes(false); - sword.installMgr.installModule(this.currentModule.url, - enyo.bind(this, this.handleInstalled), - enyo.bind(this, function (inEvent) { - this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100); - })); - } else { - this.$.progressBar.setShowStripes(true); - 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, this.handleInstalled)); - else - this.handleError({message: "Couldn't download module.", error: xhr.status}); + if (window.navigator.mozApps) { + var request = navigator.mozApps.getSelf(); + request.onsuccess = enyo.bind(this, function() { + if (request.result && !enyo.platform.firefox) { + this.$.progressBar.setShowStripes(false); + sword.installMgr.installModule(this.currentModule.url, + enyo.bind(this, this.handleInstalled), + enyo.bind(this, function (inEvent) { + this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100); + })); + } else { + this.$.progressBar.setShowStripes(true); + 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, this.handleInstalled)); + else + this.handleError({message: "Couldn't download module.", error: xhr.status}); + } + }); + xhr.onprogress = enyo.bind(this, function (inEvent) { + this.$.progressBar.animateProgressTo(100); + }); + xhr.onerror = enyo.bind(this, function (inError) { + this.handleError({message: "Couldn't download Module!"}); + this.$.btnInstall.show(); + this.$.btnRemove.hide(); + }); + xhr.send(null); } }); - xhr.onprogress = enyo.bind(this, function (inEvent) { - this.$.progressBar.animateProgressTo(100); - }); - xhr.onerror = enyo.bind(this, function (inError) { - this.handleError({message: "Couldn't download Module!"}); - this.$.btnInstall.show(); - this.$.btnRemove.hide(); - }); - xhr.send(null); } - }, handleInstalled: function (inError, inModule) { -- cgit