aboutsummaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2013-12-25 23:11:28 +0700
committerzefanja <zefanja@freenet.de>2013-12-25 23:11:28 +0700
commit93611890bc232a263df6459c3bdcbdf8c392e0b0 (patch)
tree2c0afb46c4963630d301451f621f0bb688dae314 /source
parent366ce9eaca8380b60bb33539be2bbf2a70779c98 (diff)
downloadbiblez-ng-93611890bc232a263df6459c3bdcbdf8c392e0b0.tar.gz
* changed currentPassage object
* further preparation for bookmarking support
Diffstat (limited to 'source')
-rw-r--r--source/api.js25
-rw-r--r--source/bcSelector.js2
-rw-r--r--source/main.js38
-rw-r--r--source/popup.js8
4 files changed, 60 insertions, 13 deletions
diff --git a/source/api.js b/source/api.js
index ef19cc8..a442a3a 100644
--- a/source/api.js
+++ b/source/api.js
@@ -78,7 +78,21 @@ var api = {
putBookmark: function (inObject, inCallback) {
this.bmWrapper(enyo.bind(this, function (inError, inDB) {
- if(!inError) this._put(inDB, inObject, inCallback);
+ if(!inError)
+ this._put(inDB, inObject, enyo.bind(this, function(inError, inId) {
+ if(!inError)
+ this.get(inObject.osisRef, enyo.bind(this, function(inError, inOsisObject) {
+ if(!inError) {
+ if(inOsisObject === undefined)
+ inOsisObject = {id: inObject.osisRef};
+ inOsisObject["bookmarkId"] = inId;
+ this.put(inOsisObject, inCallback);
+ } else
+ inCallback(inError);
+ }));
+ else
+ inCallback(inError);
+ }));
else inCallback(inError);
}));
},
@@ -112,6 +126,13 @@ var api = {
}));
},
+ getAll: function(inCallback) {
+ this.wrapper(enyo.bind(this, function (inError, inDB) {
+ if(!inError) this._getAll(inDB, inCallback);
+ else inCallback(inError);
+ }));
+ },
+
getBookmark: function (inId, inCallback) {
this.bmWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._get(inDB, inId, inCallback);
@@ -121,7 +142,7 @@ var api = {
getAllBookmarks: function (inCallback) {
this.bmWrapper(enyo.bind(this, function (inError, inDB) {
- if(!inError) this._getAll(inDB, inId, inCallback);
+ if(!inError) this._getAll(inDB, inCallback);
else inCallback(inError);
}));
}
diff --git a/source/bcSelector.js b/source/bcSelector.js
index 61111b2..681353a 100644
--- a/source/bcSelector.js
+++ b/source/bcSelector.js
@@ -76,7 +76,7 @@ enyo.kind({
},
handleChapter: function (inSender, inEvent) {
- this.doSelect({book: this.currentBook, chapter: inEvent.index+1, osis: this.currentBook.abbrev + "." + (inEvent.index+1)});
+ this.doSelect({book: this.currentBook, chapter: inEvent.index+1, osis: this.currentBook.abbrev + "." + (inEvent.index+1), label: this.currentBook.abbrev + " " + (inEvent.index+1)});
this.$.bcPanel.setIndex(0);
}
}); \ No newline at end of file
diff --git a/source/main.js b/source/main.js
index 4207e61..4c1fa50 100644
--- a/source/main.js
+++ b/source/main.js
@@ -50,7 +50,10 @@ enyo.kind({
],
currentModule: null,
- currentPassage: "Matt 1",
+ currentPassage: {
+ osis: "Matt.1",
+ label: "Matt 1"
+ },
modules: [],
panelIndex: 2,
settings: {id: "settings"},
@@ -142,23 +145,27 @@ enyo.kind({
passageChanged: function (inSender, inEvent) {
this.$.bcPopup.hide();
- this.currentPassage = inEvent.book.abbrev + " " + inEvent.chapter;
- this.handlePassage(inEvent.osis);
+ this.currentPassage.osis = inEvent.osis;
+ this.currentPassage.label = inEvent.label;
+ this.handlePassage();
},
handlePassage: function (passage) {
- //console.log("PASSAGE", inSender.getValue());
+ //console.log("PASSAGE", passage, this.currentPassage);
this.$.main.setContent("");
this.$.spinner.start();
- this.currentPassage = (!passage) ? this.currentPassage : passage;
+ if (typeof passage === "string") {
+ this.currentPassage.osis = passage.replace(" ", ".");
+ this.currentPassage.label = passage.replace(".", " ");
+ }
//Persist current passage
this.settings["lastRead"] = this.currentPassage;
this.handleUnload();
- this.$.btnPassage.setContent(this.currentPassage.replace(".", " "));
- this.currentModule.renderText(this.currentPassage, {oneVersePerLine: false}, enyo.bind(this, function (inError, inText) {
+ this.$.btnPassage.setContent(this.currentPassage.label);
+ this.currentModule.renderText(this.currentPassage.osis, {oneVersePerLine: true}, enyo.bind(this, function (inError, inText) {
this.$.spinner.stop();
if(!inError) {
this.$.verseScroller.scrollToTop();
@@ -166,6 +173,19 @@ enyo.kind({
} else
this.handleError(inError.message);
}));
+ this.handleBookmarks(this.currentPassage.osis);
+ //console.log();
+ /*api.getAll(function (inError, inAll) {
+ console.log(inAll);
+ });
+ api.getAllBookmarks(function (inError, inBookmarks) {
+ console.log(inBookmarks);
+ });*/
+ },
+
+ handleBookmarks: function (inOsis) {
+ this.currentModule.getVersesInChapter(inOsis);
+
},
handleBcSelector: function (inSender, inEvent) {
@@ -183,9 +203,9 @@ enyo.kind({
handleChangeChapter: function (inSender, inEvent) {
if(this.currentModule) {
if(this.panelIndex === 1) {
- this.handlePassage(sword.verseKey.previous(this.currentPassage, this.currentModule.config.Versification).osis);
+ this.handlePassage(sword.verseKey.previous(this.currentPassage.osis, this.currentModule.config.Versification).osis);
} else if(this.panelIndex === 3) {
- this.handlePassage(sword.verseKey.next(this.currentPassage, this.currentModule.config.Versification).osis);
+ this.handlePassage(sword.verseKey.next(this.currentPassage.osis, this.currentModule.config.Versification).osis);
}
}
this.$.mainPanel.setIndexDirect(2);
diff --git a/source/popup.js b/source/popup.js
index 22a63c1..24b242c 100644
--- a/source/popup.js
+++ b/source/popup.js
@@ -19,6 +19,12 @@ enyo.kind({
],
handleBookmark: function (inSender, inEvent) {
- console.log(this.osisRef);
+ this.hide();
+ api.putBookmark({osisRef: this.osisRef}, function (inError, inId) {
+ if(!inError) {
+ console.log("Added Bookmark");
+ } else
+ console.log(inError);
+ });
}
}); \ No newline at end of file