mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 16:29:49 -04:00
TESTS: moar tests...
This commit is contained in:
parent
edf6475e6a
commit
7ce775059f
@ -36,3 +36,4 @@ DynamicBibleIonic/platforms/android/build.gradle
|
||||
DynamicBibleIonic/platforms/android/android.json
|
||||
DynamicBibleIonic/platforms/android/AndroidManifest.xml
|
||||
DynamicBibleIonic/platforms/android/.gitignore
|
||||
DynamicBibleIonic/.idea
|
||||
|
@ -1,290 +1,292 @@
|
||||
import { Reference } from './Reference';
|
||||
|
||||
describe('Reference', () => {
|
||||
|
||||
it('Should parse the reference: Gen 1:1', () => {
|
||||
let ref = new Reference("Gen 1:1").toString();
|
||||
expect(ref).toBe('Genesis 1:1');
|
||||
});
|
||||
|
||||
it('Should parse the reference: Gen 1:1-11', () => {
|
||||
let ref = new Reference("Gen 1:1-11").toString();
|
||||
expect(ref).toBe('Genesis 1:1 - 11');
|
||||
});
|
||||
|
||||
it('Should parse the reference: Gen 1-2', () => {
|
||||
let ref = new Reference("Gen 1-2").toString();
|
||||
expect(ref).toBe('Genesis 1:1 - 2:*');
|
||||
});
|
||||
|
||||
it('Should parse the reference: John 3:16', () => {
|
||||
let ref = new Reference("John 3:16").toString();
|
||||
expect(ref).toBe('John 3:16');
|
||||
});
|
||||
|
||||
it('Should parse the reference: John 3-6', () => {
|
||||
let ref = new Reference("Jn 3-6").toString();
|
||||
expect(ref).toBe('John 3:1 - 6:*');
|
||||
});
|
||||
|
||||
it('Should parse the reference: 1 Corinthians 3:5-6:5', () => {
|
||||
let ref = new Reference("1 Corinthians 3:5-6:5").toString();
|
||||
expect(ref).toBe('1 Corinthians 3:5 - 6:5');
|
||||
});
|
||||
|
||||
it('Should parse the reference: 2 Samuel 5:5-6:5', () => {
|
||||
expect(new Reference("II sam 5:5-6:5").toString()).toBe('2 Samuel 5:5 - 6:5');
|
||||
});
|
||||
|
||||
let booknames = [
|
||||
{ "abbr": "gen", "actual": "Genesis" },
|
||||
{ "abbr": "ge", "actual": "Genesis" },
|
||||
{ "abbr": "genesis", "actual": "Genesis" },
|
||||
{ "abbr": "gn", "actual": "Genesis" },
|
||||
{ "abbr": "exodus", "actual": "Exodus" },
|
||||
{ "abbr": "ex", "actual": "Exodus" },
|
||||
{ "abbr": "exo", "actual": "Exodus" },
|
||||
{ "abbr": "exod", "actual": "Exodus" },
|
||||
{ "abbr": "exd", "actual": "Exodus" },
|
||||
{ "abbr": "leviticus", "actual": "Leviticus" },
|
||||
{ "abbr": "lev", "actual": "Leviticus" },
|
||||
{ "abbr": "le", "actual": "Leviticus" },
|
||||
{ "abbr": "levi", "actual": "Leviticus" },
|
||||
{ "abbr": "lv", "actual": "Leviticus" },
|
||||
{ "abbr": "numbers", "actual": "Numbers" },
|
||||
{ "abbr": "num", "actual": "Numbers" },
|
||||
{ "abbr": "nu", "actual": "Numbers" },
|
||||
{ "abbr": "numb", "actual": "Numbers" },
|
||||
{ "abbr": "number", "actual": "Numbers" },
|
||||
{ "abbr": "deuteronomy", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deut", "actual": "Deuteronomy" },
|
||||
{ "abbr": "de", "actual": "Deuteronomy" },
|
||||
{ "abbr": "dt", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deu", "actual": "Deuteronomy" },
|
||||
{ "abbr": "joshua", "actual": "Joshua" },
|
||||
{ "abbr": "josh", "actual": "Joshua" },
|
||||
{ "abbr": "jos", "actual": "Joshua" },
|
||||
{ "abbr": "judges", "actual": "Judges" },
|
||||
{ "abbr": "jud", "actual": "Judges" },
|
||||
{ "abbr": "jdg", "actual": "Judges" },
|
||||
{ "abbr": "judg", "actual": "Judges" },
|
||||
{ "abbr": "ruth", "actual": "Ruth" },
|
||||
{ "abbr": "ru", "actual": "Ruth" },
|
||||
{ "abbr": "1 samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "i samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "first samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "2 samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "second samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "1 kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1 king", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1 k", "actual": "1 Kings" },
|
||||
{ "abbr": "1 ki", "actual": "1 Kings" },
|
||||
{ "abbr": "i kings", "actual": "1 Kings" },
|
||||
{ "abbr": "i king", "actual": "1 Kings" },
|
||||
{ "abbr": "i kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "i kn", "actual": "1 Kings" },
|
||||
{ "abbr": "i k", "actual": "1 Kings" },
|
||||
{ "abbr": "i ki", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1st king", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1st k", "actual": "1 Kings" },
|
||||
{ "abbr": "1st ki", "actual": "1 Kings" },
|
||||
{ "abbr": "first kings", "actual": "1 Kings" },
|
||||
{ "abbr": "first king", "actual": "1 Kings" },
|
||||
{ "abbr": "first kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "first kn", "actual": "1 Kings" },
|
||||
{ "abbr": "first k", "actual": "1 Kings" },
|
||||
{ "abbr": "first ki", "actual": "1 Kings" },
|
||||
{ "abbr": "2 Kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2 king", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2 k", "actual": "2 Kings" },
|
||||
{ "abbr": "2 ki", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kings", "actual": "2 Kings" },
|
||||
{ "abbr": "ii king", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kn", "actual": "2 Kings" },
|
||||
{ "abbr": "ii k", "actual": "2 Kings" },
|
||||
{ "abbr": "ii ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd king", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd k", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd ki", "actual": "2 Kings" },
|
||||
{ "abbr": "second kings", "actual": "2 Kings" },
|
||||
{ "abbr": "second king", "actual": "2 Kings" },
|
||||
{ "abbr": "second kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "second kn", "actual": "2 Kings" },
|
||||
{ "abbr": "second k", "actual": "2 Kings" },
|
||||
{ "abbr": "second ki", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kings", "actual": "2 Kings" },
|
||||
{ "abbr": "sec king", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kn", "actual": "2 Kings" },
|
||||
{ "abbr": "sec k", "actual": "2 Kings" },
|
||||
{ "abbr": "sec ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2 Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "1 Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "ezra", "actual": "Ezra" },
|
||||
{ "abbr": "ezr", "actual": "Ezra" },
|
||||
{ "abbr": "nehemiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "neh", "actual": "Nehemiah" },
|
||||
{ "abbr": "ne", "actual": "Nehemiah" },
|
||||
{ "abbr": "nehamiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "esther", "actual": "Esther" },
|
||||
{ "abbr": "est", "actual": "Esther" },
|
||||
{ "abbr": "es", "actual": "Esther" },
|
||||
{ "abbr": "esth", "actual": "Esther" },
|
||||
{ "abbr": "job", "actual": "Job" },
|
||||
{ "abbr": "jo", "actual": "Job" },
|
||||
{ "abbr": "jb", "actual": "Job" },
|
||||
{ "abbr": "psalms", "actual": "Psalm" },
|
||||
{ "abbr": "ps", "actual": "Psalm" },
|
||||
{ "abbr": "psa", "actual": "Psalm" },
|
||||
{ "abbr": "psalm", "actual": "Psalm" },
|
||||
{ "abbr": "psm", "actual": "Psalm" },
|
||||
{ "abbr": "proverbs", "actual": "Proverbs" },
|
||||
{ "abbr": "prov", "actual": "Proverbs" },
|
||||
{ "abbr": "pr", "actual": "Proverbs" },
|
||||
{ "abbr": "pro", "actual": "Proverbs" },
|
||||
{ "abbr": "proverb", "actual": "Proverbs" },
|
||||
{ "abbr": "prv", "actual": "Proverbs" },
|
||||
{ "abbr": "prvbs", "actual": "Proverbs" },
|
||||
{ "abbr": "ecclesiastes", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecc", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccles", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ec", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecclesiaste", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "song of solomon", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song of songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "sos", "actual": "Song of Solomon" },
|
||||
{ "abbr": "ss", "actual": "Song of Solomon" },
|
||||
{ "abbr": "son", "actual": "Song of Solomon" },
|
||||
{ "abbr": "so", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song", "actual": "Song of Solomon" },
|
||||
{ "abbr": "songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "isaiah", "actual": "Isaiah" },
|
||||
{ "abbr": "is", "actual": "Isaiah" },
|
||||
{ "abbr": "isah", "actual": "Isaiah" },
|
||||
{ "abbr": "isai", "actual": "Isaiah" },
|
||||
{ "abbr": "ia", "actual": "Isaiah" },
|
||||
{ "abbr": "jerimiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jeremiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jer", "actual": "Jeremiah" },
|
||||
{ "abbr": "je", "actual": "Jeremiah" },
|
||||
{ "abbr": "jere", "actual": "Jeremiah" },
|
||||
{ "abbr": "lamentations", "actual": "Lamentations" },
|
||||
{ "abbr": "lam", "actual": "Lamentations" },
|
||||
{ "abbr": "la", "actual": "Lamentations" },
|
||||
{ "abbr": "lamentation", "actual": "Lamentations" },
|
||||
];
|
||||
|
||||
for (let bk of booknames) {
|
||||
it('Should parse the references: ' + bk.abbr, () => {
|
||||
let book = Reference.parseBook(bk.abbr);
|
||||
expect(book.bookname).toBe(bk.actual);
|
||||
for (let i = 1; i <= book.lastchapter; i++)
|
||||
expect(new Reference(bk.abbr + ' ' + i).toString()).toBe(bk.actual + ' ' + i + ":1 - *");
|
||||
|
||||
for (let i = 1; i < book.lastchapter; i++)
|
||||
expect(new Reference(bk.abbr + ' ' + i+'-'+(i+1)).toString()).toBe(bk.actual + ' ' + i + ":1 - "+(i+1)+":*");
|
||||
|
||||
expect(new Reference(bk.abbr + ' 1:4-2:5').toString()).toBe(bk.actual + ' 1:4 - 2:5');
|
||||
expect(new Reference(bk.abbr + ' 1:1 - 5').toString()).toBe(bk.actual + ' 1:1 - 5');
|
||||
expect(new Reference(bk.abbr + ' 1:4 - 5').toString()).toBe(bk.actual + ' 1:4 - 5');
|
||||
});
|
||||
}
|
||||
let refs = [
|
||||
{ "src": "2 sam 3:4-6:8", "actual": "2 Samuel 3:4 - 6:8" },
|
||||
//{ "src": "gen 50 - ex 2", "actual": "Genesis 50:1 - Exodus 2:*" },
|
||||
];
|
||||
|
||||
for (let ref of refs) {
|
||||
it('Should parse the reference: ' + ref.src, () => {
|
||||
expect(new Reference(ref.src).toString()).toBe(ref.actual);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
import { Reference } from './Reference';
|
||||
|
||||
describe('Reference', () => {
|
||||
|
||||
it('Should parse the reference: Gen 1:1', () => {
|
||||
let ref = new Reference("Gen 1:1").toString();
|
||||
expect(ref).toBe('Genesis 1:1');
|
||||
});
|
||||
|
||||
it('Should parse the reference: Gen 1:1-11', () => {
|
||||
let ref = new Reference("Gen 1:1-11").toString();
|
||||
expect(ref).toBe('Genesis 1:1 - 11');
|
||||
});
|
||||
|
||||
it('Should parse the reference: Gen 1-2', () => {
|
||||
let ref = new Reference("Gen 1-2").toString();
|
||||
expect(ref).toBe('Genesis 1:1 - 2:*');
|
||||
});
|
||||
|
||||
it('Should parse the reference: John 3:16', () => {
|
||||
let ref = new Reference("John 3:16").toString();
|
||||
expect(ref).toBe('John 3:16');
|
||||
});
|
||||
|
||||
it('Should parse the reference: John 3-6', () => {
|
||||
let ref = new Reference("Jn 3-6").toString();
|
||||
expect(ref).toBe('John 3:1 - 6:*');
|
||||
});
|
||||
|
||||
it('Should parse the reference: 1 Corinthians 3:5-6:5', () => {
|
||||
let ref = new Reference("1 Corinthians 3:5-6:5").toString();
|
||||
expect(ref).toBe('1 Corinthians 3:5 - 6:5');
|
||||
});
|
||||
|
||||
it('Should parse the reference: 2 Samuel 5:5-6:5', () => {
|
||||
expect(new Reference("II sam 5:5-6:5").toString()).toBe('2 Samuel 5:5 - 6:5');
|
||||
});
|
||||
|
||||
let booknames = [
|
||||
{ "abbr": "gen", "actual": "Genesis" },
|
||||
{ "abbr": "ge", "actual": "Genesis" },
|
||||
{ "abbr": "genesis", "actual": "Genesis" },
|
||||
{ "abbr": "gn", "actual": "Genesis" },
|
||||
{ "abbr": "exodus", "actual": "Exodus" },
|
||||
{ "abbr": "ex", "actual": "Exodus" },
|
||||
{ "abbr": "exo", "actual": "Exodus" },
|
||||
{ "abbr": "exod", "actual": "Exodus" },
|
||||
{ "abbr": "exd", "actual": "Exodus" },
|
||||
{ "abbr": "leviticus", "actual": "Leviticus" },
|
||||
{ "abbr": "lev", "actual": "Leviticus" },
|
||||
{ "abbr": "le", "actual": "Leviticus" },
|
||||
{ "abbr": "levi", "actual": "Leviticus" },
|
||||
{ "abbr": "lv", "actual": "Leviticus" },
|
||||
{ "abbr": "numbers", "actual": "Numbers" },
|
||||
{ "abbr": "num", "actual": "Numbers" },
|
||||
{ "abbr": "nu", "actual": "Numbers" },
|
||||
{ "abbr": "numb", "actual": "Numbers" },
|
||||
{ "abbr": "number", "actual": "Numbers" },
|
||||
{ "abbr": "deuteronomy", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deut", "actual": "Deuteronomy" },
|
||||
{ "abbr": "de", "actual": "Deuteronomy" },
|
||||
{ "abbr": "dt", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deu", "actual": "Deuteronomy" },
|
||||
{ "abbr": "joshua", "actual": "Joshua" },
|
||||
{ "abbr": "josh", "actual": "Joshua" },
|
||||
{ "abbr": "jos", "actual": "Joshua" },
|
||||
{ "abbr": "judges", "actual": "Judges" },
|
||||
{ "abbr": "jud", "actual": "Judges" },
|
||||
{ "abbr": "jdg", "actual": "Judges" },
|
||||
{ "abbr": "judg", "actual": "Judges" },
|
||||
{ "abbr": "ruth", "actual": "Ruth" },
|
||||
{ "abbr": "ru", "actual": "Ruth" },
|
||||
{ "abbr": "1 samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "i samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "first samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "2 samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "second samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "1 kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1 king", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1 k", "actual": "1 Kings" },
|
||||
{ "abbr": "1 ki", "actual": "1 Kings" },
|
||||
{ "abbr": "i kings", "actual": "1 Kings" },
|
||||
{ "abbr": "i king", "actual": "1 Kings" },
|
||||
{ "abbr": "i kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "i kn", "actual": "1 Kings" },
|
||||
{ "abbr": "i k", "actual": "1 Kings" },
|
||||
{ "abbr": "i ki", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1st king", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1st k", "actual": "1 Kings" },
|
||||
{ "abbr": "1st ki", "actual": "1 Kings" },
|
||||
{ "abbr": "first kings", "actual": "1 Kings" },
|
||||
{ "abbr": "first king", "actual": "1 Kings" },
|
||||
{ "abbr": "first kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "first kn", "actual": "1 Kings" },
|
||||
{ "abbr": "first k", "actual": "1 Kings" },
|
||||
{ "abbr": "first ki", "actual": "1 Kings" },
|
||||
{ "abbr": "2 Kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2 king", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2 k", "actual": "2 Kings" },
|
||||
{ "abbr": "2 ki", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kings", "actual": "2 Kings" },
|
||||
{ "abbr": "ii king", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kn", "actual": "2 Kings" },
|
||||
{ "abbr": "ii k", "actual": "2 Kings" },
|
||||
{ "abbr": "ii ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd king", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd k", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd ki", "actual": "2 Kings" },
|
||||
{ "abbr": "second kings", "actual": "2 Kings" },
|
||||
{ "abbr": "second king", "actual": "2 Kings" },
|
||||
{ "abbr": "second kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "second kn", "actual": "2 Kings" },
|
||||
{ "abbr": "second k", "actual": "2 Kings" },
|
||||
{ "abbr": "second ki", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kings", "actual": "2 Kings" },
|
||||
{ "abbr": "sec king", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kn", "actual": "2 Kings" },
|
||||
{ "abbr": "sec k", "actual": "2 Kings" },
|
||||
{ "abbr": "sec ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2 Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "1 Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "ezra", "actual": "Ezra" },
|
||||
{ "abbr": "ezr", "actual": "Ezra" },
|
||||
{ "abbr": "nehemiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "neh", "actual": "Nehemiah" },
|
||||
{ "abbr": "ne", "actual": "Nehemiah" },
|
||||
{ "abbr": "nehamiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "esther", "actual": "Esther" },
|
||||
{ "abbr": "est", "actual": "Esther" },
|
||||
{ "abbr": "es", "actual": "Esther" },
|
||||
{ "abbr": "esth", "actual": "Esther" },
|
||||
{ "abbr": "job", "actual": "Job" },
|
||||
{ "abbr": "jo", "actual": "Job" },
|
||||
{ "abbr": "jb", "actual": "Job" },
|
||||
{ "abbr": "psalms", "actual": "Psalm" },
|
||||
{ "abbr": "ps", "actual": "Psalm" },
|
||||
{ "abbr": "psa", "actual": "Psalm" },
|
||||
{ "abbr": "psalm", "actual": "Psalm" },
|
||||
{ "abbr": "psm", "actual": "Psalm" },
|
||||
{ "abbr": "proverbs", "actual": "Proverbs" },
|
||||
{ "abbr": "prov", "actual": "Proverbs" },
|
||||
{ "abbr": "pr", "actual": "Proverbs" },
|
||||
{ "abbr": "pro", "actual": "Proverbs" },
|
||||
{ "abbr": "proverb", "actual": "Proverbs" },
|
||||
{ "abbr": "prv", "actual": "Proverbs" },
|
||||
{ "abbr": "prvbs", "actual": "Proverbs" },
|
||||
{ "abbr": "ecclesiastes", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecc", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccles", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ec", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecclesiaste", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "song of solomon", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song of songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "sos", "actual": "Song of Solomon" },
|
||||
{ "abbr": "ss", "actual": "Song of Solomon" },
|
||||
{ "abbr": "son", "actual": "Song of Solomon" },
|
||||
{ "abbr": "so", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song", "actual": "Song of Solomon" },
|
||||
{ "abbr": "songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "isaiah", "actual": "Isaiah" },
|
||||
{ "abbr": "is", "actual": "Isaiah" },
|
||||
{ "abbr": "isah", "actual": "Isaiah" },
|
||||
{ "abbr": "isai", "actual": "Isaiah" },
|
||||
{ "abbr": "ia", "actual": "Isaiah" },
|
||||
{ "abbr": "jerimiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jeremiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jer", "actual": "Jeremiah" },
|
||||
{ "abbr": "je", "actual": "Jeremiah" },
|
||||
{ "abbr": "jere", "actual": "Jeremiah" },
|
||||
{ "abbr": "lamentations", "actual": "Lamentations" },
|
||||
{ "abbr": "lam", "actual": "Lamentations" },
|
||||
{ "abbr": "la", "actual": "Lamentations" },
|
||||
{ "abbr": "lamentation", "actual": "Lamentations" },
|
||||
];
|
||||
|
||||
for (let bk of booknames) {
|
||||
it('Should parse the references: ' + bk.abbr, () => {
|
||||
let book = Reference.parseBook(bk.abbr);
|
||||
expect(book.bookname).toBe(bk.actual);
|
||||
for (let i = 1; i <= book.lastchapter; i++)
|
||||
expect(new Reference(bk.abbr + ' ' + i).toString()).toBe(bk.actual + ' ' + i + ":1 - *");
|
||||
|
||||
for (let i = 1; i < book.lastchapter; i++) {
|
||||
expect(new Reference(bk.abbr + ' ' + i + '-' + (i + 1)).toString()).toBe(bk.actual + ' ' + i + ":1 - " + (i + 1) + ":*");
|
||||
expect(new Reference(bk.abbr + ' ' + i + ':3-' + (i + 1)+":6").toString()).toBe(bk.actual + ' ' + i + ":3 - " + (i + 1) + ":6");
|
||||
}
|
||||
|
||||
expect(new Reference(bk.abbr + ' 1:4-2:5').toString()).toBe(bk.actual + ' 1:4 - 2:5');
|
||||
expect(new Reference(bk.abbr + ' 1:1 - 5').toString()).toBe(bk.actual + ' 1:1 - 5');
|
||||
expect(new Reference(bk.abbr + ' 1:4 - 5').toString()).toBe(bk.actual + ' 1:4 - 5');
|
||||
});
|
||||
}
|
||||
let refs = [
|
||||
{ "src": "2 sam 3:4-6:8", "actual": "2 Samuel 3:4 - 6:8" },
|
||||
//{ "src": "gen 50 - ex 2", "actual": "Genesis 50:1 - Exodus 2:*" },
|
||||
];
|
||||
|
||||
for (let ref of refs) {
|
||||
it('Should parse the reference: ' + ref.src, () => {
|
||||
expect(new Reference(ref.src).toString()).toBe(ref.actual);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -2,12 +2,12 @@ import { Component, ViewChild } from '@angular/core';
|
||||
import { Platform, MenuController, Nav } from 'ionic-angular';
|
||||
import { StatusBar, Splashscreen } from 'ionic-native';
|
||||
import {SearchPage} from "../pages/search/search";
|
||||
import {SettingsPage} from "../pages/settings/settings";
|
||||
import {SettingsPage} from "../pages/settings/settings";
|
||||
|
||||
@Component({
|
||||
templateUrl: 'app.html'
|
||||
})
|
||||
export class MyApp
|
||||
export class MyApp
|
||||
{
|
||||
@ViewChild(Nav) nav: Nav;
|
||||
|
||||
@ -17,7 +17,7 @@ export class MyApp
|
||||
constructor(
|
||||
public platform: Platform,
|
||||
public menu: MenuController
|
||||
)
|
||||
)
|
||||
{
|
||||
this.initializeApp();
|
||||
|
||||
@ -28,9 +28,9 @@ export class MyApp
|
||||
];
|
||||
}
|
||||
|
||||
initializeApp()
|
||||
initializeApp()
|
||||
{
|
||||
this.platform.ready().then(() =>
|
||||
this.platform.ready().then(() =>
|
||||
{
|
||||
// Okay, so the platform is ready and our plugins are available.
|
||||
// Here you can do any higher level native things you might need.
|
||||
@ -39,11 +39,11 @@ export class MyApp
|
||||
});
|
||||
}
|
||||
|
||||
openPage(page)
|
||||
openPage(page)
|
||||
{
|
||||
// close the menu when clicking a link from the menu
|
||||
this.menu.close();
|
||||
this.menu.close();
|
||||
// navigate to the new page if it is not the current page
|
||||
this.nav.setRoot(page.component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
import { NgModule, ErrorHandler } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
|
||||
import { Storage } from '@ionic/storage';
|
||||
|
||||
import { MyApp } from './app.component';
|
||||
|
||||
import {SearchPage} from "../pages/search/search";
|
||||
import {SettingsPage} from "../pages/settings/settings";
|
||||
|
||||
import {ComponentLoader} from "../components/component-loader/component-loader.ts";
|
||||
import {Passage} from "../components/passage/passage.ts";
|
||||
import {Strongs} from "../components/strongs/strongs.ts";
|
||||
import {Words} from "../components/words/words.ts";
|
||||
import {Error} from "../components/error/error.ts";
|
||||
import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
MyApp,
|
||||
SearchPage,
|
||||
SettingsPage,
|
||||
ComponentLoader,
|
||||
Passage,
|
||||
Strongs,
|
||||
StrongsModal,
|
||||
Words,
|
||||
Error
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(MyApp),
|
||||
BrowserModule,
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
MyApp,
|
||||
SearchPage,
|
||||
SettingsPage,
|
||||
Passage,
|
||||
Strongs,
|
||||
StrongsModal,
|
||||
Words,
|
||||
Error
|
||||
],
|
||||
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
|
||||
})
|
||||
export class AppModule { }
|
||||
import { NgModule, ErrorHandler } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
|
||||
import { Storage } from '@ionic/storage';
|
||||
|
||||
import { MyApp } from './app.component';
|
||||
|
||||
import {SearchPage} from "../pages/search/search";
|
||||
import {SettingsPage} from "../pages/settings/settings";
|
||||
|
||||
import {ComponentLoader} from "../components/component-loader/component-loader";
|
||||
import {Passage} from "../components/passage/passage";
|
||||
import {Strongs} from "../components/strongs/strongs";
|
||||
import {Words} from "../components/words/words";
|
||||
import {Error} from "../components/error/error";
|
||||
import {StrongsModal} from "../components/strongs-modal/strongs-modal";
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
MyApp,
|
||||
SearchPage,
|
||||
SettingsPage,
|
||||
ComponentLoader,
|
||||
Passage,
|
||||
Strongs,
|
||||
StrongsModal,
|
||||
Words,
|
||||
Error
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(MyApp),
|
||||
BrowserModule,
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
MyApp,
|
||||
SearchPage,
|
||||
SettingsPage,
|
||||
Passage,
|
||||
Strongs,
|
||||
StrongsModal,
|
||||
Words,
|
||||
Error
|
||||
],
|
||||
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
@ -1,69 +1,312 @@
|
||||
import { getTestBed, TestBed, inject } from '@angular/core/testing';
|
||||
import { XHRBackend, BaseRequestOptions, HttpModule, Http, } from '@angular/http';
|
||||
import { MockBackend } from '@angular/http/testing';
|
||||
import { BibleService } from './bible-service';
|
||||
import { Reference } from './Reference';
|
||||
|
||||
describe('Bible Service', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpModule],
|
||||
providers: [
|
||||
BibleService,
|
||||
{
|
||||
provide: Http,
|
||||
useFactory: function (backend, defaultOptions) {
|
||||
return new Http(backend, defaultOptions);
|
||||
},
|
||||
deps: [MockBackend, BaseRequestOptions]
|
||||
},
|
||||
MockBackend,
|
||||
BaseRequestOptions
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get the verse: Gen 1:1', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 1:1").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe(':)');
|
||||
expect(r.ref).toBe('Genesis 1:1');
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.testament).toBe("old");
|
||||
|
||||
expect(r.cs.length).toBe(1);
|
||||
expect(r.cs[0].vss.length).toBe(1);
|
||||
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||
});
|
||||
|
||||
it('Should get the passage: Gen 1:1-9', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 1:1-9").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe(':)');
|
||||
expect(r.ref).toBe('Genesis 1:1 - 9');
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.testament).toBe("old");
|
||||
|
||||
expect(r.cs.length).toBe(1);
|
||||
expect(r.cs[0].vss.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||
});
|
||||
|
||||
it('Should return an error status', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 100:1").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe('Unable to retrieve bible passage Genesis 100:1.');
|
||||
expect(r.ref).toBe("Genesis 100:1");
|
||||
expect(r.status).toBe(-1);
|
||||
expect(r.testament).toBe('');
|
||||
|
||||
});
|
||||
});
|
||||
import { getTestBed, TestBed, inject } from '@angular/core/testing';
|
||||
import { XHRBackend, BaseRequestOptions, HttpModule, Http, } from '@angular/http';
|
||||
import { MockBackend } from '@angular/http/testing';
|
||||
import { BibleService } from './bible-service';
|
||||
import { Reference } from './Reference';
|
||||
|
||||
describe('Bible Service', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpModule],
|
||||
providers: [
|
||||
BibleService,
|
||||
{
|
||||
provide: Http,
|
||||
useFactory: function (backend, defaultOptions) {
|
||||
return new Http(backend, defaultOptions);
|
||||
},
|
||||
deps: [MockBackend, BaseRequestOptions]
|
||||
},
|
||||
MockBackend,
|
||||
BaseRequestOptions
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get the verse: Gen 1:1', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 1:1").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe(':)');
|
||||
expect(r.ref).toBe('Genesis 1:1');
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.testament).toBe("old");
|
||||
|
||||
expect(r.cs.length).toBe(1);
|
||||
expect(r.cs[0].vss.length).toBe(1);
|
||||
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||
});
|
||||
|
||||
it('Should get the passage: Gen 1:1-9', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 1:1-9").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe(':)');
|
||||
expect(r.ref).toBe('Genesis 1:1 - 9');
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.testament).toBe("old");
|
||||
|
||||
expect(r.cs.length).toBe(1);
|
||||
expect(r.cs[0].vss.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||
});
|
||||
|
||||
it('Should return an error status', () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let ref = new Reference("Gen 100:1").Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe('Unable to retrieve bible passage Genesis 100:1.');
|
||||
expect(r.ref).toBe("Genesis 100:1");
|
||||
expect(r.status).toBe(-1);
|
||||
expect(r.testament).toBe('');
|
||||
|
||||
});
|
||||
|
||||
|
||||
let booknames = [
|
||||
{ "abbr": "gen", "actual": "Genesis" },
|
||||
{ "abbr": "ge", "actual": "Genesis" },
|
||||
{ "abbr": "genesis", "actual": "Genesis" },
|
||||
{ "abbr": "gn", "actual": "Genesis" },
|
||||
{ "abbr": "exodus", "actual": "Exodus" },
|
||||
{ "abbr": "ex", "actual": "Exodus" },
|
||||
{ "abbr": "exo", "actual": "Exodus" },
|
||||
{ "abbr": "exod", "actual": "Exodus" },
|
||||
{ "abbr": "exd", "actual": "Exodus" },
|
||||
{ "abbr": "leviticus", "actual": "Leviticus" },
|
||||
{ "abbr": "lev", "actual": "Leviticus" },
|
||||
{ "abbr": "le", "actual": "Leviticus" },
|
||||
{ "abbr": "levi", "actual": "Leviticus" },
|
||||
{ "abbr": "lv", "actual": "Leviticus" },
|
||||
{ "abbr": "numbers", "actual": "Numbers" },
|
||||
{ "abbr": "num", "actual": "Numbers" },
|
||||
{ "abbr": "nu", "actual": "Numbers" },
|
||||
{ "abbr": "numb", "actual": "Numbers" },
|
||||
{ "abbr": "number", "actual": "Numbers" },
|
||||
{ "abbr": "deuteronomy", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deut", "actual": "Deuteronomy" },
|
||||
{ "abbr": "de", "actual": "Deuteronomy" },
|
||||
{ "abbr": "dt", "actual": "Deuteronomy" },
|
||||
{ "abbr": "deu", "actual": "Deuteronomy" },
|
||||
{ "abbr": "joshua", "actual": "Joshua" },
|
||||
{ "abbr": "josh", "actual": "Joshua" },
|
||||
{ "abbr": "jos", "actual": "Joshua" },
|
||||
{ "abbr": "judges", "actual": "Judges" },
|
||||
{ "abbr": "jud", "actual": "Judges" },
|
||||
{ "abbr": "jdg", "actual": "Judges" },
|
||||
{ "abbr": "judg", "actual": "Judges" },
|
||||
{ "abbr": "ruth", "actual": "Ruth" },
|
||||
{ "abbr": "ru", "actual": "Ruth" },
|
||||
{ "abbr": "1 samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1 sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "i samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "i sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "1st sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "first samuel", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sa", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sam", "actual": "1 Samuel" },
|
||||
{ "abbr": "first sml", "actual": "1 Samuel" },
|
||||
{ "abbr": "2 samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2 sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "ii sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "2nd sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "second samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "second sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec samuel", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sa", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sam", "actual": "2 Samuel" },
|
||||
{ "abbr": "sec sml", "actual": "2 Samuel" },
|
||||
{ "abbr": "1 kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1 king", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1 kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1 k", "actual": "1 Kings" },
|
||||
{ "abbr": "1 ki", "actual": "1 Kings" },
|
||||
{ "abbr": "i kings", "actual": "1 Kings" },
|
||||
{ "abbr": "i king", "actual": "1 Kings" },
|
||||
{ "abbr": "i kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "i kn", "actual": "1 Kings" },
|
||||
{ "abbr": "i k", "actual": "1 Kings" },
|
||||
{ "abbr": "i ki", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kings", "actual": "1 Kings" },
|
||||
{ "abbr": "1st king", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "1st kn", "actual": "1 Kings" },
|
||||
{ "abbr": "1st k", "actual": "1 Kings" },
|
||||
{ "abbr": "1st ki", "actual": "1 Kings" },
|
||||
{ "abbr": "first kings", "actual": "1 Kings" },
|
||||
{ "abbr": "first king", "actual": "1 Kings" },
|
||||
{ "abbr": "first kgs", "actual": "1 Kings" },
|
||||
{ "abbr": "first kn", "actual": "1 Kings" },
|
||||
{ "abbr": "first k", "actual": "1 Kings" },
|
||||
{ "abbr": "first ki", "actual": "1 Kings" },
|
||||
{ "abbr": "2 Kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2 king", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2 kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2 k", "actual": "2 Kings" },
|
||||
{ "abbr": "2 ki", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kings", "actual": "2 Kings" },
|
||||
{ "abbr": "ii king", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "ii kn", "actual": "2 Kings" },
|
||||
{ "abbr": "ii k", "actual": "2 Kings" },
|
||||
{ "abbr": "ii ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kings", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd king", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd kn", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd k", "actual": "2 Kings" },
|
||||
{ "abbr": "2nd ki", "actual": "2 Kings" },
|
||||
{ "abbr": "second kings", "actual": "2 Kings" },
|
||||
{ "abbr": "second king", "actual": "2 Kings" },
|
||||
{ "abbr": "second kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "second kn", "actual": "2 Kings" },
|
||||
{ "abbr": "second k", "actual": "2 Kings" },
|
||||
{ "abbr": "second ki", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kings", "actual": "2 Kings" },
|
||||
{ "abbr": "sec king", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kgs", "actual": "2 Kings" },
|
||||
{ "abbr": "sec kn", "actual": "2 Kings" },
|
||||
{ "abbr": "sec k", "actual": "2 Kings" },
|
||||
{ "abbr": "sec ki", "actual": "2 Kings" },
|
||||
{ "abbr": "2 Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2 chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "ii chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "2nd chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "second chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec Chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chronicles", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chron", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec ch", "actual": "2 Chronicles" },
|
||||
{ "abbr": "sec chr", "actual": "2 Chronicles" },
|
||||
{ "abbr": "1 Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1 chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "i chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "1st chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first Chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chronicles", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chron", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first ch", "actual": "1 Chronicles" },
|
||||
{ "abbr": "first chr", "actual": "1 Chronicles" },
|
||||
{ "abbr": "ezra", "actual": "Ezra" },
|
||||
{ "abbr": "ezr", "actual": "Ezra" },
|
||||
{ "abbr": "nehemiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "neh", "actual": "Nehemiah" },
|
||||
{ "abbr": "ne", "actual": "Nehemiah" },
|
||||
{ "abbr": "nehamiah", "actual": "Nehemiah" },
|
||||
{ "abbr": "esther", "actual": "Esther" },
|
||||
{ "abbr": "est", "actual": "Esther" },
|
||||
{ "abbr": "es", "actual": "Esther" },
|
||||
{ "abbr": "esth", "actual": "Esther" },
|
||||
{ "abbr": "job", "actual": "Job" },
|
||||
{ "abbr": "jo", "actual": "Job" },
|
||||
{ "abbr": "jb", "actual": "Job" },
|
||||
{ "abbr": "psalms", "actual": "Psalm" },
|
||||
{ "abbr": "ps", "actual": "Psalm" },
|
||||
{ "abbr": "psa", "actual": "Psalm" },
|
||||
{ "abbr": "psalm", "actual": "Psalm" },
|
||||
{ "abbr": "psm", "actual": "Psalm" },
|
||||
{ "abbr": "proverbs", "actual": "Proverbs" },
|
||||
{ "abbr": "prov", "actual": "Proverbs" },
|
||||
{ "abbr": "pr", "actual": "Proverbs" },
|
||||
{ "abbr": "pro", "actual": "Proverbs" },
|
||||
{ "abbr": "proverb", "actual": "Proverbs" },
|
||||
{ "abbr": "prv", "actual": "Proverbs" },
|
||||
{ "abbr": "prvbs", "actual": "Proverbs" },
|
||||
{ "abbr": "ecclesiastes", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecc", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "eccles", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ec", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecl", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "ecclesiaste", "actual": "Ecclesiastes" },
|
||||
{ "abbr": "song of solomon", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song of songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "sos", "actual": "Song of Solomon" },
|
||||
{ "abbr": "ss", "actual": "Song of Solomon" },
|
||||
{ "abbr": "son", "actual": "Song of Solomon" },
|
||||
{ "abbr": "so", "actual": "Song of Solomon" },
|
||||
{ "abbr": "song", "actual": "Song of Solomon" },
|
||||
{ "abbr": "songs", "actual": "Song of Solomon" },
|
||||
{ "abbr": "isaiah", "actual": "Isaiah" },
|
||||
{ "abbr": "is", "actual": "Isaiah" },
|
||||
{ "abbr": "isah", "actual": "Isaiah" },
|
||||
{ "abbr": "isai", "actual": "Isaiah" },
|
||||
{ "abbr": "ia", "actual": "Isaiah" },
|
||||
{ "abbr": "jerimiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jeremiah", "actual": "Jeremiah" },
|
||||
{ "abbr": "jer", "actual": "Jeremiah" },
|
||||
{ "abbr": "je", "actual": "Jeremiah" },
|
||||
{ "abbr": "jere", "actual": "Jeremiah" },
|
||||
{ "abbr": "lamentations", "actual": "Lamentations" },
|
||||
{ "abbr": "lam", "actual": "Lamentations" },
|
||||
{ "abbr": "la", "actual": "Lamentations" },
|
||||
{ "abbr": "lamentation", "actual": "Lamentations" },
|
||||
];
|
||||
|
||||
for (let bk of booknames) {
|
||||
it('Get Data for: ' + bk.abbr, () => {
|
||||
let svc: BibleService = getTestBed().get(BibleService);
|
||||
let book = Reference.parseBook(bk.abbr);
|
||||
for (let i = 1; i <= book.lastchapter; i++)
|
||||
{
|
||||
let ref = new Reference(bk.abbr + " "+i).Section;
|
||||
var r = svc.getResult(ref);
|
||||
|
||||
expect(r.msg).toBe(':)');
|
||||
expect(r.ref).toBe(book.bookname + " "+i+":1 - *");
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.cs[0].vss.length).toBeGreaterThan(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { EventEmitter, Component, Output } from "@angular/core";
|
||||
import { Platform, NavParams, ViewController } from 'ionic-angular';
|
||||
import { Reference } from '../../Reference.ts';
|
||||
import { Reference } from '../../Reference';
|
||||
|
||||
@Component({
|
||||
selector: "strongs-modal",
|
||||
@ -18,7 +18,7 @@ export class StrongsModal {
|
||||
public viewCtrl: ViewController
|
||||
) {
|
||||
this.item = this.params.get('strongsid') as StrongsResult;
|
||||
this.onPassageClicked.subscribe(item =>
|
||||
this.onPassageClicked.subscribe(item =>
|
||||
this.params.get('onPassageClicked').getItems(item)
|
||||
)
|
||||
}
|
||||
@ -33,4 +33,4 @@ export class StrongsModal {
|
||||
let ref = this.makePassage(p);
|
||||
this.onPassageClicked.emit(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { EventEmitter, Component, Input, Output } from "@angular/core";
|
||||
import { Reference } from '../../Reference.ts';
|
||||
import { Reference } from '../../Reference';
|
||||
|
||||
@Component({
|
||||
selector: "strongs",
|
||||
@ -21,7 +21,7 @@ export class Strongs {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
close()
|
||||
close()
|
||||
{
|
||||
this.onClose.emit(this.cardItem);
|
||||
}
|
||||
@ -32,4 +32,4 @@ export class Strongs {
|
||||
let ref = this.makePassage(p);
|
||||
this.onPassageClicked.emit({ card: this.cardItem, qry: ref });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {EventEmitter, Component, Input, Output} from "@angular/core";
|
||||
import { Reference } from '../../Reference.ts';
|
||||
import { Reference } from '../../Reference';
|
||||
|
||||
@Component({
|
||||
selector: "words",
|
||||
@ -25,13 +25,13 @@ export class Words {
|
||||
this.onClose.emit(this.cardItem);
|
||||
}
|
||||
|
||||
makePassage(p: string)
|
||||
makePassage(p: string)
|
||||
{
|
||||
return Reference.bookName(parseInt(p.split(":")[0])) + ' ' + p.split(":")[1] + ":" + p.split(":")[2];
|
||||
}
|
||||
openPassage(p: string)
|
||||
openPassage(p: string)
|
||||
{
|
||||
let ref = this.makePassage(p);
|
||||
this.onPassageClicked.emit({ card: this.cardItem, qry: ref });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,222 +1,222 @@
|
||||
/// <reference path="../../types.ts" />
|
||||
import {Type, Component} from "@angular/core";
|
||||
import {Reference} from "../../Reference";
|
||||
import {BibleService} from "../../bible-service";
|
||||
import {Loading, LoadingController, ModalController } from "ionic-angular";
|
||||
import {StrongsService} from "../../strongs-service";
|
||||
import {WordService} from "../../word-service";
|
||||
import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts";
|
||||
import {Storage} from '@ionic/storage';
|
||||
import {UserProfile} from '../../UserProfile';
|
||||
|
||||
class Item
|
||||
{
|
||||
id: number;
|
||||
data: any;
|
||||
type: Type<any>;
|
||||
dict: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: "search.html",
|
||||
providers: [BibleService, StrongsService, WordService],
|
||||
})
|
||||
export class SearchPage
|
||||
{
|
||||
searchQuery: string = "";
|
||||
userProfile: UserProfile;
|
||||
last: CardItem;
|
||||
loader: Loading;
|
||||
|
||||
constructor(
|
||||
private strongsService: StrongsService
|
||||
, private bibleService: BibleService
|
||||
, private wordService: WordService
|
||||
, public loadingCtrl: LoadingController
|
||||
, public modalCtrl: ModalController
|
||||
, public local: Storage)
|
||||
{
|
||||
this.userProfile = new UserProfile(UserProfile.createDefaultUser());
|
||||
|
||||
// Check if there is a profile saved in local storage
|
||||
this.local.get('profile').then(profile =>
|
||||
{
|
||||
let t = this.userProfile;
|
||||
|
||||
if (profile !== null)
|
||||
t = JSON.parse(profile);
|
||||
|
||||
this.userProfile.update(t, local);
|
||||
|
||||
this.initializeItems(this.userProfile);
|
||||
}).catch(error =>
|
||||
{
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
initializeItems(u: UserProfile)
|
||||
{
|
||||
this.userProfile = u;
|
||||
}
|
||||
|
||||
presentStrongsModal(strongs: StrongsResult)
|
||||
{
|
||||
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs, onPassageClicked: this });
|
||||
modal.present();
|
||||
}
|
||||
|
||||
setQuery(searchbar)
|
||||
{
|
||||
this.searchQuery = searchbar.target.value;
|
||||
}
|
||||
getQuery(searchbar)
|
||||
{
|
||||
this.getItems(this.searchQuery);
|
||||
}
|
||||
|
||||
removeItem(item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(item);
|
||||
this.userProfile.user.items.splice(idx, 1);
|
||||
|
||||
// save the users settings.
|
||||
this.userProfile.save(this.local);
|
||||
}
|
||||
|
||||
isError(t: string)
|
||||
{
|
||||
return t === "Error";
|
||||
}
|
||||
isPassage(t: string)
|
||||
{
|
||||
return t === "Passage";
|
||||
}
|
||||
isStrongs(t: string)
|
||||
{
|
||||
return t === "Strongs";
|
||||
}
|
||||
isWords(t: string)
|
||||
{
|
||||
return t === "Words";
|
||||
}
|
||||
|
||||
addItemToList(item)
|
||||
{
|
||||
if (this.userProfile.user.append_to_bottom)
|
||||
{
|
||||
if (this.last != null && this.userProfile.user.insert_next_to_item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(this.last);
|
||||
this.userProfile.user.items.splice(idx + 1, 0, item);
|
||||
}
|
||||
else
|
||||
this.userProfile.user.items.push(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.last != null && this.userProfile.user.insert_next_to_item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(this.last);
|
||||
this.userProfile.user.items.splice(idx, 0, item);
|
||||
}
|
||||
else
|
||||
this.userProfile.user.items.unshift(item);
|
||||
}
|
||||
this.last = null;
|
||||
}
|
||||
|
||||
getItemsNextToCard(data: OpenData)
|
||||
{
|
||||
this.last = data.card;
|
||||
this.getItems(data.qry);
|
||||
}
|
||||
|
||||
|
||||
getItems(search)
|
||||
{
|
||||
this.loader = this.loadingCtrl.create({
|
||||
content: "Looking up query..."
|
||||
});
|
||||
this.loader.present().then(
|
||||
() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
let qs = search.split(";");
|
||||
for (let x in qs)
|
||||
{
|
||||
if (qs.hasOwnProperty(x))
|
||||
{
|
||||
let q = qs[x].trim();
|
||||
if (q !== "")
|
||||
{
|
||||
// its a search term.
|
||||
if (q.search(/[0-9]/i) === -1)
|
||||
{
|
||||
let result = this.wordService.getResult(q);
|
||||
if (result.status == 0)
|
||||
this.addItemToList({ data: result, type: "Words", dict: "na" });
|
||||
else
|
||||
this.addItemToList({ data: result.msg, type: "Error", dict: "na" });
|
||||
}
|
||||
else if (q.search(/(H|G)[0-9]/i) !== -1)
|
||||
{
|
||||
// its a strongs lookup
|
||||
let dict = q.substring(0, 1);
|
||||
|
||||
if (dict.search(/h/i) !== -1)
|
||||
{
|
||||
dict = "heb";
|
||||
} else
|
||||
{
|
||||
dict = "grk";
|
||||
}
|
||||
q = q.substring(1, q.length);
|
||||
let result = this.strongsService.getResult(parseInt(q), dict);
|
||||
if (result.status == -1)
|
||||
this.addItemToList({ data: result.msg, type: "Error", dict: "na" });
|
||||
else
|
||||
{
|
||||
if (this.userProfile.user.strongs_modal)
|
||||
this.presentStrongsModal(result);
|
||||
else
|
||||
this.addItemToList({ data: result, type: "Strongs", dict: "na" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// its a verse reference.
|
||||
if (q.trim() !== "")
|
||||
{
|
||||
let myref = new Reference(q.trim());
|
||||
let r = this.bibleService.getResult(myref.Section);
|
||||
r.ref = myref.toString();
|
||||
if (r.status == 0)
|
||||
this.addItemToList({ data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" });
|
||||
else
|
||||
this.addItemToList({ data: r.msg, type: "Error", dict: "na" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.userProfile.user.clear_search_after_query)
|
||||
$(".searchbar-input").val("");
|
||||
|
||||
this.userProfile.save(this.local);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
this.addItemToList({ data: error, type: "Error", dict: "na" });
|
||||
console.log(error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.loader.dismiss();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
/// <reference path="../../types.ts" />
|
||||
import {Type, Component} from "@angular/core";
|
||||
import {Reference} from "../../Reference";
|
||||
import {BibleService} from "../../bible-service";
|
||||
import {Loading, LoadingController, ModalController } from "ionic-angular";
|
||||
import {StrongsService} from "../../strongs-service";
|
||||
import {WordService} from "../../word-service";
|
||||
import {StrongsModal} from "../../components/strongs-modal/strongs-modal";
|
||||
import {Storage} from '@ionic/storage';
|
||||
import {UserProfile} from '../../UserProfile';
|
||||
|
||||
class Item
|
||||
{
|
||||
id: number;
|
||||
data: any;
|
||||
type: Type<any>;
|
||||
dict: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: "search.html",
|
||||
providers: [BibleService, StrongsService, WordService],
|
||||
})
|
||||
export class SearchPage
|
||||
{
|
||||
searchQuery: string = "";
|
||||
userProfile: UserProfile;
|
||||
last: CardItem;
|
||||
loader: Loading;
|
||||
|
||||
constructor(
|
||||
private strongsService: StrongsService
|
||||
, private bibleService: BibleService
|
||||
, private wordService: WordService
|
||||
, public loadingCtrl: LoadingController
|
||||
, public modalCtrl: ModalController
|
||||
, public local: Storage)
|
||||
{
|
||||
this.userProfile = new UserProfile(UserProfile.createDefaultUser());
|
||||
|
||||
// Check if there is a profile saved in local storage
|
||||
this.local.get('profile').then(profile =>
|
||||
{
|
||||
let t = this.userProfile;
|
||||
|
||||
if (profile !== null)
|
||||
t = JSON.parse(profile);
|
||||
|
||||
this.userProfile.update(t, local);
|
||||
|
||||
this.initializeItems(this.userProfile);
|
||||
}).catch(error =>
|
||||
{
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
initializeItems(u: UserProfile)
|
||||
{
|
||||
this.userProfile = u;
|
||||
}
|
||||
|
||||
presentStrongsModal(strongs: StrongsResult)
|
||||
{
|
||||
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs, onPassageClicked: this });
|
||||
modal.present();
|
||||
}
|
||||
|
||||
setQuery(searchbar)
|
||||
{
|
||||
this.searchQuery = searchbar.target.value;
|
||||
}
|
||||
getQuery(searchbar)
|
||||
{
|
||||
this.getItems(this.searchQuery);
|
||||
}
|
||||
|
||||
removeItem(item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(item);
|
||||
this.userProfile.user.items.splice(idx, 1);
|
||||
|
||||
// save the users settings.
|
||||
this.userProfile.save(this.local);
|
||||
}
|
||||
|
||||
isError(t: string)
|
||||
{
|
||||
return t === "Error";
|
||||
}
|
||||
isPassage(t: string)
|
||||
{
|
||||
return t === "Passage";
|
||||
}
|
||||
isStrongs(t: string)
|
||||
{
|
||||
return t === "Strongs";
|
||||
}
|
||||
isWords(t: string)
|
||||
{
|
||||
return t === "Words";
|
||||
}
|
||||
|
||||
addItemToList(item)
|
||||
{
|
||||
if (this.userProfile.user.append_to_bottom)
|
||||
{
|
||||
if (this.last != null && this.userProfile.user.insert_next_to_item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(this.last);
|
||||
this.userProfile.user.items.splice(idx + 1, 0, item);
|
||||
}
|
||||
else
|
||||
this.userProfile.user.items.push(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.last != null && this.userProfile.user.insert_next_to_item)
|
||||
{
|
||||
let idx = this.userProfile.user.items.indexOf(this.last);
|
||||
this.userProfile.user.items.splice(idx, 0, item);
|
||||
}
|
||||
else
|
||||
this.userProfile.user.items.unshift(item);
|
||||
}
|
||||
this.last = null;
|
||||
}
|
||||
|
||||
getItemsNextToCard(data: OpenData)
|
||||
{
|
||||
this.last = data.card;
|
||||
this.getItems(data.qry);
|
||||
}
|
||||
|
||||
|
||||
getItems(search)
|
||||
{
|
||||
this.loader = this.loadingCtrl.create({
|
||||
content: "Looking up query..."
|
||||
});
|
||||
this.loader.present().then(
|
||||
() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
let qs = search.split(";");
|
||||
for (let x in qs)
|
||||
{
|
||||
if (qs.hasOwnProperty(x))
|
||||
{
|
||||
let q = qs[x].trim();
|
||||
if (q !== "")
|
||||
{
|
||||
// its a search term.
|
||||
if (q.search(/[0-9]/i) === -1)
|
||||
{
|
||||
let result = this.wordService.getResult(q);
|
||||
if (result.status == 0)
|
||||
this.addItemToList({ data: result, type: "Words", dict: "na" });
|
||||
else
|
||||
this.addItemToList({ data: result.msg, type: "Error", dict: "na" });
|
||||
}
|
||||
else if (q.search(/(H|G)[0-9]/i) !== -1)
|
||||
{
|
||||
// its a strongs lookup
|
||||
let dict = q.substring(0, 1);
|
||||
|
||||
if (dict.search(/h/i) !== -1)
|
||||
{
|
||||
dict = "heb";
|
||||
} else
|
||||
{
|
||||
dict = "grk";
|
||||
}
|
||||
q = q.substring(1, q.length);
|
||||
let result = this.strongsService.getResult(parseInt(q), dict);
|
||||
if (result.status == -1)
|
||||
this.addItemToList({ data: result.msg, type: "Error", dict: "na" });
|
||||
else
|
||||
{
|
||||
if (this.userProfile.user.strongs_modal)
|
||||
this.presentStrongsModal(result);
|
||||
else
|
||||
this.addItemToList({ data: result, type: "Strongs", dict: "na" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// its a verse reference.
|
||||
if (q.trim() !== "")
|
||||
{
|
||||
let myref = new Reference(q.trim());
|
||||
let r = this.bibleService.getResult(myref.Section);
|
||||
r.ref = myref.toString();
|
||||
if (r.status == 0)
|
||||
this.addItemToList({ data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" });
|
||||
else
|
||||
this.addItemToList({ data: r.msg, type: "Error", dict: "na" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.userProfile.user.clear_search_after_query)
|
||||
$(".searchbar-input").val("");
|
||||
|
||||
this.userProfile.save(this.local);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
this.addItemToList({ data: error, type: "Error", dict: "na" });
|
||||
console.log(error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.loader.dismiss();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user