mirror of
https://github.com/getbible/app.git
synced 2024-12-22 07:48:55 +00:00
Removed static web urls and fixed some issues
This commit is contained in:
parent
195eec66b1
commit
10c4e1e6c5
@ -4,6 +4,8 @@
|
||||
let BASE_URL = 'https://getbible.net';
|
||||
let API_VERSION = 'v2';
|
||||
|
||||
export { BASE_URL, API_VERSION };
|
||||
|
||||
|
||||
export default {
|
||||
get_translations(){
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
cursor.continue();
|
||||
}
|
||||
};
|
||||
trans.onerror = e => {
|
||||
reject(e)
|
||||
}
|
||||
trans.onabort = e => {
|
||||
reject(e)
|
||||
}
|
||||
trans.commit();
|
||||
|
||||
});
|
||||
},
|
||||
// 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();
|
||||
|
||||
// });
|
||||
// },
|
||||
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
<script>
|
||||
import _ from 'lodash';
|
||||
import { mapGetters } from 'vuex'
|
||||
import { BASE_URL, API_VERSION } from '../api/getbible_v2_api'
|
||||
|
||||
export default {
|
||||
components:{
|
||||
@ -63,7 +64,7 @@ export default {
|
||||
headers: {'Access-Control-Allow-Origin': '*'}
|
||||
};
|
||||
|
||||
let url = `https://getbible.net/v2/${this.translation}/${this.book}/${this.chapter_num}.json`
|
||||
let url = `${BASE_URL}/${API_VERSION}/${this.translation}/${this.book}/${this.chapter_num}.json`
|
||||
|
||||
let response = await fetch(url, config).catch(function(err) {
|
||||
this.chapter = err
|
||||
@ -98,7 +99,7 @@ export default {
|
||||
this.loading =true
|
||||
this.progress =25
|
||||
this.message = 'Loading...'
|
||||
let url = `https://getbible.net/v2/${this.translation}/books.json`
|
||||
let url = `${BASE_URL}/${API_VERSION}/${this.translation}/books.json`
|
||||
fetch(url,config)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@ -117,7 +118,7 @@ export default {
|
||||
let config = {
|
||||
headers: {'Access-Control-Allow-Origin': '*'}
|
||||
};
|
||||
fetch(`https://getbible.net/v2/${this.translation}/${this.book}/chapters.json`,config)
|
||||
fetch(`${BASE_URL}/${API_VERSION}/${this.translation}/${this.book}/chapters.json`,config)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// console.log(data)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div id="selection" class="primary text-secondary uk-animation-slide-bottom uk-width-1-1 uk-card uk-card-default uk-card-body rounded" uk-margin>
|
||||
<div class="" v-if="!saved_translations.length>0">No translation added. <br/>Please click <a @click="open_settings">HERE</a> to Open Settings</div>
|
||||
<div class="" v-if="!saved_translations.length>0">No translations added. <br/>Please click <a @click="open_settings">HERE</a> to Open Settings</div>
|
||||
<div v-else>
|
||||
|
||||
<ul class="uk-nav-default uk-nav-parent-icon uk-witdth-1-1 " uk-nav="multiple: false" >
|
||||
|
@ -3,34 +3,10 @@
|
||||
export default {
|
||||
add_translation (state, payload ) {
|
||||
|
||||
// payload = {
|
||||
// translation:{
|
||||
// name: 'translation',
|
||||
// putObj: {}
|
||||
// },
|
||||
// saved_translations:{
|
||||
// name: 'saved_translation',
|
||||
// putObj: {}
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
state.saved_translations.push(payload.saved_translations.putObj)
|
||||
|
||||
},
|
||||
REMOVE_TRANSLATION (state, payload ) {
|
||||
// payload example
|
||||
// payload = {
|
||||
// translation:{
|
||||
// name: 'translation',
|
||||
// keyPath: 'aksjv'
|
||||
// },
|
||||
// saved_translations:{
|
||||
// name: 'saved_translation',
|
||||
// keyPath: "askjv"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
const {keyPath} = payload.saved_translations;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user