From cb3903f86e6daaee67df36f8eb8aea5e8d383577 Mon Sep 17 00:00:00 2001 From: Jason Wall Date: Sat, 1 Aug 2020 23:01:29 -0400 Subject: [PATCH] numer of minor bug fixes, cleanup --- app/db/src/app/common/bible-reference.ts | 393 ++++++++++++++++-- app/db/src/app/common/card.component.ts | 8 +- .../components/strongs/strongs.component.html | 2 +- .../components/words/words.component.html | 2 +- .../components/words/words.component.ts | 13 +- app/db/src/app/services/app.service.ts | 22 +- 6 files changed, 387 insertions(+), 53 deletions(-) diff --git a/app/db/src/app/common/bible-reference.ts b/app/db/src/app/common/bible-reference.ts index d67fce13..74406c6a 100644 --- a/app/db/src/app/common/bible-reference.ts +++ b/app/db/src/app/common/bible-reference.ts @@ -308,7 +308,33 @@ export class BibleReference { short_name: 'Josh', long_name: 'Book of Joshua', last_chapter: 24, - chapters: [0, 18, 24, 17, 24, 15, 27, 26, 35, 27, 43, 23, 24, 33, 15, 63, 10, 18, 28, 51, 9, 45, 34, 16, 33], + chapters: [ + 0, + 18, + 24, + 17, + 24, + 15, + 27, + 26, + 35, + 27, + 43, + 23, + 24, + 33, + 15, + 63, + 10, + 18, + 28, + 51, + 9, + 45, + 34, + 16, + 33, + ], }, { book_number: 7, @@ -316,7 +342,30 @@ export class BibleReference { short_name: 'Jud', long_name: 'Book of Judges', last_chapter: 21, - chapters: [0, 36, 23, 31, 24, 31, 40, 25, 35, 57, 18, 40, 15, 25, 20, 20, 31, 13, 31, 30, 48, 25], + chapters: [ + 0, + 36, + 23, + 31, + 24, + 31, + 40, + 25, + 35, + 57, + 18, + 40, + 15, + 25, + 20, + 20, + 31, + 13, + 31, + 30, + 48, + 25, + ], }, { book_number: 8, @@ -373,7 +422,33 @@ export class BibleReference { short_name: '2 Sam', long_name: 'Second Book of Samuel', last_chapter: 24, - chapters: [0, 27, 32, 39, 12, 25, 23, 29, 18, 13, 19, 27, 31, 39, 33, 37, 23, 29, 33, 43, 26, 22, 51, 39, 25], + chapters: [ + 0, + 27, + 32, + 39, + 12, + 25, + 23, + 29, + 18, + 13, + 19, + 27, + 31, + 39, + 33, + 37, + 23, + 29, + 33, + 43, + 26, + 22, + 51, + 39, + 25, + ], }, { book_number: 11, @@ -381,7 +456,31 @@ export class BibleReference { short_name: '1 Kng', long_name: 'First Book of Kings', last_chapter: 22, - chapters: [0, 53, 46, 28, 34, 18, 38, 51, 66, 28, 29, 43, 33, 34, 31, 34, 34, 24, 46, 21, 43, 29, 53], + chapters: [ + 0, + 53, + 46, + 28, + 34, + 18, + 38, + 51, + 66, + 28, + 29, + 43, + 33, + 34, + 31, + 34, + 34, + 24, + 46, + 21, + 43, + 29, + 53, + ], }, { book_number: 12, @@ -389,7 +488,34 @@ export class BibleReference { short_name: '2 Kng', long_name: 'Second Book of Kings', last_chapter: 25, - chapters: [0, 18, 25, 27, 44, 27, 33, 20, 29, 37, 36, 21, 21, 25, 29, 38, 20, 41, 37, 37, 21, 26, 20, 37, 20, 30], + chapters: [ + 0, + 18, + 25, + 27, + 44, + 27, + 33, + 20, + 29, + 37, + 36, + 21, + 21, + 25, + 29, + 38, + 20, + 41, + 37, + 37, + 21, + 26, + 20, + 37, + 20, + 30, + ], }, { book_number: 13, @@ -1121,7 +1247,25 @@ export class BibleReference { short_name: 'Mark', long_name: 'Gospel of Mark', last_chapter: 16, - chapters: [0, 45, 28, 35, 41, 43, 56, 37, 38, 50, 52, 33, 44, 37, 72, 47, 20], + chapters: [ + 0, + 45, + 28, + 35, + 41, + 43, + 56, + 37, + 38, + 50, + 52, + 33, + 44, + 37, + 72, + 47, + 20, + ], }, { book_number: 42, @@ -1129,7 +1273,33 @@ export class BibleReference { short_name: 'Luke', long_name: 'Gospel of Luke', last_chapter: 24, - chapters: [0, 80, 52, 38, 44, 39, 49, 50, 56, 62, 42, 54, 59, 35, 35, 32, 31, 37, 43, 48, 47, 38, 71, 56, 53], + chapters: [ + 0, + 80, + 52, + 38, + 44, + 39, + 49, + 50, + 56, + 62, + 42, + 54, + 59, + 35, + 35, + 32, + 31, + 37, + 43, + 48, + 47, + 38, + 71, + 56, + 53, + ], }, { book_number: 43, @@ -1137,7 +1307,30 @@ export class BibleReference { short_name: 'John', long_name: 'Gospel of John', last_chapter: 21, - chapters: [0, 51, 25, 36, 54, 47, 71, 53, 59, 41, 42, 57, 50, 38, 31, 27, 33, 26, 40, 42, 31, 25], + chapters: [ + 0, + 51, + 25, + 36, + 54, + 47, + 71, + 53, + 59, + 41, + 42, + 57, + 50, + 38, + 31, + 27, + 33, + 26, + 40, + 42, + 31, + 25, + ], }, { book_number: 44, @@ -1183,7 +1376,25 @@ export class BibleReference { short_name: 'Rom', long_name: 'Epistle to the Romans', last_chapter: 16, - chapters: [0, 32, 29, 31, 25, 21, 23, 25, 39, 33, 21, 36, 21, 14, 23, 33, 27], + chapters: [ + 0, + 32, + 29, + 31, + 25, + 21, + 23, + 25, + 39, + 33, + 21, + 36, + 21, + 14, + 23, + 33, + 27, + ], }, { book_number: 46, @@ -1191,7 +1402,25 @@ export class BibleReference { short_name: '1 Cor', long_name: 'First Epistle to the Corinthians', last_chapter: 16, - chapters: [0, 31, 16, 23, 21, 13, 20, 40, 13, 27, 33, 34, 31, 13, 40, 58, 24], + chapters: [ + 0, + 31, + 16, + 23, + 21, + 13, + 20, + 40, + 13, + 27, + 33, + 34, + 31, + 13, + 40, + 58, + 24, + ], }, { book_number: 47, @@ -1351,9 +1580,34 @@ export class BibleReference { short_name: 'Rev', long_name: 'Book of Revelations', last_chapter: 22, - chapters: [0, 20, 29, 22, 11, 14, 17, 17, 13, 21, 11, 19, 17, 18, 20, 8, 21, 18, 24, 21, 15, 27, 21], + chapters: [ + 0, + 20, + 29, + 22, + 11, + 14, + 17, + 17, + 13, + 21, + 11, + 19, + 17, + 18, + 20, + 8, + 21, + 18, + 24, + 21, + 15, + 27, + 21, + ], }, ]; + private ref: string; Section: Section; errAcc: string; @@ -1386,19 +1640,31 @@ export class BibleReference { if (fbook.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) !== -1) { return this.bookName(9); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(samuel|sa|sam|sml)\b/i) !== -1) { + if ( + fbook.search(/\b(2|ii|2nd|second|sec)\s*(samuel|sa|sam|sml)\b/i) !== -1 + ) { return this.bookName(10); } - if (fbook.search(/\b(1|i|1st|first)\s*(kings|king|kgs|kn|k|ki)\b/i) !== -1) { + if ( + fbook.search(/\b(1|i|1st|first)\s*(kings|king|kgs|kn|k|ki)\b/i) !== -1 + ) { return this.bookName(11); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(kings|king|kgs|kn|k|ki)\b/i) !== -1) { + if ( + fbook.search(/\b(2|ii|2nd|second|sec)\s*(kings|king|kgs|kn|k|ki)\b/i) !== + -1 + ) { return this.bookName(12); } - if (fbook.search(/\b(1|i|1st|first)\s*(chronicles|chron|ch|chr)\b/i) !== -1) { + if ( + fbook.search(/\b(1|i|1st|first)\s*(chronicles|chron|ch|chr)\b/i) !== -1 + ) { return this.bookName(13); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(chronicles|chron|ch|chr)\b/i) !== -1) { + if ( + fbook.search(/\b(2|ii|2nd|second|sec)\s*(chronicles|chron|ch|chr)\b/i) !== + -1 + ) { return this.bookName(14); } if (fbook.search(/\b(ezra|ezr)\b/i) !== -1) { @@ -1419,10 +1685,17 @@ export class BibleReference { if (fbook.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) !== -1) { return this.bookName(20); } - if (fbook.search(/\b(ecclesiastes|eccl|ecc|eccles|ec|ecl|ecclesiaste)\b/i) !== -1) { + if ( + fbook.search(/\b(ecclesiastes|eccl|ecc|eccles|ec|ecl|ecclesiaste)\b/i) !== + -1 + ) { return this.bookName(21); } - if (fbook.search(/\b(song\sof\ssolomon|song\sof\ssongs|sos|ss|son|so|song|songs)\b/i) !== -1) { + if ( + fbook.search( + /\b(song\sof\ssolomon|song\sof\ssongs|sos|ss|son|so|song|songs)\b/i + ) !== -1 + ) { return this.bookName(22); } if (fbook.search(/\b(isaiah|is|isah|isai|ia)\b/i) !== -1) { @@ -1505,13 +1778,25 @@ export class BibleReference { if (fbook.search(/\b(romans|rom|ro|rm|roman)\b/i) !== -1) { return this.bookName(45); } - if (fbook.search(/\b(1|i|1st|first)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) !== -1) { + if ( + fbook.search( + /\b(1|i|1st|first)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i + ) !== -1 + ) { return this.bookName(46); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) !== -1) { + if ( + fbook.search( + /\b(2|ii|2nd|second|sec)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i + ) !== -1 + ) { return this.bookName(47); } - if (fbook.search(/\b(galatians|galatian|galations|gal|ga|gala|galation|galat)\b/i) !== -1) { + if ( + fbook.search( + /\b(galatians|galatian|galations|gal|ga|gala|galation|galat)\b/i + ) !== -1 + ) { return this.bookName(48); } if (fbook.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) !== -1) { @@ -1520,19 +1805,34 @@ export class BibleReference { if (fbook.search(/\b(philippians|phi|phil|ph|philip)\b/i) !== -1) { return this.bookName(50); } - if (fbook.search(/\b(colossians|col|co|colossian|colos|coloss)\b/i) !== -1) { + if ( + fbook.search(/\b(colossians|col|co|colossian|colos|coloss)\b/i) !== -1 + ) { return this.bookName(51); } - if (fbook.search(/\b(1|i|1st|first)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) !== -1) { + if ( + fbook.search( + /\b(1|i|1st|first)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i + ) !== -1 + ) { return this.bookName(52); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) !== -1) { + if ( + fbook.search( + /\b(2|ii|2nd|second|sec)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i + ) !== -1 + ) { return this.bookName(53); } - if (fbook.search(/\b(1|i|1st|first)\s*(timothy|tim|ti|timoth|tm)\b/i) !== -1) { + if ( + fbook.search(/\b(1|i|1st|first)\s*(timothy|tim|ti|timoth|tm)\b/i) !== -1 + ) { return this.bookName(54); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(timothy|tim|timoth|tm)\b/i) !== -1) { + if ( + fbook.search(/\b(2|ii|2nd|second|sec)\s*(timothy|tim|timoth|tm)\b/i) !== + -1 + ) { return this.bookName(55); } if (fbook.search(/\b(titus|tit)\b/i) !== -1) { @@ -1547,10 +1847,15 @@ export class BibleReference { if (fbook.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) !== -1) { return this.bookName(59); } - if (fbook.search(/\b(1|i|1st|first)\s*(peter|pe|pet|pete|pt|p)\b/i) !== -1) { + if ( + fbook.search(/\b(1|i|1st|first)\s*(peter|pe|pet|pete|pt|p)\b/i) !== -1 + ) { return this.bookName(60); } - if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(peter|pe|pet|pete|pt|p)\b/i) !== -1) { + if ( + fbook.search(/\b(2|ii|2nd|second|sec)\s*(peter|pe|pet|pete|pt|p)\b/i) !== + -1 + ) { return this.bookName(61); } if (fbook.search(/\b(jude|ju)\b/i) !== -1) { @@ -1565,7 +1870,11 @@ export class BibleReference { public static toString(section: Section) { // get the starting book, chapter, verse - let ref = section.start.book.name.concat(' ').concat(section.start.chapter).concat(':').concat(section.start.verse); + let ref = section.start.book.name + .concat(' ') + .concat(section.start.chapter) + .concat(':') + .concat(section.start.verse); if ( section.start.chapter === section.end.chapter && @@ -1598,6 +1907,20 @@ export class BibleReference { return this.Books[booknum]; } + public static formatReferenceKey( + book: number | string, + chapter: number | string, + vs: number | string + ) { + return `${book};${chapter};${vs}`; + } + + public static makePassageFromReferenceKey(referenceKey: string) { + const keyArray = referenceKey.split(';'); + const book = BibleReference.bookName(parseInt(keyArray[0], 10)).name; + return new BibleReference(`${book} ${keyArray[1]}:${keyArray[2]}`); + } + private parseReference() { this.parseNumberReference(); if (this.ref.length === 0) { @@ -1728,11 +2051,19 @@ export class BibleReference { }); } - private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean) { + private maybeParseFirstNumOrVerse( + foundSecondBook: boolean, + foundFirstVerse: boolean, + isEnd: boolean + ) { const self = this; return this.maybeDo(() => { if (self.Section.end.book.name === self.Section.start.book.name) { - if (self.ref.search(/:/) !== -1 || foundSecondBook || !foundFirstVerse) { + if ( + self.ref.search(/:/) !== -1 || + foundSecondBook || + !foundFirstVerse + ) { self.parseFirstNum(isEnd); } self.parseSecondNum(true, isEnd); diff --git a/app/db/src/app/common/card.component.ts b/app/db/src/app/common/card.component.ts index 71ecf580..befede1b 100644 --- a/app/db/src/app/common/card.component.ts +++ b/app/db/src/app/common/card.component.ts @@ -58,12 +58,6 @@ export class CardComponent { } makePassage(p: string) { - return new BibleReference( - BibleReference.bookName(parseInt(p.split(':')[0], 10)).name + - ' ' + - p.split(':')[1] + - ':' + - p.split(':')[2] - ); + return BibleReference.makePassageFromReferenceKey(p); } } diff --git a/app/db/src/app/search/components/strongs/strongs.component.html b/app/db/src/app/search/components/strongs/strongs.component.html index c222ad79..e483e129 100644 --- a/app/db/src/app/search/components/strongs/strongs.component.html +++ b/app/db/src/app/search/components/strongs/strongs.component.html @@ -77,7 +77,7 @@ diff --git a/app/db/src/app/search/components/words/words.component.html b/app/db/src/app/search/components/words/words.component.html index f3c6ea57..7a0a4e67 100644 --- a/app/db/src/app/search/components/words/words.component.html +++ b/app/db/src/app/search/components/words/words.component.html @@ -40,7 +40,7 @@ diff --git a/app/db/src/app/search/components/words/words.component.ts b/app/db/src/app/search/components/words/words.component.ts index bbdc62d1..27045ec9 100644 --- a/app/db/src/app/search/components/words/words.component.ts +++ b/app/db/src/app/search/components/words/words.component.ts @@ -1,6 +1,7 @@ import { Component, ElementRef, ViewChild } from '@angular/core'; import { AppService } from '../../../services/app.service'; import { CardComponent } from '../../../common/card.component'; +import { WordLookupResult } from 'src/app/models/app-state'; @Component({ selector: 'app-words', @@ -20,8 +21,16 @@ export class WordsComponent extends CardComponent { } copy() { - const html = this.wordsElement.nativeElement.innerHTML; - const text = this.wordsElement.nativeElement.innerText; + const refs = (this.cardItem.data as WordLookupResult).refs.map((ref) => + this.makePassage(ref) + ); + + const html = refs + .map( + (ref) => `${ref}` + ) + .join(', '); + const text = refs.join(', '); this.copyToClip(text, html); } diff --git a/app/db/src/app/services/app.service.ts b/app/db/src/app/services/app.service.ts index eef025cd..9867e6c7 100644 --- a/app/db/src/app/services/app.service.ts +++ b/app/db/src/app/services/app.service.ts @@ -224,14 +224,6 @@ export class AppService extends createStateService(reducer, initialState) { }); console.log(msg); } - - private formatReferenceKey( - book: number | string, - chapter: number | string, - vs: number | string - ) { - return `${book}:${chapter}:${vs}`; - } //#region Strongs async getStrongs( @@ -575,7 +567,7 @@ export class AppService extends createStateService(reducer, initialState) { } private getRefKey(vs: BibleVerse, section: Section) { - return this.formatReferenceKey( + return BibleReference.formatReferenceKey( section.start.book.book_number, section.start.chapter, vs.v @@ -732,7 +724,15 @@ export class AppService extends createStateService(reducer, initialState) { return; } // find the right word - const refs = r.filter((o) => o.w === query); + const refs = r + .filter((o) => o.w === query) + // you used the wrong delimiter here... *sigh* its ;'s in all the other things. + .map((o) => { + return { + ...o, + r: o.r.map((ref) => ref.replace(':', ';')), + }; + }); if (refs.length > 0) { return refs[0].r; @@ -969,7 +969,7 @@ export class AppService extends createStateService(reducer, initialState) { } private toReferenceString(ref: number) { - return this.formatReferenceKey( + return BibleReference.formatReferenceKey( Math.floor(ref / 100000000), Math.floor((ref % 100000000) / 10000), Math.floor((ref % 100000000) % 10000)