From 10c4e1e6c570189c1d3ed1f57e8ad91a0eb384a0 Mon Sep 17 00:00:00 2001 From: ohrionmartin Date: Thu, 7 Jan 2021 14:47:51 +0200 Subject: [PATCH] Removed static web urls and fixed some issues --- src/api/getbible_v2_api.js | 2 + src/api/idb.js | 91 ++++++++------- src/components/Options.vue | 213 ++++++++++++++++++----------------- src/components/Selection.vue | 6 +- src/store/mutations.js | 24 ---- 5 files changed, 165 insertions(+), 171 deletions(-) diff --git a/src/api/getbible_v2_api.js b/src/api/getbible_v2_api.js index fc703bd..737e85b 100644 --- a/src/api/getbible_v2_api.js +++ b/src/api/getbible_v2_api.js @@ -4,6 +4,8 @@ let BASE_URL = 'https://getbible.net'; let API_VERSION = 'v2'; +export { BASE_URL, API_VERSION }; + export default { get_translations(){ diff --git a/src/api/idb.js b/src/api/idb.js index 841b61f..4d2e194 100644 --- a/src/api/idb.js +++ b/src/api/idb.js @@ -27,6 +27,21 @@ export default { let db = e.target.result; db.createObjectStore("saved_translations", { keyPath:'abbreviation' }); db.createObjectStore("translations", { keyPath:'abbreviation' }); + + // let index = translations.createIndex('book_idx', 'name'); + // let transaction = db.transaction("books"); // readonly + // let books = transaction.objectStore("books"); + // let bookIndex = translations.index("book_idx"); + + // let request = bookIndex.getAll("Genesis"); + + // request.onsuccess = function() { + // if (request.result !== undefined) { + // console.log("Books", request.result); // array of books with name="Genesis" + // } else { + // console.log("No such books"); + // } + // } }; }); }, @@ -134,50 +149,50 @@ export default { }); }, - async search(name, keyPath) { + // async search(name, keyPath) { - let db = await this.getDb(); + // let db = await this.getDb(); - return new Promise((resolve, reject) => { + // return new Promise((resolve, reject) => { - let trans = db.transaction([name],'readonly'); - trans.oncomplete = () => { - resolve(tr); - }; + // let trans = db.transaction([name],'readonly'); + // trans.oncomplete = () => { + // resolve(tr); + // }; - let store = trans.objectStore(name); - let tr = {}; + // let store = trans.objectStore(name); + // let tr = {}; - store.openCursor().onsuccess = e => { - let cursor = e.target.result; - if (cursor) { - if (keyPath == cursor.value.keyPath){ - tr = cursor.value - for (const book in cursor.value.books) { - for (const chapters in book) { - for (const verses in chapters) { - for (const verse in verses) { - if(verse.text.includes(keyPath)){ - console.log("We found a row with value: " + JSON.stringify(verse.text)); - } - } - } - } - } + // store.openCursor().onsuccess = e => { + // let cursor = e.target.result; + // if (cursor) { + // if (keyPath == cursor.value.keyPath){ + // tr = cursor.value + // for (const book in cursor.value.books) { + // for (const chapters in book) { + // for (const verses in chapters) { + // for (const verse in verses) { + // if(verse.text.includes(keyPath)){ + // console.log("We found a row with value: " + JSON.stringify(verse.text)); + // } + // } + // } + // } + // } - } - cursor.continue(); - } - }; - trans.onerror = e => { - reject(e) - } - trans.onabort = e => { - reject(e) - } - trans.commit(); + // } + // cursor.continue(); + // } + // }; + // trans.onerror = e => { + // reject(e) + // } + // trans.onabort = e => { + // reject(e) + // } + // trans.commit(); - }); - }, + // }); + // }, } \ No newline at end of file diff --git a/src/components/Options.vue b/src/components/Options.vue index 79bd4f4..c8d5bb2 100644 --- a/src/components/Options.vue +++ b/src/components/Options.vue @@ -11,126 +11,127 @@ \ No newline at end of file diff --git a/src/components/Selection.vue b/src/components/Selection.vue index 64371d5..8883909 100644 --- a/src/components/Selection.vue +++ b/src/components/Selection.vue @@ -1,6 +1,6 @@