mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 07:19:50 -04:00
fix reference refactor build issues
This commit is contained in:
parent
d30f3736cb
commit
0e2b2273c1
@ -27,7 +27,7 @@ export enum Overlap {
|
||||
|
||||
export class BibleReference {
|
||||
constructor(reference: string) {
|
||||
this.Section = {
|
||||
this.section = {
|
||||
book: null,
|
||||
start: {
|
||||
chapter: 0,
|
||||
@ -41,20 +41,22 @@ export class BibleReference {
|
||||
this.ref = reference.toLowerCase().trim();
|
||||
this.parseReference();
|
||||
|
||||
if (this.Section.end.chapter === 0) {
|
||||
this.Section.end.chapter = this.Section.start.chapter;
|
||||
if (this.section.end.chapter === 0) {
|
||||
this.section.end.chapter = this.section.start.chapter;
|
||||
}
|
||||
if (
|
||||
Number(this.Section.start.verse) > Number(this.Section.end.verse) &&
|
||||
this.Section.start.chapter === this.Section.end.chapter
|
||||
Number(this.section.start.verse) > Number(this.section.end.verse) &&
|
||||
this.section.start.chapter === this.section.end.chapter
|
||||
) {
|
||||
this.Section.end.verse = this.Section.start.verse;
|
||||
this.section.end.verse = this.section.start.verse;
|
||||
}
|
||||
if (this.Section.start.verse === 0) {
|
||||
this.Section.start.verse = 1;
|
||||
if (this.section.start.verse === 0) {
|
||||
this.section.start.verse = 1;
|
||||
}
|
||||
if (this.Section.end.verse === 0) {
|
||||
this.Section.end.verse = this.Section.book.chapters[this.Section.end.chapter];
|
||||
if (this.section.end.verse === 0) {
|
||||
this.section.end.verse = this.section.book.chapters[
|
||||
this.section.end.chapter
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1611,7 +1613,7 @@ export class BibleReference {
|
||||
];
|
||||
|
||||
private ref: string;
|
||||
Section: Section;
|
||||
section: Section;
|
||||
errAcc: string;
|
||||
|
||||
public static parseBook(fbook: string): Book {
|
||||
@ -1917,30 +1919,29 @@ export class BibleReference {
|
||||
return new BibleReference(`${book} ${keyArray[1]}:${keyArray[2]}`);
|
||||
}
|
||||
|
||||
public static overlap(leftRef: BibleReference, rightRef: BibleReference): Overlap {
|
||||
if (leftRef.Section.book !== rightRef.Section.book) {
|
||||
public static overlap(
|
||||
leftRef: BibleReference,
|
||||
rightRef: BibleReference
|
||||
): Overlap {
|
||||
if (leftRef.section.book !== rightRef.section.book) {
|
||||
// either of the above means we are not overlapping
|
||||
console.log("Not same book");
|
||||
return Overlap.None;
|
||||
}
|
||||
|
||||
if (leftRef.Section.end.chapter === rightRef.Section.start.chapter) {
|
||||
console.log("Same chapter");
|
||||
console.log("Left Section", leftRef.Section);
|
||||
console.log("Right Section", rightRef.Section);
|
||||
if ((leftRef.Section.end.verse > rightRef.Section.start.verse)
|
||||
|| (rightRef.Section.end.verse > leftRef.Section.start.verse)) {
|
||||
console.log("Overlap detected");
|
||||
if (leftRef.section.end.chapter === rightRef.section.start.chapter) {
|
||||
if (
|
||||
leftRef.section.end.verse > rightRef.section.start.verse ||
|
||||
rightRef.section.end.verse > leftRef.section.start.verse
|
||||
) {
|
||||
return Overlap.Intersect;
|
||||
}
|
||||
}
|
||||
console.log("Default case");
|
||||
return Overlap.None;
|
||||
}
|
||||
|
||||
public static mergeReference(ref1: BibleReference, ref2: BibleReference) {
|
||||
// eliminate based on book first.
|
||||
if (ref1.Section.book != ref2.Section.book) {
|
||||
if (ref1.section.book !== ref2.section.book) {
|
||||
// either of the above mean we are not overlapping
|
||||
return null;
|
||||
}
|
||||
@ -1974,15 +1975,15 @@ export class BibleReference {
|
||||
const parts = this.ref.split(':');
|
||||
if (this.ref.match(/\d+:\d+:\d+/) !== null) {
|
||||
const fbook = BibleReference.bookName(parseInt(parts[0], 10));
|
||||
this.Section.book = fbook;
|
||||
this.section.book = fbook;
|
||||
|
||||
const fch = parts[1];
|
||||
this.Section.end.chapter = parseInt(fch, 10);
|
||||
this.Section.start.chapter = parseInt(fch, 10);
|
||||
this.section.end.chapter = parseInt(fch, 10);
|
||||
this.section.start.chapter = parseInt(fch, 10);
|
||||
|
||||
const fv = parts[2];
|
||||
this.Section.end.verse = parseInt(fv, 10);
|
||||
this.Section.start.verse = parseInt(fv, 10);
|
||||
this.section.end.verse = parseInt(fv, 10);
|
||||
this.section.start.verse = parseInt(fv, 10);
|
||||
|
||||
this.ref = '';
|
||||
}
|
||||
@ -1996,13 +1997,13 @@ export class BibleReference {
|
||||
fbook = this.ref;
|
||||
}
|
||||
this.ref = this.ref.slice(this.ref.search(/\w\s+\d/i) + 1);
|
||||
this.Section.book = BibleReference.parseBook(fbook);
|
||||
this.section.book = BibleReference.parseBook(fbook);
|
||||
}
|
||||
|
||||
private parseChapter(isEnd: boolean) {
|
||||
let thing = this.Section.start;
|
||||
let thing = this.section.start;
|
||||
if (isEnd) {
|
||||
thing = this.Section.end;
|
||||
thing = this.section.end;
|
||||
}
|
||||
|
||||
this.ref = StringUtils.ltrim(this.ref);
|
||||
@ -2030,9 +2031,9 @@ export class BibleReference {
|
||||
}
|
||||
|
||||
private parseVerse(skipColon?: boolean, isEnd?: boolean) {
|
||||
let thing = this.Section.start;
|
||||
let thing = this.section.start;
|
||||
if (isEnd) {
|
||||
thing = this.Section.end;
|
||||
thing = this.section.end;
|
||||
}
|
||||
|
||||
this.ref = StringUtils.ltrim(this.ref.toLowerCase());
|
||||
@ -2112,7 +2113,7 @@ export class BibleReference {
|
||||
|
||||
public toString() {
|
||||
// get the starting book, chapter, verse
|
||||
return BibleReference.toString(this.Section);
|
||||
return BibleReference.toString(this.section);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,101 +54,91 @@ export class PassageCardComponent extends CardComponent implements OnInit {
|
||||
}
|
||||
|
||||
next() {
|
||||
const lastVerseForEnd = this.ref.Section.end.book.chapters[
|
||||
parseInt(this.ref.Section.end.chapter, 10)
|
||||
].toString();
|
||||
const lastVerseForEnd = this.ref.section.book.chapters[
|
||||
this.ref.section.end.chapter
|
||||
];
|
||||
|
||||
if (
|
||||
this.ref.Section.end.verse !== '*' &&
|
||||
this.ref.Section.end.verse !== lastVerseForEnd
|
||||
this.ref.section.end.verse !== 0 &&
|
||||
this.ref.section.end.verse !== lastVerseForEnd
|
||||
) {
|
||||
this.ref.Section.end.chapter = this.ref.Section.end.chapter;
|
||||
this.ref.section.end.chapter = this.ref.section.end.chapter;
|
||||
} else {
|
||||
this.ref.Section.end.chapter = (
|
||||
parseInt(this.ref.Section.end.chapter, 10) + 1
|
||||
).toString();
|
||||
this.ref.section.end.chapter = this.ref.section.end.chapter + 1;
|
||||
}
|
||||
|
||||
this.ref.Section.start.chapter = this.ref.Section.end.chapter;
|
||||
this.ref.Section.start.verse = '1';
|
||||
this.ref.Section.end.verse = '*';
|
||||
this.ref.section.start.chapter = this.ref.section.end.chapter;
|
||||
this.ref.section.start.verse = 1;
|
||||
this.ref.section.end.verse = this.ref.section.book.chapters[
|
||||
this.ref.section.end.chapter
|
||||
];
|
||||
|
||||
this.appService.updatePassage(this.cardItem, this.ref);
|
||||
}
|
||||
|
||||
prev() {
|
||||
if (this.ref.Section.start.verse !== '1') {
|
||||
this.ref.Section.start.chapter = this.ref.Section.start.chapter;
|
||||
if (this.ref.section.start.verse !== 1) {
|
||||
this.ref.section.start.chapter = this.ref.section.start.chapter;
|
||||
} else {
|
||||
this.ref.Section.start.chapter = (
|
||||
parseInt(this.ref.Section.start.chapter, 10) - 1
|
||||
).toString();
|
||||
this.ref.section.start.chapter = this.ref.section.start.chapter - 1;
|
||||
}
|
||||
|
||||
this.ref.Section.end.chapter = this.ref.Section.start.chapter;
|
||||
this.ref.Section.start.verse = '1';
|
||||
this.ref.Section.end.verse = '*';
|
||||
this.ref.section.end.chapter = this.ref.section.start.chapter;
|
||||
this.ref.section.start.verse = 1;
|
||||
this.ref.section.end.verse = this.ref.section.book.chapters[
|
||||
this.ref.section.end.chapter
|
||||
];
|
||||
|
||||
this.appService.updatePassage(this.cardItem, this.ref);
|
||||
}
|
||||
|
||||
expand() {
|
||||
const lastVerseForEnd = this.ref.Section.end.book.chapters[
|
||||
parseInt(this.ref.Section.end.chapter, 10)
|
||||
const lastVerseForEnd = this.ref.section.book.chapters[
|
||||
this.ref.section.end.chapter
|
||||
];
|
||||
|
||||
// if your verse is at the beginning, to go the prev chapter and add 3 verses from that
|
||||
if (parseInt(this.ref.Section.start.verse, 10) < 4) {
|
||||
this.ref.Section.start.chapter = (
|
||||
parseInt(this.ref.Section.start.chapter, 10) - 1
|
||||
).toString();
|
||||
this.ref.Section.start.verse =
|
||||
'*-' + (3 - parseInt(this.ref.Section.start.verse, 10));
|
||||
if (this.ref.Section.start.chapter === '0') {
|
||||
this.ref.Section.start.chapter = '1';
|
||||
this.ref.Section.start.verse = '1';
|
||||
if (this.ref.section.start.verse < 4) {
|
||||
this.ref.section.start.chapter = this.ref.section.start.chapter - 1;
|
||||
this.ref.section.start.verse =
|
||||
this.ref.section.book.chapters[this.ref.section.start.chapter] -
|
||||
(3 - this.ref.section.start.verse);
|
||||
if (this.ref.section.start.chapter === 0) {
|
||||
this.ref.section.start.chapter = 1;
|
||||
this.ref.section.start.verse = 1;
|
||||
}
|
||||
} else {
|
||||
// or go back 3 verses
|
||||
this.ref.Section.start.verse = (
|
||||
parseInt(this.ref.Section.start.verse, 10) - 3
|
||||
).toString();
|
||||
this.ref.section.start.verse = this.ref.section.start.verse - 3;
|
||||
}
|
||||
|
||||
// if your verse is at the end, go to the next chapter
|
||||
if (
|
||||
this.ref.Section.end.verse === '*' ||
|
||||
parseInt(this.ref.Section.end.verse, 10) + 3 > lastVerseForEnd
|
||||
this.ref.section.end.verse === 0 ||
|
||||
this.ref.section.end.verse + 3 > lastVerseForEnd
|
||||
) {
|
||||
this.ref.Section.end.chapter = (
|
||||
parseInt(this.ref.Section.end.chapter, 10) + 1
|
||||
).toString();
|
||||
if (this.ref.Section.end.verse === '*') {
|
||||
this.ref.Section.end.verse = '3';
|
||||
this.ref.section.end.chapter = this.ref.section.end.chapter + 1;
|
||||
if (this.ref.section.end.verse === 0) {
|
||||
this.ref.section.end.verse = 3;
|
||||
} else {
|
||||
this.ref.Section.end.verse = (
|
||||
parseInt(this.ref.Section.end.verse, 10) +
|
||||
3 -
|
||||
lastVerseForEnd
|
||||
).toString();
|
||||
this.ref.section.end.verse =
|
||||
this.ref.section.end.verse + 3 - lastVerseForEnd;
|
||||
}
|
||||
|
||||
if (
|
||||
this.ref.Section.end.chapter ===
|
||||
(this.ref.Section.end.book.lastChapter + 1).toString()
|
||||
this.ref.section.end.chapter ===
|
||||
this.ref.section.book.lastChapter + 1
|
||||
) {
|
||||
this.ref.Section.end.chapter = this.ref.Section.end.book.lastChapter.toString();
|
||||
this.ref.Section.end.verse = lastVerseForEnd.toString();
|
||||
this.ref.section.end.chapter = this.ref.section.book.lastChapter;
|
||||
this.ref.section.end.verse = lastVerseForEnd;
|
||||
}
|
||||
} else {
|
||||
// or add 3 verses
|
||||
this.ref.Section.end.verse = (
|
||||
parseInt(this.ref.Section.end.verse, 10) + 3
|
||||
).toString();
|
||||
this.ref.section.end.verse = this.ref.section.end.verse + 3;
|
||||
}
|
||||
|
||||
if (this.ref.Section.start.verse === '0') {
|
||||
this.ref.Section.start.verse = '1';
|
||||
if (this.ref.section.start.verse === 0) {
|
||||
this.ref.section.start.verse = 1;
|
||||
}
|
||||
|
||||
this.appService.updatePassage(this.cardItem, this.ref);
|
||||
|
@ -75,9 +75,9 @@ const initialState: AppState = {
|
||||
|
||||
type AppAction =
|
||||
| {
|
||||
type: 'GET_SAVED_PAGE';
|
||||
pageId: string;
|
||||
}
|
||||
type: 'GET_SAVED_PAGE';
|
||||
pageId: string;
|
||||
}
|
||||
| {
|
||||
type: 'SAVE_PAGE';
|
||||
title: string;
|
||||
@ -86,48 +86,48 @@ type AppAction =
|
||||
type: 'UPDATE_CURRENT_PAGE';
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_SAVED_PAGES';
|
||||
savedPages: SavedPage[];
|
||||
}
|
||||
type: 'UPDATE_SAVED_PAGES';
|
||||
savedPages: SavedPage[];
|
||||
}
|
||||
| {
|
||||
type: 'ADD_CARD_TO_SAVED_PAGE';
|
||||
card: CardItem;
|
||||
pageId: string;
|
||||
}
|
||||
type: 'ADD_CARD_TO_SAVED_PAGE';
|
||||
card: CardItem;
|
||||
pageId: string;
|
||||
}
|
||||
| {
|
||||
type: 'ADD_CARD';
|
||||
card: CardItem;
|
||||
nextToItem: CardItem;
|
||||
}
|
||||
type: 'ADD_CARD';
|
||||
card: CardItem;
|
||||
nextToItem: CardItem;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_CARD';
|
||||
newCard: CardItem;
|
||||
oldCard: CardItem;
|
||||
}
|
||||
type: 'UPDATE_CARD';
|
||||
newCard: CardItem;
|
||||
oldCard: CardItem;
|
||||
}
|
||||
| {
|
||||
type: 'REMOVE_CARD';
|
||||
card: CardItem;
|
||||
}
|
||||
type: 'REMOVE_CARD';
|
||||
card: CardItem;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_ERROR';
|
||||
error: Error;
|
||||
}
|
||||
type: 'UPDATE_ERROR';
|
||||
error: Error;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_FONT_SIZE';
|
||||
size: number;
|
||||
}
|
||||
type: 'UPDATE_FONT_SIZE';
|
||||
size: number;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_FONT_FAMILY';
|
||||
cardFont: string;
|
||||
}
|
||||
type: 'UPDATE_FONT_FAMILY';
|
||||
cardFont: string;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_AUTOCOMPLETE';
|
||||
words: string[];
|
||||
}
|
||||
type: 'UPDATE_AUTOCOMPLETE';
|
||||
words: string[];
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_DISPLAY_SETTINGS';
|
||||
settings: DisplaySettings;
|
||||
};
|
||||
type: 'UPDATE_DISPLAY_SETTINGS';
|
||||
settings: DisplaySettings;
|
||||
};
|
||||
|
||||
function reducer(state: AppState, action: AppAction): AppState {
|
||||
// somtimes the state is null. lets not complain if that happens.
|
||||
@ -692,10 +692,10 @@ export class AppService extends createStateService(reducer, initialState) {
|
||||
}
|
||||
|
||||
private async composeBiblePassageCardItem(ref: BibleReference) {
|
||||
const result = await this.getPassageFromApi(ref.Section);
|
||||
const result = await this.getPassageFromApi(ref.section);
|
||||
return {
|
||||
qry: ref.toString(),
|
||||
dict: ref.Section.book.bookNumber > 39 ? 'G' : 'H',
|
||||
dict: ref.section.book.bookNumber > 39 ? 'G' : 'H',
|
||||
type: 'Passage',
|
||||
data: result,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user