aboutsummaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2014-01-03 19:13:50 +0700
committerzefanja <zefanja@freenet.de>2014-01-03 19:13:50 +0700
commit67e7c121c5f6a7cd9cff715894e85ea62d2cb523 (patch)
tree6261702fb502d1433fc69862d9ea950fb3cabd4e /source
parent328556250b7168ab5bf1f7ae245b4f4f756a3c3b (diff)
downloadbiblez-ng-67e7c121c5f6a7cd9cff715894e85ea62d2cb523.tar.gz
* fixed some small bugs in dataView.js, module manager and api.js
Diffstat (limited to 'source')
-rw-r--r--source/api.js3
-rw-r--r--source/dataView.js2
-rw-r--r--source/main.js10
-rw-r--r--source/moduleManager.js46
-rw-r--r--source/settings.js4
5 files changed, 51 insertions, 14 deletions
diff --git a/source/api.js b/source/api.js
index d2efafc..c8423cf 100644
--- a/source/api.js
+++ b/source/api.js
@@ -18,7 +18,7 @@ var api = {
var self = this;
this.db = new this.store({
storeName: "biblez",
- dbVersion: 3,
+ dbVersion: 4,
onStoreReady: function() {
//console.log("isInitialized", self.isInitialized);
self.isInitialized = true;
@@ -214,6 +214,7 @@ var api = {
if(inCallback) inCallback(null, inObject);
},
function (inError) {
+ console.log(inError);
if(inCallback) inCallback(inError);
}
);
diff --git a/source/dataView.js b/source/dataView.js
index e5d3a21..7edd7c2 100644
--- a/source/dataView.js
+++ b/source/dataView.js
@@ -83,7 +83,7 @@ enyo.kind({
this.$.noData.show();
if(this.section === "bookmarks")
this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
- else if(this.section === "note")
+ else if(this.section === "notes")
this.$.noData.setContent($L("No Notes.") + " " + $L("Tap on a verse number to add one."));
else if(this.section === "highlights")
this.$.noData.setContent($L("No Highlights.") + " " + $L("Tap on a verse number to add one."));
diff --git a/source/main.js b/source/main.js
index ccb19df..d7b8d28 100644
--- a/source/main.js
+++ b/source/main.js
@@ -133,6 +133,7 @@ enyo.kind({
if(this.settings.history)
this.history = this.settings.history;
} else {
+ console.log(inError);
this.handleError("Couldn't load settings!");
}
}));
@@ -215,7 +216,7 @@ enyo.kind({
if (!isNaN(inEvent.originator.index)) {
this.currentModule = this.modules[inEvent.originator.index];
this.settings["lastModule"] = this.currentModule.modKey;
- api.putSetting("lastModule", this.currentModule.modKey);
+ //api.putSetting("lastModule", this.currentModule.modKey);
this.renderModuleMenu();
}
},
@@ -247,9 +248,9 @@ enyo.kind({
}
//Persist current passage
- this.settings["lastRead"] = this.currentPassage;
this.addToHistory(this.currentPassage.osis);
- api.putSetting("lastRead", this.currentPassage);
+ this.settings["lastRead"] = this.currentPassage;
+ api.put(this.settings);
this.$.btnPassage.setContent(this.currentPassage.label);
//Adjust the TB Icons
@@ -300,7 +301,8 @@ enyo.kind({
}
}
this.history.unshift({osisRef: inOsis});
- api.putSetting("history", this.history);
+ this.settings["history"] = this.history;
+ //api.putSetting("history", this.history);
},
handleUserData: function (inOsis) {
diff --git a/source/moduleManager.js b/source/moduleManager.js
index ece7f4b..5740d45 100644
--- a/source/moduleManager.js
+++ b/source/moduleManager.js
@@ -39,6 +39,7 @@ enyo.kind({
{name: "detailsName", classes: "title"},
//{kind: "onyx.ProgressBar", name: "progressBar", progress: 0, showing: false, showStripes: false},
{kind: "onyx.Button", ontap: "installModule", name: "btnInstall", classes: "onyx-affirmative", content: $L("Install Module"), style: "margin-left: 10px;"},
+ {kind: "onyx.Button", ontap: "removeModule", name: "btnRemove", showing: false, classes: "onyx-negative", content: $L("Remove Module"), style: "margin-left: 10px;"},
{name: "detailsDescription", allowHtml: true, classes: "nice-padding"}
]}
]}
@@ -59,6 +60,7 @@ enyo.kind({
modules: [],
langModules: [],
currentModule: null,
+ installedModules: [],
start: function () {
if (!this.started) {
@@ -71,9 +73,19 @@ enyo.kind({
this.setupRepoPicker(inData.repos, inData.currentRepo);
}));
}
+ this.getInstalledModules();
this.started = true;
},
+ getInstalledModules: function () {
+ sword.moduleMgr.getModules(enyo.bind(this, function (inError, inModules) {
+ //console.log(inModules);
+ if(!inError && inModules.length !== 0) {
+ this.installedModules = inModules;
+ }
+ }));
+ },
+
handleBack: function() {
if(enyo.Panels.isScreenNarrow()) {
if(this.$.panel.getIndex() !== 0)
@@ -222,34 +234,56 @@ enyo.kind({
if(enyo.Panels.isScreenNarrow()) {
this.$.panel.next();
}
+ this.$.btnInstall.show();
+ this.$.btnRemove.hide();
+ this.currentModule = this.langModules[inEvent.index];
+ this.installedModules.forEach(enyo.bind(this, function(mod) {
+ if(mod.modKey === this.currentModule.moduleKey) {
+ this.$.btnInstall.hide();
+ this.$.btnRemove.show();
+ }
+ }));
this.$.detailsContainer.show();
- var data = this.langModules[inEvent.index];
- this.currentModule = data;
- this.$.detailsName.setContent(data.Description);
- this.$.detailsDescription.setContent(data.About.replace(/\\par/g, "<br>"));
+ this.$.detailsName.setContent(this.currentModule.Description);
+ this.$.detailsDescription.setContent(this.currentModule.About.replace(/\\par/g, "<br>"));
},
installModule: function (inSender, inEvent) {
- console.log(this.currentModule.url);
+ //console.log(this.currentModule.url);
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 {
- this.handleError((inError.message) ? inError.message : 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);
}));
},
+ removeModule: function (inSender, inEvent) {
+ sword.installMgr.removeModule(this.currentModule.moduleKey, enyo.bind(this, function (inError) {
+ if(!inError) {
+ this.doInstalled();
+ this.$.btnInstall.show();
+ this.$.btnRemove.hide();
+ } else {
+ this.handleError(inError);
+ }
+ }));
+ },
+
clearDB: function () {
sword.dataMgr.clearDatabase();
},
diff --git a/source/settings.js b/source/settings.js
index f5fa5de..9444e2c 100644
--- a/source/settings.js
+++ b/source/settings.js
@@ -22,13 +22,13 @@ enyo.kind({
]}
]},
{tag: "br"},
- {kind: "onyx.Groupbox", components: [
+ /*{kind: "onyx.Groupbox", components: [
{kind: "onyx.GroupboxHeader", content: $L("Be careful!")},
{kind: "enyo.FittableRows", classes: "settings-row", components: [
{kind: "onyx.Button", content: "Delete all modules!", classes: "onyx-negative", style: "margin: 3px;", ontap: "deleteModules"},
{kind: "onyx.Button", content: "Delete all app data!", classes: "onyx-negative", style: "margin: 3px;", ontap: "deleteDatabases"}
]}
- ]},
+ ]},*/
]}
]}