diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/App.js | 10 | ||||
-rw-r--r-- | source/api.js | 53 | ||||
-rw-r--r-- | source/main.js | 25 | ||||
-rw-r--r-- | source/notes.js | 1 | ||||
-rw-r--r-- | source/popup.js | 2 | ||||
-rw-r--r-- | source/settings.js | 1 |
6 files changed, 55 insertions, 37 deletions
diff --git a/source/App.js b/source/App.js index 1d01664..b682a83 100644 --- a/source/App.js +++ b/source/App.js @@ -21,10 +21,11 @@ enyo.kind({ onOpenAbout: "openAbout" }, {name: "bcSelector", kind: "biblez.bcSelector", onSelect: "handlePassageSelect", onBack: "handleBack"}, + {name: "notes", kind: "biblez.notes", onBack: "handleBack", onChange: "handleNote"} /*{name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {name: "moduleManagerDesktop", kind: "biblez.moduleManagerDesktop", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {name: "settings", kind: "biblez.settings", onBack: "handleBack", onChange: "handleSettings"}, - {name: "notes", kind: "biblez.notes", onBack: "handleBack", onChange: "handleNote"}, + {name: "dataView", kind: "biblez.dataView", onBack: "handleBack", onVerse: "handleVerse"}, {name: "about", kind: "biblez.about", onBack: "handleBack"}*/ ]} @@ -32,7 +33,7 @@ enyo.kind({ handleBack: function (inSender, inEvent) { this.$.panel.selectPanelByName("main"); - if(inSender.name !== "bcSelector" && inSender.name !== "notes" && inSender.name !== "settings" && inSender.name !== "dataView") + if(inSender.name !== "bcSelector" && inSender.name !== "notes") enyo.asyncMethod(inSender, "destroy"); return true; }, @@ -80,12 +81,12 @@ enyo.kind({ handleSettings: function (inSender, inEvent) { this.$.main.handleSettings(inSender, inEvent); - enyo.asyncMethod(inSender, "destroy"); + enyo.asyncMethod(this.$.settings, "destroy"); this.$.panel.selectPanelByName("main"); }, openNotes: function (inSender, inEvent) { - this.$.panel.createComponent({name: "notes", kind: "biblez.notes", onBack: "handleBack", onChange: "handleNote"}, {owner: this}).render(); + //this.$.panel.createComponent({name: "notes", kind: "biblez.notes", onBack: "handleBack", onChange: "handleNote"}, {owner: this}).render(); this.$.notes.setOsisRef(inEvent.osisRef); this.$.notes.setNoteId(inEvent.noteId); this.$.panel.selectPanelByName("notes"); @@ -93,7 +94,6 @@ enyo.kind({ handleNote: function (inSender, inEvent) { this.$.main.handleNote(inSender, inEvent); - enyo.asyncMethod(inSender, "destroy"); this.$.panel.selectPanelByName("main"); return true; }, diff --git a/source/api.js b/source/api.js index c401fef..37e8003 100644 --- a/source/api.js +++ b/source/api.js @@ -11,14 +11,17 @@ var api = { //Wraps the initialization of the IndexedDB Wrapper function wrapper: function (inCallback) { - //console.log("isInitialized...", this.isInitialized); + //console.log("main wrapper"); if (this.isInitialized) { if(inCallback) inCallback(null, this.db); } else { var self = this; this.db = new this.store({ storeName: "biblez", - dbVersion: 4, + dbVersion: 5, + indexes: [ + {name: "osisRef", keyPath: "osisRef", unique: true} + ], onStoreReady: function() { //console.log("isInitialized", self.isInitialized); self.isInitialized = true; @@ -33,7 +36,7 @@ var api = { }, bmWrapper: function (inCallback) { - //console.log("isInitialized...", this.isInitialized); + //console.log("bm wrapper"); if (this.isBmInitialized) { if(inCallback) inCallback(null, this.bmStore); } else { @@ -60,7 +63,7 @@ var api = { }, hlWrapper: function (inCallback) { - //console.log("isInitialized...", this.isHlInitialized); + //console.log("hl wrapper"); if (this.isHlInitialized) { if(inCallback) inCallback(null, this.hlStore); } else { @@ -86,7 +89,7 @@ var api = { }, noteWrapper: function (inCallback) { - //console.log("isInitialized...", this.isHlInitialized); + //console.log("note wrapper"); if (this.isNoteInitialized) { if(inCallback) inCallback(null, this.noteStore); } else { @@ -263,6 +266,13 @@ var api = { })); }, + getBatch: function (inIds, inCallback) { + this.wrapper(enyo.bind(this, function (inError, inDB) { + if(!inError) this._getBatch(inDB, inIds, inCallback); + else if(inCallback) inCallback(inError); + })); + }, + getBookmark: function (inId, inCallback) { this.bmWrapper(enyo.bind(this, function (inError, inDB) { if(!inError) this._get(inDB, inId, inCallback); @@ -313,24 +323,27 @@ var api = { }, getUserData: function(inOsis, inVMax, inCallback) { - var z=1, - userData = {}; + var userData = {}, + ids = []; inOsis = (inOsis.split(".").length === 2) ? inOsis : inOsis.split(".")[0] + "." + inOsis.split(".")[1]; for (var i=1;i<inVMax+1;i++) { - this.get(inOsis + "." + i, function (inError, inData) { - if(!inError) { - if(inData && inData.bookmarkId) - userData[inData.id] = inData; - if(inData && inData.highlightId) - userData[inData.id] = inData; - if(inData && inData.noteId) - userData[inData.id] = inData; - if(z === inVMax) inCallback(null, userData); - else z++; - } else - if(inCallback) inCallback(inError); - }); + ids.push(inOsis + "." + i); } + + this.getBatch(ids, function (inError, inData) { + if(!inError) { + inData.forEach(function (item) { + if(item.bookmarkId) + userData[item.id] = item; + if(item.highlightId) + userData[item.id] = item; + if(item.noteId) + userData[item.id] = item; + }); + inCallback(null, userData); + } else + if(inCallback) inCallback(inError); + }); }, _remove: function (inDB, inId, inCallback) { diff --git a/source/main.js b/source/main.js index 2f07df5..d7d3de8 100644 --- a/source/main.js +++ b/source/main.js @@ -273,14 +273,15 @@ enyo.kind({ this.handlePassage(this.passage); //Persist current passage - this.addToHistory(this.passage); - this.renderHistory(); - this.settings["lastRead"] = this.passage; - api.put(this.settings); - - this.$.btnPassage.setContent((this.passage.label) ? this.passage.label : api.formatOsis(this.passage.osisRef)); - //Adjust the TB Icons - this.$.topTB.resized(); + if ((this.settings.lastRead && this.passage.osisRef !== this.settings.lastRead.osisRef) || !this.settings.lastRead) { + this.addToHistory(this.passage); + this.renderHistory(); + this.settings["lastRead"] = this.passage; + api.put(this.settings); + this.$.btnPassage.setContent((this.passage.label) ? this.passage.label : api.formatOsis(this.passage.osisRef)); + //Adjust the TB Icons + this.$.topTB.resized(); + } return true; }, @@ -375,7 +376,7 @@ enyo.kind({ historySelected: function (inSender, inEvent) { if (!isNaN(inEvent.originator.index)) { - this.handlePassage(this.history[inEvent.originator.index].osisRef); + this.setPassage(this.history[inEvent.originator.index].osisRef); } }, @@ -400,7 +401,7 @@ enyo.kind({ api.getUserData(inOsis, vmax, enyo.bind(this, function (inError, inUserData) { if(!inError) { this.userData = api.extend(this.userData, inUserData); - //console.log(this.userData); + //console.log(this.userData, this.verses); Object.keys(inUserData).forEach(enyo.bind(this, function (key) { if(inUserData[key].bookmarkId) { this.updateVerses(key, {bookmark: true}); @@ -444,6 +445,8 @@ enyo.kind({ handleBookmark: function (inSender, inEvent) { if(inEvent.action === "remove") { this.updateVerses(inEvent.osisRef, {bookmark: false}); + } else { + this.updateVerses(inEvent.osisRef, {bookmark: true}); } this.handleUserData(inEvent.osisRef); }, @@ -451,6 +454,8 @@ enyo.kind({ handleHighlight: function (inSender, inEvent) { if(inEvent.action === "remove") { this.updateVerses(inEvent.osisRef, {highlight: false}); + } else { + //this.updateVerses(inEvent.osisRef, {highlight: true, color: inEvent.color}); } this.handleUserData(inEvent.osisRef); }, diff --git a/source/notes.js b/source/notes.js index d1bd1bc..6441c32 100644 --- a/source/notes.js +++ b/source/notes.js @@ -68,6 +68,7 @@ enyo.kind({ api.removeNote({id: this.noteId, osisRef: this.osisRef}, enyo.bind(this, function (inError) { if(!inError) { this.doChange({action: "remove", osisRef: this.osisRef}); + this.doBack(); } else this.handleError(inError); })); diff --git a/source/popup.js b/source/popup.js index 2f600b3..65894bd 100644 --- a/source/popup.js +++ b/source/popup.js @@ -69,7 +69,7 @@ enyo.kind({ var obj = (this.hlExists) ? {id: this.hlId, osisRef: this.osisRef, color: inSender.color} : {osisRef: this.osisRef, color: inSender.color}; api.putHighlight(obj, enyo.bind(this, function (inError, inId) { if(!inError) - this.doHighlight({osisRef: this.osisRef}); + this.doHighlight({osisRef: this.osisRef, color: inSender.color}); else console.log(inError); })); diff --git a/source/settings.js b/source/settings.js index 1d9700e..1f6850f 100644 --- a/source/settings.js +++ b/source/settings.js @@ -87,7 +87,6 @@ enyo.kind({ } } })); - }, handleSettings: function (inSender, inEvent) { |