Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
Simplify openVerse code with supported translations list
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOfTheTiger committed Oct 31, 2018
1 parent 83cc7cc commit e001d78
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions app/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ const Store = require('electron-store');
const store = new Store();
const randomVerse = require('random-verse');

// List supported translations from OpenBibles
const obtranslations = [
'asv',
'dby',
'jub',
'kj2000',
'kjv',
'nheb',
'rsv',
'wbt',
'web',
'ylt'
]

// This function gets the book number in bible.json (i.e Genesis is 0, Exodus is 1, etc.) from its name
function getBook(bookGet) {
var i = 0;
Expand Down Expand Up @@ -368,17 +382,14 @@ function openVerse(pas) {
}
openPopup('versePopup');
document.getElementById('vs').innerText = ref;
document.getElementById('asvtext').innerText = bibles(ref, 'asv');
document.getElementById('dbytext').innerText = bibles(ref, 'darby');
document.getElementById('jubtext').innerText = bibles(ref, 'jub');
document.getElementById('kj2000text').innerText = bibles(ref, 'kj2000');
document.getElementById('kjvtext').innerText = bibles(ref, 'kjv');
document.getElementById('nhebtext').innerText = bibles(ref, 'nheb');

for (let i = 0; i < obtranslations.length; i++) {
let element = obtranslations[i];
document.getElementById(element + 'text').innerText = bibles(ref, element);
console.log('loading ' + element);

}
getNETVerse(ref);
document.getElementById('rsvtext').innerText = bibles(ref, 'rsv');
document.getElementById('wbttext').innerText = bibles(ref, 'wbt');
document.getElementById('webtext').innerText = bibles(ref, 'web');
document.getElementById('ylttext').innerText = bibles(ref, 'ylt');
document.getElementById('searchBox').placeholder = ref;
document.getElementById('searchBox').value = '';
}
Expand Down Expand Up @@ -595,17 +606,14 @@ window.onload = function() {
// Setup default verse popup
let ref = randomVerse();
document.getElementById('vs').innerText = ref;
document.getElementById('asvtext').innerText = bibles(ref, 'asv');
document.getElementById('dbytext').innerText = bibles(ref, 'darby');
document.getElementById('jubtext').innerText = bibles(ref, 'jub');
document.getElementById('kj2000text').innerText = bibles(ref, 'kj2000');
document.getElementById('kjvtext').innerText = bibles(ref, 'kjv');
document.getElementById('nhebtext').innerText = bibles(ref, 'nheb');

for (let i = 0; i < obtranslations.length; i++) {
let element = obtranslations[i];
document.getElementById(element + 'text').innerText = bibles(ref, element);
console.log('loading ' + element);

}
getNETVerse(ref);
document.getElementById('rsvtext').innerText = bibles(ref, 'rsv');
document.getElementById('wbttext').innerText = bibles(ref, 'wbt');
document.getElementById('webtext').innerText = bibles(ref, 'web');
document.getElementById('ylttext').innerText = bibles(ref, 'ylt');
document.getElementById('searchBox').placeholder = ref;
document.getElementById('searchBox').value = '';
}

0 comments on commit e001d78

Please sign in to comment.