FEATURE: Added ability to save pages...

* added db solution
This commit is contained in:
jason.wall 2017-01-18 17:51:06 -05:00
parent cd654fc5f0
commit 72207e327d
37 changed files with 3815 additions and 394 deletions

View File

@ -38,3 +38,5 @@ DynamicBibleIonic/platforms/android/AndroidManifest.xml
DynamicBibleIonic/platforms/android/.gitignore DynamicBibleIonic/platforms/android/.gitignore
DynamicBibleIonic/.idea DynamicBibleIonic/.idea
DynamicBibleIonic/nbproject DynamicBibleIonic/nbproject
DynamicBibleIonic/obj
DynamicBibleIonic/bin

View File

@ -1,3 +0,0 @@
{
"typescript.tsdk": "./node_modules/typescript/lib"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "DynamicBibleIonic", "DynamicBibleIonic.njsproj", "{78F6C2B6-208E-4A76-A214-921AFA081284}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{78F6C2B6-208E-4A76-A214-921AFA081284}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78F6C2B6-208E-4A76-A214-921AFA081284}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -46,7 +46,7 @@
<preference name="SplashScreen" value="screen"/> <preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="12000"/> <preference name="SplashScreenDelay" value="12000"/>
<preference name="ShowSplashScreen" value="true"/> <preference name="ShowSplashScreen" value="true"/>
<preference name="AutoHideSplashScreen" value="true"/> <preference name="AutoHideSplashScreen" value="false"/>
<preference name="SplashShowOnlyFirstTime" value="false"/> <preference name="SplashShowOnlyFirstTime" value="false"/>
<preference name="FadeSplashScreen" value="false"/> <preference name="FadeSplashScreen" value="false"/>
<feature name="SplashScreen"> <feature name="SplashScreen">

Binary file not shown.

View File

@ -1,31 +1,27 @@
import { Component, ViewChild } from '@angular/core'; import { Component, ViewChild } from '@angular/core';
import { Platform, MenuController, Nav } from 'ionic-angular'; import { Platform, MenuController, Nav } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native'; import { StatusBar, Splashscreen } from 'ionic-native';
import {SearchPage} from "../pages/search/search"; import { SearchPage } from "../pages/search/search";
import {SettingsPage} from "../pages/settings/settings"; import { SettingsPage } from "../pages/settings/settings";
import { PagesService } from "../services/pages-service";
@Component({ @Component({
templateUrl: 'app.html' templateUrl: 'app.html',
providers: [PagesService]
}) })
export class MyApp export class MyApp
{ {
@ViewChild(Nav) nav: Nav; @ViewChild(Nav) nav: Nav;
rootPage: any = SearchPage; rootPage: any = SearchPage;
pages: Array<{ title: string, component: any }>;
constructor( constructor(
public platform: Platform, public platform: Platform,
public menu: MenuController public menu: MenuController,
private pagesSvc: PagesService
) )
{ {
this.initializeApp(); this.initializeApp();
// set our app's pages
this.pages = [
{ title: 'Search', component: SearchPage },
{ title: 'Settings', component: SettingsPage }
];
} }
initializeApp() initializeApp()
@ -42,8 +38,8 @@ export class MyApp
openPage(page) openPage(page)
{ {
// close the menu when clicking a link from the menu // 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 // navigate to the new page if it is not the current page
this.nav.setRoot(page.component); this.nav.setRoot(page.component, page.params);
} }
} }

View File

@ -8,7 +8,7 @@
<ion-content> <ion-content>
<ion-list> <ion-list>
<button ion-item *ngFor="let p of pages" (click)="openPage(p)"> <button ion-item *ngFor="let p of pagesSvc.getResult()" (click)="openPage(p)">
{{p.title}} {{p.title}}
</button> </button>
</ion-list> </ion-list>

View File

@ -1,4 +1,4 @@
import { NgModule, ErrorHandler } from '@angular/core'; import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
@ -6,15 +6,15 @@ import { Storage } from '@ionic/storage';
import { MyApp } from './app.component'; import { MyApp } from './app.component';
import {SearchPage} from "../pages/search/search"; import { SearchPage } from "../pages/search/search";
import {SettingsPage} from "../pages/settings/settings"; import { SettingsPage } from "../pages/settings/settings";
import {ComponentLoader} from "../components/component-loader/component-loader"; import { ComponentLoader } from "../components/component-loader/component-loader";
import {Passage} from "../components/passage/passage"; import { Passage } from "../components/passage/passage";
import {Strongs} from "../components/strongs/strongs"; import { Strongs } from "../components/strongs/strongs";
import {Words} from "../components/words/words"; import { Words } from "../components/words/words";
import {Error} from "../components/error/error"; import { Error } from "../components/error/error";
import {StrongsModal} from "../components/strongs-modal/strongs-modal"; import { StrongsModal } from "../components/strongs-modal/strongs-modal";
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -45,4 +45,4 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal";
], ],
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage] providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
}) })
export class AppModule { } export class AppModule { }

View File

@ -25,7 +25,7 @@ export class ComponentLoader {
} }
let factory = this.componentFactoryResolver.resolveComponentFactory(this.type); let factory = this.componentFactoryResolver.resolveComponentFactory(this.type);
this.cmpRef = this.target.createComponent(factory) this.cmpRef = this.target.createComponent(factory);
// to access the created instance use // to access the created instance use
// this.compRef.instance.someProperty = 'someValue'; // this.compRef.instance.someProperty = 'someValue';
// this.compRef.instance.someOutput.subscribe(val => doSomething()); // this.compRef.instance.someOutput.subscribe(val => doSomething());

View File

@ -7,4 +7,8 @@
<ion-card-content> <ion-card-content>
<br> <br>
<p>{{item}}</p> <p>{{item}}</p>
</ion-card-content> </ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>

View File

@ -1,4 +1,5 @@
import { EventEmitter, Component, Input, Output } from "@angular/core"; import { EventEmitter, Component, Input, Output } from "@angular/core";
import { CardItem } from "../../pages/search/search";
@Component({ @Component({
selector: "error", selector: "error",

View File

@ -1,4 +1,4 @@
<ion-item class="title passage-title"> <ion-item class="title passage-title">
{{item.ref}} {{item.ref}}
<button ion-button icon-only item-right large clear (click)="close()"> <button ion-button icon-only item-right large clear (click)="close()">
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
@ -6,11 +6,23 @@
</ion-item> </ion-item>
<ion-card-content> <ion-card-content>
<br> <br>
<div class="passage-text" *ngFor="let ch of item.cs"> <div class="passage-text" *ngFor="let ch of item.cs">
<h2 *ngIf="item.cs.length > 1"><b>Chapter {{ch.ch}}</b> <h2 *ngIf="item.cs.length > 1">
<b>Chapter {{ch.ch}}</b>
</h2> </h2>
<span *ngFor="let vs of ch.vss"><b>{{vs.v}}.</b> <span *ngFor="let w of vs.w"><template [ngIf]="!isPunct(w.t)"> <span *ngFor="let vs of ch.vss">
</template><a *ngIf="w.s != null" (click)="openStrongs(w.s)" (press)="openMenu(w.s)">{{w.t}}</a><template [ngIf]="!(w.s != null)">{{w.t}}</template></span><br></span> <b>{{vs.v}}.</b> <span *ngFor="let w of vs.w">
<template [ngIf]="!isPunct(w.t)">
</template><a *ngIf="w.s != null" (click)="openStrongs(w.s)" (press)="openMenu(w.s)">{{w.t}}</a>
<template [ngIf]="!(w.s != null)">
{{w.t}}
</template>
</span><br>
</span>
</div> </div>
</ion-card-content> </ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>

View File

@ -2,13 +2,18 @@
background-color: #c3cce4; background-color: #c3cce4;
} }
passage .passage-text { passage .passage-text {
margin-bottom: 10px;
padding-bottom: 12px; padding-bottom: 12px;
border-bottom: 1px dotted #808080;
} }
@media screen and (min-width: 600px) and (max-width: 849px) { .passage-text + .passage-text
{
border-top: 1px dotted #808080;
padding-top: 12px;
}
@media screen and (min-width: 700px) and (max-width: 949px) {
passage .passage-text { passage .passage-text {
-webkit-column-count: 2; /* Chrome, Safari, Opera */ -webkit-column-count: 2; /* Chrome, Safari, Opera */
-moz-column-count: 2; /* Firefox */ -moz-column-count: 2; /* Firefox */
@ -16,16 +21,16 @@ passage .passage-text {
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */ -webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */ -moz-column-gap: 30px; /* Firefox */
column-gap: 30px; column-gap: 30px;
-webkit-column-rule-style: solid; /* Chrome, Safari, Opera */ -webkit-column-rule-style: dotted; /* Chrome, Safari, Opera */
-moz-column-rule-style: solid; /* Firefox */ -moz-column-rule-style: dotted; /* Firefox */
column-rule-style: solid; column-rule-style: dotted;
-webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */ -webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */
-moz-column-rule-width: 1px; /* Firefox */ -moz-column-rule-width: 1px; /* Firefox */
column-rule-width: 1px; column-rule-width: 1px;
} }
} }
@media screen and (min-width: 850px) { @media screen and (min-width: 950px) {
passage .passage-text { passage .passage-text {
-webkit-column-count: 3; /* Chrome, Safari, Opera */ -webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */ -moz-column-count: 3; /* Firefox */
@ -33,9 +38,9 @@ passage .passage-text {
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */ -webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */ -moz-column-gap: 30px; /* Firefox */
column-gap: 30px; column-gap: 30px;
-webkit-column-rule-style: solid; /* Chrome, Safari, Opera */ -webkit-column-rule-style: dotted; /* Chrome, Safari, Opera */
-moz-column-rule-style: solid; /* Firefox */ -moz-column-rule-style: dotted; /* Firefox */
column-rule-style: solid; column-rule-style: dotted;
-webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */ -webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */
-moz-column-rule-width: 1px; /* Firefox */ -moz-column-rule-width: 1px; /* Firefox */
column-rule-width: 1px; column-rule-width: 1px;

View File

@ -1,9 +1,13 @@
import { Component, EventEmitter, Output, Input} from "@angular/core"; import { Component, EventEmitter, Output, Input } from "@angular/core";
import { BiblePassageResult } from "../../services/bible-service";
import { OpenData, CardItem } from "../../pages/search/search";
@Component({ @Component({
selector: "passage", selector: "passage",
templateUrl: "passage.html" templateUrl: "passage.html"
}) })
export class Passage { export class Passage
{
@Output() @Output()
onStrongsClicked = new EventEmitter<OpenData>(); onStrongsClicked = new EventEmitter<OpenData>();
@Output() @Output()
@ -18,18 +22,23 @@ export class Passage {
@Input() @Input()
cardItem: CardItem; cardItem: CardItem;
constructor() { constructor()
{
} }
close() { close()
{
this.onClose.emit(this.cardItem); this.onClose.emit(this.cardItem);
} }
openStrongs(strongs: string) { openStrongs(strongs: string)
{
this.onStrongsClicked.emit({ card: this.cardItem, qry: this.dict + strongs }); this.onStrongsClicked.emit({ card: this.cardItem, qry: this.dict + strongs });
} }
openMenu(strongs: string) { openMenu(strongs: string)
{
} }
isPunct(c: string) { isPunct(c: string)
{
return new RegExp('^[\.\,\;\:\?\!]$').test(c) return new RegExp('^[\.\,\;\:\?\!]$').test(c)
} }
} }

View File

@ -1,12 +1,14 @@
import { EventEmitter, Component, Output } from "@angular/core"; import { EventEmitter, Component, Output } from "@angular/core";
import { Platform, NavParams, ViewController } from 'ionic-angular'; import { Platform, NavParams, ViewController } from 'ionic-angular';
import { Reference } from '../../Reference'; import { Reference } from '../../libs/Reference';
import { StrongsResult } from "../../services/strongs-service";
@Component({ @Component({
selector: "strongs-modal", selector: "strongs-modal",
templateUrl: "strongs-modal.html" templateUrl: "strongs-modal.html"
}) })
export class StrongsModal { export class StrongsModal
{
item: StrongsResult; item: StrongsResult;
@Output() @Output()
@ -16,21 +18,25 @@ export class StrongsModal {
public platform: Platform, public platform: Platform,
public params: NavParams, public params: NavParams,
public viewCtrl: ViewController public viewCtrl: ViewController
) { )
{
this.item = this.params.get('strongsid') as StrongsResult; this.item = this.params.get('strongsid') as StrongsResult;
this.onPassageClicked.subscribe(item => this.onPassageClicked.subscribe(item =>
this.params.get('onPassageClicked').getItems(item) this.params.get('onPassageClicked').getItems(item)
) )
} }
dismiss() { dismiss()
{
this.viewCtrl.dismiss(); this.viewCtrl.dismiss();
} }
makePassage(p: string) { makePassage(p: string)
{
return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2]; return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2];
} }
openPassage(p: string) { openPassage(p: string)
{
let ref = this.makePassage(p); let ref = this.makePassage(p);
this.onPassageClicked.emit(ref); this.onPassageClicked.emit(ref);
} }
} }

View File

@ -32,4 +32,8 @@
</dl> </dl>
</ion-scroll> </ion-scroll>
</div> </div>
</ion-card-content> </ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>

View File

@ -1,4 +1,8 @@
.strongs-title { strongs .button-clear-md{
color: #307e4b;
}
.strongs-title {
background-color: #c6efd4; background-color: #c6efd4;
} }

View File

@ -1,11 +1,14 @@
import { EventEmitter, Component, Input, Output } from "@angular/core"; import { EventEmitter, Component, Input, Output } from "@angular/core";
import { Reference } from '../../Reference'; import { Reference } from '../../libs/Reference';
import { OpenData, CardItem } from "../../pages/search/search";
import { StrongsResult } from "../../services/strongs-service";
@Component({ @Component({
selector: "strongs", selector: "strongs",
templateUrl: "strongs.html" templateUrl: "strongs.html"
}) })
export class Strongs { export class Strongs
{
@Output() @Output()
onClose = new EventEmitter<CardItem>(); onClose = new EventEmitter<CardItem>();
@ -18,18 +21,21 @@ export class Strongs {
@Input() @Input()
cardItem: CardItem; cardItem: CardItem;
constructor() { constructor()
{
} }
close() close()
{ {
this.onClose.emit(this.cardItem); this.onClose.emit(this.cardItem);
} }
makePassage(p: string) { makePassage(p: string)
{
return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2]; return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2];
} }
openPassage(p: string) { openPassage(p: string)
{
let ref = this.makePassage(p); let ref = this.makePassage(p);
this.onPassageClicked.emit({ card: this.cardItem, qry: ref }); this.onPassageClicked.emit({ card: this.cardItem, qry: ref });
} }
} }

View File

@ -8,4 +8,8 @@
<ion-scroll scrollY="true" overflow-scroll="true"> <ion-scroll scrollY="true" overflow-scroll="true">
<a class="passage-button" *ngFor="let ref of item.refs" (click)="openPassage(ref)">{{makePassage(ref)}}</a> <a class="passage-button" *ngFor="let ref of item.refs" (click)="openPassage(ref)">{{makePassage(ref)}}</a>
</ion-scroll> </ion-scroll>
</ion-card-content> </ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>

View File

@ -1,4 +1,8 @@
words { words {
.button-clear-md {
color: #632761;
}
.words-title { .words-title {
background-color: #f5b9f3; background-color: #f5b9f3;
} }

View File

@ -1,11 +1,14 @@
import {EventEmitter, Component, Input, Output} from "@angular/core"; import { EventEmitter, Component, Input, Output } from "@angular/core";
import { Reference } from '../../Reference'; import { Reference } from '../../libs/Reference';
import { OpenData, CardItem } from "../../pages/search/search";
import { WordLookupResult } from "../../services/word-service"
@Component({ @Component({
selector: "words", selector: "words",
templateUrl: "words.html" templateUrl: "words.html"
}) })
export class Words { export class Words
{
@Output() @Output()
onClose = new EventEmitter<CardItem>(); onClose = new EventEmitter<CardItem>();
@ -18,10 +21,12 @@ export class Words {
@Input() @Input()
cardItem: CardItem; cardItem: CardItem;
constructor() { constructor()
{
} }
close() { close()
{
this.onClose.emit(this.cardItem); this.onClose.emit(this.cardItem);
} }
@ -34,4 +39,4 @@ export class Words {
let ref = this.makePassage(p); let ref = this.makePassage(p);
this.onPassageClicked.emit({ card: this.cardItem, qry: ref }); this.onPassageClicked.emit({ card: this.cardItem, qry: ref });
} }
} }

View File

@ -3,28 +3,33 @@
// Jason@walljm.com // www.walljm.com // Jason@walljm.com // www.walljm.com
// Jeremy@marzhillstudios.com // jeremy.marzhillstudios.com // Jeremy@marzhillstudios.com // jeremy.marzhillstudios.com
/// <reference path="types.ts"/> class StringUtils
class StringUtils { {
public static trim(str: string): string { public static trim(str: string): string
{
return str.replace(/^\s+|\s+$/g, ""); return str.replace(/^\s+|\s+$/g, "");
} }
public static ltrim(str: string): string { public static ltrim(str: string): string
{
return str.replace(/^\s+/, ""); return str.replace(/^\s+/, "");
} }
public static rtrim(str: string): string { public static rtrim(str: string): string
{
return str.replace(/\s+$/, ""); return str.replace(/\s+$/, "");
} }
} }
export class Reference { export class Reference
{
private ref: string; private ref: string;
public Section: Section; public Section: Section;
public errAcc: string; public errAcc: string;
constructor(reference: string) { constructor(reference: string)
{
this.Section = { this.Section = {
start: { start: {
book: -1, book: -1,
@ -46,7 +51,8 @@ export class Reference {
this.ref = reference.toLowerCase().trim(); this.ref = reference.toLowerCase().trim();
this.parseReference(); this.parseReference();
if (this.Section.end.book == -1) { if (this.Section.end.book == -1)
{
this.Section.end.book = this.Section.start.book; this.Section.end.book = this.Section.start.book;
this.Section.end.bookname = this.Section.start.bookname; this.Section.end.bookname = this.Section.start.bookname;
this.Section.end.longbookname = this.Section.start.longbookname; this.Section.end.longbookname = this.Section.start.longbookname;
@ -63,7 +69,8 @@ export class Reference {
if (this.Section.end.verse == "") this.Section.end.verse = "*"; if (this.Section.end.verse == "") this.Section.end.verse = "*";
} }
private parseReference() { private parseReference()
{
this.parseBook(false); this.parseBook(false);
this.parseFirstNum(false); this.parseFirstNum(false);
let foundFirstVerse = this.ref.search(/:.*-/) != -1; let foundFirstVerse = this.ref.search(/:.*-/) != -1;
@ -76,7 +83,8 @@ export class Reference {
this.maybeParseSecondNum(true); this.maybeParseSecondNum(true);
}; };
private parseBook(isEnd?: boolean) { private parseBook(isEnd?: boolean)
{
this.ref = this.ref.toLowerCase().trim(); this.ref = this.ref.toLowerCase().trim();
let fbook = this.ref.substring(0, this.ref.search(/\w\s+\d/i) + 1); let fbook = this.ref.substring(0, this.ref.search(/\w\s+\d/i) + 1);
@ -87,24 +95,32 @@ export class Reference {
else this.Section.start = Reference.parseBook(fbook); else this.Section.start = Reference.parseBook(fbook);
} }
private parseFirstNum(isEnd: boolean) { private parseFirstNum(isEnd: boolean)
{
let thing = this.Section.start; let thing = this.Section.start;
if (isEnd) thing = this.Section.end; if (isEnd) thing = this.Section.end;
this.ref = StringUtils.ltrim(this.ref); this.ref = StringUtils.ltrim(this.ref);
let found = false; let found = false;
for (let i = 0; i <= this.ref.length; i++) { for (let i = 0; i <= this.ref.length; i++)
{
let c = this.ref.charAt(i); let c = this.ref.charAt(i);
// Grab characters until we hit a non digit. // Grab characters until we hit a non digit.
if ("0".charAt(0) <= c && c <= "9".charAt(0)) { if ("0".charAt(0) <= c && c <= "9".charAt(0))
{
found = true; found = true;
thing.chapter = thing.chapter.concat(c); thing.chapter = thing.chapter.concat(c);
} else { }
else
{
// if the chapter is longer than 3 digits it's an error // if the chapter is longer than 3 digits it's an error
if (thing.chapter.length > 3) { if (thing.chapter.length > 3)
{
this.errAcc = "Chapter too long\"" + thing.chapter + "\"."; this.errAcc = "Chapter too long\"" + thing.chapter + "\".";
return; return;
} else if (!found) { }
else if (!found)
{
this.errAcc = "No chapter found" + this.ref; this.errAcc = "No chapter found" + this.ref;
} }
this.ref = this.ref.slice(i); this.ref = this.ref.slice(i);
@ -113,29 +129,38 @@ export class Reference {
} }
} }
private parseSecondNum(skipColon?: boolean, isEnd?: boolean) { private parseSecondNum(skipColon?: boolean, isEnd?: boolean)
{
let thing = this.Section.start; let thing = this.Section.start;
if (isEnd) thing = this.Section.end; if (isEnd) thing = this.Section.end;
this.ref = StringUtils.ltrim(this.ref.toLowerCase()); this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (!skipColon) { if (!skipColon)
if (this.ref[0] != ":") { {
if (this.ref[0] != ":")
{
return; return;
} }
this.ref = this.ref.slice(1); this.ref = this.ref.slice(1);
} }
this.ref = StringUtils.ltrim(this.ref.toLowerCase()); this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (this.ref[0] == "*") { if (this.ref[0] == "*")
{
thing.verse = "*"; thing.verse = "*";
this.ref = this.ref.slice(1); this.ref = this.ref.slice(1);
return; return;
} }
for (var i = 0; i <= this.ref.length; i++) { for (var i = 0; i <= this.ref.length; i++)
{
let c = this.ref.charAt(i); let c = this.ref.charAt(i);
if ("0".charAt(0) <= c && c <= "9".charAt(0)) { if ("0".charAt(0) <= c && c <= "9".charAt(0))
{
thing.verse = thing.verse.concat(c); thing.verse = thing.verse.concat(c);
} else { }
if (thing.verse.length > 3) { else
{
if (thing.verse.length > 3)
{
this.errAcc = "Verse too long \"" + thing.verse + "\"."; this.errAcc = "Verse too long \"" + thing.verse + "\".";
return ""; return "";
} }
@ -145,31 +170,41 @@ export class Reference {
} }
} }
private maybeParseBook(isEnd: boolean) { private maybeParseBook(isEnd: boolean)
return this.maybeDo(() => { {
if (this.ref.search(/\w\s+\d/i) == -1) { return this.maybeDo(() =>
{
if (this.ref.search(/\w\s+\d/i) == -1)
{
this.Section.end.book = this.Section.start.book; this.Section.end.book = this.Section.start.book;
this.Section.end.bookname = this.Section.start.bookname; this.Section.end.bookname = this.Section.start.bookname;
this.Section.end.longbookname = this.Section.start.longbookname; this.Section.end.longbookname = this.Section.start.longbookname;
this.Section.end.lastchapter = this.Section.start.lastchapter; this.Section.end.lastchapter = this.Section.start.lastchapter;
} }
else { else
{
this.parseBook(isEnd) this.parseBook(isEnd)
} }
}); });
}; };
private maybeParseSecondNum(isEnd?: boolean) { private maybeParseSecondNum(isEnd?: boolean)
return this.maybeDo(() => { {
return this.maybeDo(() =>
{
this.parseSecondNum(false, isEnd); this.parseSecondNum(false, isEnd);
}); });
}; };
private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean) { private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean)
{
let self = this; let self = this;
return this.maybeDo(() => { return this.maybeDo(() =>
if (self.Section.end.book == self.Section.start.book) { {
if (self.ref.search(/:/) != -1 || foundSecondBook || !foundFirstVerse) { if (self.Section.end.book == self.Section.start.book)
{
if (self.ref.search(/:/) != -1 || foundSecondBook || !foundFirstVerse)
{
self.parseFirstNum(isEnd); self.parseFirstNum(isEnd);
} }
self.parseSecondNum(true, isEnd); self.parseSecondNum(true, isEnd);
@ -177,29 +212,36 @@ export class Reference {
}); });
}; };
private maybeParseRangeSep() { private maybeParseRangeSep()
{
let self = this; let self = this;
return this.maybeDo(() => { return this.maybeDo(() =>
if (self.ref[0] == "-") { {
if (self.ref[0] == "-")
{
self.ref = StringUtils.ltrim(self.ref.slice(1)); self.ref = StringUtils.ltrim(self.ref.slice(1));
} }
}); });
}; };
private maybeDo(f) { private maybeDo(f)
{
let func = f; let func = f;
this.ref = StringUtils.ltrim(this.ref.toLowerCase()); this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (this.ref != "") { if (this.ref != "")
{
func(); func();
} }
}; };
public toString() { public toString()
{
// get the starting book, chapter, verse // get the starting book, chapter, verse
return Reference.toString(this.Section); return Reference.toString(this.Section);
}; };
public static parseBook(fbook: string) { public static parseBook(fbook: string)
{
let thing = { let thing = {
book: 0, book: 0,
bookname: "", bookname: "",
@ -208,397 +250,463 @@ export class Reference {
chapter: "", chapter: "",
verse: "" verse: ""
}; };
if (fbook.search(/\b(genesis|gen|ge|gn)\b/i) != -1) { if (fbook.search(/\b(genesis|gen|ge|gn)\b/i) != -1)
{
thing.book = 1; thing.book = 1;
thing.bookname = "Genesis"; thing.bookname = "Genesis";
thing.longbookname = "Genesis"; thing.longbookname = "Genesis";
thing.lastchapter = 50; thing.lastchapter = 50;
} }
if (fbook.search(/\b(exodus|ex|exo|exod|exd)\b/i) != -1) { if (fbook.search(/\b(exodus|ex|exo|exod|exd)\b/i) != -1)
{
thing.book = 2; thing.book = 2;
thing.bookname = "Exodus"; thing.bookname = "Exodus";
thing.longbookname = "Exodus"; thing.longbookname = "Exodus";
thing.lastchapter = 40; thing.lastchapter = 40;
} }
if (fbook.search(/\b(leviticus|lev|le|levi|lv)\b/i) != -1) { if (fbook.search(/\b(leviticus|lev|le|levi|lv)\b/i) != -1)
{
thing.book = 3; thing.book = 3;
thing.bookname = "Leviticus"; thing.bookname = "Leviticus";
thing.longbookname = "Leviticus"; thing.longbookname = "Leviticus";
thing.lastchapter = 27; thing.lastchapter = 27;
} }
if (fbook.search(/\b(numbers|num|nu|numb|number)\b/i) != -1) { if (fbook.search(/\b(numbers|num|nu|numb|number)\b/i) != -1)
{
thing.book = 4; thing.book = 4;
thing.bookname = "Numbers"; thing.bookname = "Numbers";
thing.longbookname = "Book_of_Numbers"; thing.longbookname = "Book_of_Numbers";
thing.lastchapter = 36; thing.lastchapter = 36;
} }
if (fbook.search(/\b(deuteronomy|deut|de|dt|deu)\b/i) != -1) { if (fbook.search(/\b(deuteronomy|deut|de|dt|deu)\b/i) != -1)
{
thing.book = 5; thing.book = 5;
thing.bookname = "Deuteronomy"; thing.bookname = "Deuteronomy";
thing.longbookname = "Deuteronomy"; thing.longbookname = "Deuteronomy";
thing.lastchapter = 34; thing.lastchapter = 34;
} }
if (fbook.search(/\b(joshua|josh|jos)\b/i) != -1) { if (fbook.search(/\b(joshua|josh|jos)\b/i) != -1)
{
thing.book = 6; thing.book = 6;
thing.bookname = "Joshua"; thing.bookname = "Joshua";
thing.longbookname = "Book_of_Joshua"; thing.longbookname = "Book_of_Joshua";
thing.lastchapter = 24; thing.lastchapter = 24;
} }
if (fbook.search(/\b(judges|jud|jdg|judg)\b/i) != -1) { if (fbook.search(/\b(judges|jud|jdg|judg)\b/i) != -1)
{
thing.book = 7; thing.book = 7;
thing.bookname = "Judges"; thing.bookname = "Judges";
thing.longbookname = "Book_of_Judges"; thing.longbookname = "Book_of_Judges";
thing.lastchapter = 21; thing.lastchapter = 21;
} }
if (fbook.search(/\b(ruth|ru)\b/i) != -1) { if (fbook.search(/\b(ruth|ru)\b/i) != -1)
{
thing.book = 8; thing.book = 8;
thing.bookname = "Ruth"; thing.bookname = "Ruth";
thing.longbookname = "Book_of_Ruth"; thing.longbookname = "Book_of_Ruth";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
if (fbook.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) != -1) { if (fbook.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) != -1)
{
thing.book = 9; thing.book = 9;
thing.bookname = "1 Samuel"; thing.bookname = "1 Samuel";
thing.longbookname = "First_Samuel"; thing.longbookname = "First_Samuel";
thing.lastchapter = 31; thing.lastchapter = 31;
} }
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)
{
thing.book = 10; thing.book = 10;
thing.bookname = "2 Samuel"; thing.bookname = "2 Samuel";
thing.longbookname = "Second_Samuel"; thing.longbookname = "Second_Samuel";
thing.lastchapter = 24; thing.lastchapter = 24;
} }
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)
{
thing.book = 11; thing.book = 11;
thing.bookname = "1 Kings"; thing.bookname = "1 Kings";
thing.longbookname = "First_Kings"; thing.longbookname = "First_Kings";
thing.lastchapter = 22; thing.lastchapter = 22;
} }
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)
{
thing.book = 12; thing.book = 12;
thing.bookname = "2 Kings"; thing.bookname = "2 Kings";
thing.longbookname = "Second_Kings"; thing.longbookname = "Second_Kings";
thing.lastchapter = 25; thing.lastchapter = 25;
} }
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)
{
thing.book = 13; thing.book = 13;
thing.bookname = "1 Chronicles"; thing.bookname = "1 Chronicles";
thing.longbookname = "First_Chronicles"; thing.longbookname = "First_Chronicles";
thing.lastchapter = 29; thing.lastchapter = 29;
} }
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)
{
thing.book = 14; thing.book = 14;
thing.bookname = "2 Chronicles"; thing.bookname = "2 Chronicles";
thing.longbookname = "Second_Chronicles"; thing.longbookname = "Second_Chronicles";
thing.lastchapter = 36; thing.lastchapter = 36;
} }
if (fbook.search(/\b(ezra|ezr)\b/i) != -1) { if (fbook.search(/\b(ezra|ezr)\b/i) != -1)
{
thing.book = 15; thing.book = 15;
thing.bookname = "Ezra"; thing.bookname = "Ezra";
thing.longbookname = "Book_of_Ezra"; thing.longbookname = "Book_of_Ezra";
thing.lastchapter = 10; thing.lastchapter = 10;
} }
if (fbook.search(/\b(nehemiah|neh|ne|nehamiah)\b/i) != -1) { if (fbook.search(/\b(nehemiah|neh|ne|nehamiah)\b/i) != -1)
{
thing.book = 16; thing.book = 16;
thing.bookname = "Nehemiah"; thing.bookname = "Nehemiah";
thing.longbookname = "Book_of_Nehemiah"; thing.longbookname = "Book_of_Nehemiah";
thing.lastchapter = 13; thing.lastchapter = 13;
} }
if (fbook.search(/\b(esther|est|es|esth)\b/i) != -1) { if (fbook.search(/\b(esther|est|es|esth)\b/i) != -1)
{
thing.book = 17; thing.book = 17;
thing.bookname = "Esther"; thing.bookname = "Esther";
thing.longbookname = "Book_of_Esther"; thing.longbookname = "Book_of_Esther";
thing.lastchapter = 10; thing.lastchapter = 10;
} }
if (fbook.search(/\b(job|jo|jb)\b/i) != -1) { if (fbook.search(/\b(job|jo|jb)\b/i) != -1)
{
thing.book = 18; thing.book = 18;
thing.bookname = "Job"; thing.bookname = "Job";
thing.longbookname = "Book_of_Job"; thing.longbookname = "Book_of_Job";
thing.lastchapter = 42; thing.lastchapter = 42;
} }
if (fbook.search(/\b(psalms|ps|psa|psalm|psm)\b/i) != -1) { if (fbook.search(/\b(psalms|ps|psa|psalm|psm)\b/i) != -1)
{
thing.book = 19; thing.book = 19;
thing.bookname = "Psalm"; thing.bookname = "Psalm";
thing.longbookname = "Psalm"; thing.longbookname = "Psalm";
thing.lastchapter = 150; thing.lastchapter = 150;
} }
if (fbook.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) != -1) { if (fbook.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) != -1)
{
thing.book = 20; thing.book = 20;
thing.bookname = "Proverbs"; thing.bookname = "Proverbs";
thing.longbookname = "Book_of_Proverbs"; thing.longbookname = "Book_of_Proverbs";
thing.lastchapter = 31; thing.lastchapter = 31;
} }
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)
{
thing.book = 21; thing.book = 21;
thing.bookname = "Ecclesiastes"; thing.bookname = "Ecclesiastes";
thing.longbookname = "Ecclesiastes"; thing.longbookname = "Ecclesiastes";
thing.lastchapter = 12; thing.lastchapter = 12;
} }
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)
{
thing.book = 22; thing.book = 22;
thing.bookname = "Song of Solomon"; thing.bookname = "Song of Solomon";
thing.longbookname = "Song_of_Solomon"; thing.longbookname = "Song_of_Solomon";
thing.lastchapter = 8; thing.lastchapter = 8;
} }
if (fbook.search(/\b(isaiah|is|isah|isai|ia)\b/i) != -1) { if (fbook.search(/\b(isaiah|is|isah|isai|ia)\b/i) != -1)
{
thing.book = 23; thing.book = 23;
thing.bookname = "Isaiah"; thing.bookname = "Isaiah";
thing.longbookname = "Book_of_Isaiah"; thing.longbookname = "Book_of_Isaiah";
thing.lastchapter = 66; thing.lastchapter = 66;
} }
if (fbook.search(/\b(jerimiah|jeremiah|jer|je|jere)\b/i) != -1) { if (fbook.search(/\b(jerimiah|jeremiah|jer|je|jere)\b/i) != -1)
{
thing.book = 24; thing.book = 24;
thing.bookname = "Jeremiah"; thing.bookname = "Jeremiah";
thing.longbookname = "Book_of_Jeremiah"; thing.longbookname = "Book_of_Jeremiah";
thing.lastchapter = 52; thing.lastchapter = 52;
} }
if (fbook.search(/\b(lamentations|lam|la|lamentation)\b/i) != -1) { if (fbook.search(/\b(lamentations|lam|la|lamentation)\b/i) != -1)
{
thing.book = 25; thing.book = 25;
thing.bookname = "Lamentations"; thing.bookname = "Lamentations";
thing.longbookname = "Book_of_Lamentations"; thing.longbookname = "Book_of_Lamentations";
thing.lastchapter = 5; thing.lastchapter = 5;
} }
if (fbook.search(/\b(ezekiel|eze|ezk|ezek)\b/i) != -1) { if (fbook.search(/\b(ezekiel|eze|ezk|ezek)\b/i) != -1)
{
thing.book = 26; thing.book = 26;
thing.bookname = "Ezekiel"; thing.bookname = "Ezekiel";
thing.longbookname = "Book_of_Ezekiel"; thing.longbookname = "Book_of_Ezekiel";
thing.lastchapter = 48; thing.lastchapter = 48;
} }
if (fbook.search(/\b(daniel|dan|dn|dl|da)\b/i) != -1) { if (fbook.search(/\b(daniel|dan|dn|dl|da)\b/i) != -1)
{
thing.book = 27; thing.book = 27;
thing.bookname = "Daniel"; thing.bookname = "Daniel";
thing.longbookname = "Book_of_Daniel"; thing.longbookname = "Book_of_Daniel";
thing.lastchapter = 12; thing.lastchapter = 12;
} }
if (fbook.search(/\b(hosea|hos|ho)\b/i) != -1) { if (fbook.search(/\b(hosea|hos|ho)\b/i) != -1)
{
thing.book = 28; thing.book = 28;
thing.bookname = "Hosea"; thing.bookname = "Hosea";
thing.longbookname = "Book_of_Hosea"; thing.longbookname = "Book_of_Hosea";
thing.lastchapter = 14; thing.lastchapter = 14;
} }
if (fbook.search(/\b(joel|joe|jl)\b/i) != -1) { if (fbook.search(/\b(joel|joe|jl)\b/i) != -1)
{
thing.book = 29; thing.book = 29;
thing.bookname = "Joel"; thing.bookname = "Joel";
thing.longbookname = "Book_of_Joel"; thing.longbookname = "Book_of_Joel";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(amos|am|amo)\b/i) != -1) { if (fbook.search(/\b(amos|am|amo)\b/i) != -1)
{
thing.book = 30; thing.book = 30;
thing.bookname = "Amos"; thing.bookname = "Amos";
thing.longbookname = "Book_of_Amos"; thing.longbookname = "Book_of_Amos";
thing.lastchapter = 9; thing.lastchapter = 9;
} }
if (fbook.search(/\b(obadiah|oba|ob|obad)\b/i) != -1) { if (fbook.search(/\b(obadiah|oba|ob|obad)\b/i) != -1)
{
thing.book = 31; thing.book = 31;
thing.bookname = "Obadiah"; thing.bookname = "Obadiah";
thing.longbookname = "Book_of_Obadiah"; thing.longbookname = "Book_of_Obadiah";
thing.lastchapter = 1; thing.lastchapter = 1;
} }
if (fbook.search(/\b(jonah|jnh|jon)\b/i) != -1) { if (fbook.search(/\b(jonah|jnh|jon)\b/i) != -1)
{
thing.book = 32; thing.book = 32;
thing.bookname = "Jonah"; thing.bookname = "Jonah";
thing.longbookname = "Book_of_Jonah"; thing.longbookname = "Book_of_Jonah";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
if (fbook.search(/\b(micah|mic|mi)\b/i) != -1) { if (fbook.search(/\b(micah|mic|mi)\b/i) != -1)
{
thing.book = 33; thing.book = 33;
thing.bookname = "Micah"; thing.bookname = "Micah";
thing.longbookname = "Book_of_Micah"; thing.longbookname = "Book_of_Micah";
thing.lastchapter = 7; thing.lastchapter = 7;
} }
if (fbook.search(/\b(nahum|nah|na)\b/i) != -1) { if (fbook.search(/\b(nahum|nah|na)\b/i) != -1)
{
thing.book = 34; thing.book = 34;
thing.bookname = "Nahum"; thing.bookname = "Nahum";
thing.longbookname = "Book_of_Nahum"; thing.longbookname = "Book_of_Nahum";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(habakkuk|hab|ha|habakuk)\b/i) != -1) { if (fbook.search(/\b(habakkuk|hab|ha|habakuk)\b/i) != -1)
{
thing.book = 35; thing.book = 35;
thing.bookname = "Habakkuk"; thing.bookname = "Habakkuk";
thing.longbookname = "Book_of_Habakkuk"; thing.longbookname = "Book_of_Habakkuk";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(zephaniah|zeph|zep)\b/i) != -1) { if (fbook.search(/\b(zephaniah|zeph|zep)\b/i) != -1)
{
thing.book = 36; thing.book = 36;
thing.bookname = "Zephaniah"; thing.bookname = "Zephaniah";
thing.longbookname = "Book_of_Zephaniah"; thing.longbookname = "Book_of_Zephaniah";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(haggia|hag|hg|haggai)\b/i) != -1) { if (fbook.search(/\b(haggia|hag|hg|haggai)\b/i) != -1)
{
thing.book = 37; thing.book = 37;
thing.bookname = "Haggai"; thing.bookname = "Haggai";
thing.longbookname = "Book_of_Haggai"; thing.longbookname = "Book_of_Haggai";
thing.lastchapter = 2; thing.lastchapter = 2;
} }
if (fbook.search(/\b(zechariah|zech|zch|zec)\b/i) != -1) { if (fbook.search(/\b(zechariah|zech|zch|zec)\b/i) != -1)
{
thing.book = 38; thing.book = 38;
thing.bookname = "Zechariah"; thing.bookname = "Zechariah";
thing.longbookname = "Book_of_Zechariah"; thing.longbookname = "Book_of_Zechariah";
thing.lastchapter = 14; thing.lastchapter = 14;
} }
if (fbook.search(/\b(malachi|mal)\b/i) != -1) { if (fbook.search(/\b(malachi|mal)\b/i) != -1)
{
thing.book = 39; thing.book = 39;
thing.bookname = "Malachi"; thing.bookname = "Malachi";
thing.longbookname = "Book_of_Malachi"; thing.longbookname = "Book_of_Malachi";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
if (fbook.search(/\b(matthew|mt|matt|mat)\b/i) != -1) { if (fbook.search(/\b(matthew|mt|matt|mat)\b/i) != -1)
{
thing.book = 40; thing.book = 40;
thing.bookname = "Matthew"; thing.bookname = "Matthew";
thing.longbookname = "Gospel_of_Matthew"; thing.longbookname = "Gospel_of_Matthew";
thing.lastchapter = 28; thing.lastchapter = 28;
} }
if (fbook.search(/\b(mark|mrk|mk|mr)\b/i) != -1) { if (fbook.search(/\b(mark|mrk|mk|mr)\b/i) != -1)
{
thing.book = 41; thing.book = 41;
thing.bookname = "Mark"; thing.bookname = "Mark";
thing.longbookname = "Gospel_of_Mark"; thing.longbookname = "Gospel_of_Mark";
thing.lastchapter = 16; thing.lastchapter = 16;
} }
if (fbook.search(/\b(luke|lu|lke|luk|lk)\b/i) != -1) { if (fbook.search(/\b(luke|lu|lke|luk|lk)\b/i) != -1)
{
thing.book = 42; thing.book = 42;
thing.bookname = "Luke"; thing.bookname = "Luke";
thing.longbookname = "Gospel_of_Luke"; thing.longbookname = "Gospel_of_Luke";
thing.lastchapter = 24; thing.lastchapter = 24;
} }
if (fbook.search(/\b(john|jn|jhn)\b/i) != -1) { if (fbook.search(/\b(john|jn|jhn)\b/i) != -1)
{
thing.book = 43; thing.book = 43;
thing.bookname = "John"; thing.bookname = "John";
thing.longbookname = "Gospel_of_John"; thing.longbookname = "Gospel_of_John";
thing.lastchapter = 21; thing.lastchapter = 21;
} }
if (fbook.search(/\b(acts|ac|act)\b/i) != -1) { if (fbook.search(/\b(acts|ac|act)\b/i) != -1)
{
thing.book = 44; thing.book = 44;
thing.bookname = "Acts"; thing.bookname = "Acts";
thing.longbookname = "Acts_of_the_Apostles"; thing.longbookname = "Acts_of_the_Apostles";
thing.lastchapter = 28; thing.lastchapter = 28;
} }
if (fbook.search(/\b(romans|rom|ro|rm|roman)\b/i) != -1) { if (fbook.search(/\b(romans|rom|ro|rm|roman)\b/i) != -1)
{
thing.book = 45; thing.book = 45;
thing.bookname = "Romans"; thing.bookname = "Romans";
thing.longbookname = "Epistle_to_the_Romans"; thing.longbookname = "Epistle_to_the_Romans";
thing.lastchapter = 16; thing.lastchapter = 16;
} }
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)
{
thing.book = 46; thing.book = 46;
thing.bookname = "1 Corinthians"; thing.bookname = "1 Corinthians";
thing.longbookname = "First_Epistle_to_the_Corinthians"; thing.longbookname = "First_Epistle_to_the_Corinthians";
thing.lastchapter = 16; thing.lastchapter = 16;
} }
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)
{
thing.book = 47; thing.book = 47;
thing.bookname = "2 Corinthians"; thing.bookname = "2 Corinthians";
thing.longbookname = "Second_Epistle_to_the_Corinthians"; thing.longbookname = "Second_Epistle_to_the_Corinthians";
thing.lastchapter = 13; thing.lastchapter = 13;
} }
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)
{
thing.book = 48; thing.book = 48;
thing.bookname = "Galatians"; thing.bookname = "Galatians";
thing.longbookname = "Epistle_to_the_Galatians"; thing.longbookname = "Epistle_to_the_Galatians";
thing.lastchapter = 6; thing.lastchapter = 6;
} }
if (fbook.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) != -1) { if (fbook.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) != -1)
{
thing.book = 49; thing.book = 49;
thing.bookname = "Ephesians"; thing.bookname = "Ephesians";
thing.longbookname = "Epistle_to_the_Ephesians"; thing.longbookname = "Epistle_to_the_Ephesians";
thing.lastchapter = 6; thing.lastchapter = 6;
} }
if (fbook.search(/\b(philippians|phi|phil|ph|philip)\b/i) != -1) { if (fbook.search(/\b(philippians|phi|phil|ph|philip)\b/i) != -1)
{
thing.book = 50; thing.book = 50;
thing.bookname = "Philippians"; thing.bookname = "Philippians";
thing.longbookname = "Epistle_to_the_Philippians"; thing.longbookname = "Epistle_to_the_Philippians";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
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)
{
thing.book = 51; thing.book = 51;
thing.bookname = "Colossians"; thing.bookname = "Colossians";
thing.longbookname = "Epistle_to_the_Colossians"; thing.longbookname = "Epistle_to_the_Colossians";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
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)
{
thing.book = 52; thing.book = 52;
thing.bookname = "1 Thessalonians"; thing.bookname = "1 Thessalonians";
thing.longbookname = "First_Epistle_to_the_Thessalonians"; thing.longbookname = "First_Epistle_to_the_Thessalonians";
thing.lastchapter = 5; thing.lastchapter = 5;
} }
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)
{
thing.book = 53; thing.book = 53;
thing.bookname = "2 Thessalonians"; thing.bookname = "2 Thessalonians";
thing.longbookname = "Second_Epistle_to_the_Thessalonians"; thing.longbookname = "Second_Epistle_to_the_Thessalonians";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
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)
{
thing.book = 54; thing.book = 54;
thing.bookname = "1 Timothy"; thing.bookname = "1 Timothy";
thing.longbookname = "First_Epistle_to_Timothy"; thing.longbookname = "First_Epistle_to_Timothy";
thing.lastchapter = 6; thing.lastchapter = 6;
} }
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)
{
thing.book = 55; thing.book = 55;
thing.bookname = "2 Timothy"; thing.bookname = "2 Timothy";
thing.longbookname = "Second_Epistle_to_Timothy"; thing.longbookname = "Second_Epistle_to_Timothy";
thing.lastchapter = 4; thing.lastchapter = 4;
} }
if (fbook.search(/\b(titus|tit)\b/i) != -1) { if (fbook.search(/\b(titus|tit)\b/i) != -1)
{
thing.book = 56; thing.book = 56;
thing.bookname = "Titus"; thing.bookname = "Titus";
thing.longbookname = "Epistle_to_Titus"; thing.longbookname = "Epistle_to_Titus";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(philemon|phlmn|phl|phm|phile|philem)\b/i) != -1) { if (fbook.search(/\b(philemon|phlmn|phl|phm|phile|philem)\b/i) != -1)
{
thing.book = 57; thing.book = 57;
thing.bookname = "Philemon"; thing.bookname = "Philemon";
thing.longbookname = "Epistle_to_Philemon"; thing.longbookname = "Epistle_to_Philemon";
thing.lastchapter = 1; thing.lastchapter = 1;
} }
if (fbook.search(/\b(hebrews|heb|he|hebrew)\b/i) != -1) { if (fbook.search(/\b(hebrews|heb|he|hebrew)\b/i) != -1)
{
thing.book = 58; thing.book = 58;
thing.bookname = "Hebrews"; thing.bookname = "Hebrews";
thing.longbookname = "Epistle_to_the_Hebrews"; thing.longbookname = "Epistle_to_the_Hebrews";
thing.lastchapter = 13; thing.lastchapter = 13;
} }
if (fbook.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) != -1) { if (fbook.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) != -1)
{
thing.book = 59; thing.book = 59;
thing.bookname = "James"; thing.bookname = "James";
thing.longbookname = "Epistle_of_James"; thing.longbookname = "Epistle_of_James";
thing.lastchapter = 5; thing.lastchapter = 5;
} }
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)
{
thing.book = 60; thing.book = 60;
thing.bookname = "1 Peter"; thing.bookname = "1 Peter";
thing.longbookname = "First_Epistle_of_Peter"; thing.longbookname = "First_Epistle_of_Peter";
thing.lastchapter = 5; thing.lastchapter = 5;
} }
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)
{
thing.book = 61; thing.book = 61;
thing.bookname = "2 Peter"; thing.bookname = "2 Peter";
thing.longbookname = "Second_Epistle_of_Peter"; thing.longbookname = "Second_Epistle_of_Peter";
thing.lastchapter = 3; thing.lastchapter = 3;
} }
if (fbook.search(/\b(1|i|1st|first)\s*(john|jn|jo)\b/i) != -1) { if (fbook.search(/\b(1|i|1st|first)\s*(john|jn|jo)\b/i) != -1)
{
thing.book = 62; thing.book = 62;
thing.bookname = "1 John"; thing.bookname = "1 John";
thing.longbookname = "First_Epistle_of_John"; thing.longbookname = "First_Epistle_of_John";
thing.lastchapter = 5; thing.lastchapter = 5;
} }
if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(john|jn|jo)\b/i) != -1) { if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(john|jn|jo)\b/i) != -1)
{
thing.book = 63; thing.book = 63;
thing.bookname = "2 John"; thing.bookname = "2 John";
thing.longbookname = "Second_Epistle_of_John"; thing.longbookname = "Second_Epistle_of_John";
thing.lastchapter = 1; thing.lastchapter = 1;
} }
if (fbook.search(/\b(3|iii|3rd|third)\s*(john|jn|jo)\b/i) != -1) { if (fbook.search(/\b(3|iii|3rd|third)\s*(john|jn|jo)\b/i) != -1)
{
thing.book = 64; thing.book = 64;
thing.bookname = "3 John"; thing.bookname = "3 John";
thing.longbookname = "Third_Epistle_of_John"; thing.longbookname = "Third_Epistle_of_John";
thing.lastchapter = 1; thing.lastchapter = 1;
} }
if (fbook.search(/\b(jude|ju)\b/i) != -1) { if (fbook.search(/\b(jude|ju)\b/i) != -1)
{
thing.book = 65; thing.book = 65;
thing.bookname = "Jude"; thing.bookname = "Jude";
thing.longbookname = "Epistle_of_Jude"; thing.longbookname = "Epistle_of_Jude";
thing.lastchapter = 1; thing.lastchapter = 1;
} }
if (fbook.search(/\b(revelation|rev|re|revelations|rv)\b/i) != -1) { if (fbook.search(/\b(revelation|rev|re|revelations|rv)\b/i) != -1)
{
thing.book = 66; thing.book = 66;
thing.bookname = "Revelation"; thing.bookname = "Revelation";
thing.longbookname = "Book_of_Revelations"; thing.longbookname = "Book_of_Revelations";
@ -608,7 +716,8 @@ export class Reference {
return thing; return thing;
} }
public static toString(section: Section) { public static toString(section: Section)
{
// get the starting book, chapter, verse // get the starting book, chapter, verse
let ref = section.start.bookname.concat(" "). let ref = section.start.bookname.concat(" ").
concat(section.start.chapter).concat(":"). concat(section.start.chapter).concat(":").
@ -616,20 +725,24 @@ export class Reference {
if (section.start.chapter == section.end.chapter && if (section.start.chapter == section.end.chapter &&
section.start.verse == section.end.verse && section.start.verse == section.end.verse &&
section.start.book == section.end.book) { section.start.book == section.end.book)
{
return ref; return ref;
} }
if (section.start.chapter == section.end.chapter && if (section.start.chapter == section.end.chapter &&
section.start.verse != section.end.verse && section.start.verse != section.end.verse &&
section.start.book == section.end.book) { section.start.book == section.end.book)
{
return ref.concat(" - ").concat(section.end.verse); return ref.concat(" - ").concat(section.end.verse);
} }
if (section.start.book != section.end.book) { if (section.start.book != section.end.book)
{
ref = ref.concat(" - ").concat(section.end.bookname).concat(" "); ref = ref.concat(" - ").concat(section.end.bookname).concat(" ");
} }
else { else
{
ref = ref.concat(" - "); ref = ref.concat(" - ");
} }
@ -638,7 +751,8 @@ export class Reference {
return ref.concat(section.end.verse); return ref.concat(section.end.verse);
} }
public static bookName(booknum: number): string { public static bookName(booknum: number): string
{
let book = new Array(); let book = new Array();
book[0] = ""; book[0] = "";
book[1] = "Genesis"; book[1] = "Genesis";
@ -712,3 +826,22 @@ export class Reference {
} }
} }
export type Section = {
start: {
book: number,
bookname: string,
longbookname: string,
lastchapter: number,
chapter: string,
verse: string
},
end: {
book: number,
bookname: string,
longbookname: string,
lastchapter: number,
chapter: string,
verse: string
}
};

View File

@ -1,9 +1,10 @@
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { CardItem } from "../pages/search/search";
export class UserProfile export class UserProfile
{ {
user: User; user: User;
constructor(u: User) constructor(u: User)
{ {
this.user = u; this.user = u;
@ -48,6 +49,7 @@ export class UserProfile
this.user.append_to_bottom = false; this.user.append_to_bottom = false;
this.user.insert_next_to_item = false; this.user.insert_next_to_item = false;
this.user.font_size = 10; this.user.font_size = 10;
this.user.saved_pages = [];
this.save(local); this.save(local);
} }
@ -59,7 +61,23 @@ export class UserProfile
items: [], items: [],
append_to_bottom: false, append_to_bottom: false,
insert_next_to_item: false, insert_next_to_item: false,
font_size: 10 font_size: 10,
saved_pages: []
}; };
} }
}
export type User = {
strongs_modal: boolean,
clear_search_after_query: boolean,
items: CardItem[],
append_to_bottom: boolean,
insert_next_to_item: boolean,
font_size: number,
saved_pages: SavedPage[]
}
export type SavedPage = {
queries: CardItem[],
title: string
} }

View File

@ -6,30 +6,30 @@
<ion-searchbar (search)="getQuery($event)" (input)="setQuery($event)" [showCancelButton]="true"></ion-searchbar> <ion-searchbar (search)="getQuery($event)" (input)="setQuery($event)" [showCancelButton]="true"></ion-searchbar>
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
<ion-content padding class="search-card"> <ion-content padding class="search-card">
<!--<ion-list [virtualScroll]="userProfile.user.items" no-lines approxItemHeight="200px" bufferRatio="10"> <ion-card>
<div *virtualItem="let item" style="width: 100%"> <ion-grid>
<ion-card> <ion-row>
<passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" [dict]="item.dict" (onStrongsClicked)="getItemsNextToCard($event)"></passage> <ion-col style="width: 95px;">
<strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></strongs> <button ion-button right small (click)="addPage()">
<words *ngIf="isWords(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></words> <ion-icon name="cloud-upload"></ion-icon><div>&nbsp;&nbsp;Save</div>
<button ion-button icon-left clear small (click)="removeItem(item)"> </button>
<ion-icon name="close-circle"></ion-icon> </ion-col>
<div>Close</div> <ion-col style="flex-grow: 100 !important">
</button> <ion-item>
</ion-card> <ion-input type="text" placeholder="Saved Results Title goes here" [(ngModel)]="saved_results_title"></ion-input>
<div style="height:10px"></div> </ion-item>
</div> </ion-col>
</ion-list>-->
</ion-row>
</ion-grid>
</ion-card>
<ion-card *ngFor="let item of userProfile.user.items"> <ion-card *ngFor="let item of userProfile.user.items">
<error *ngIf="isError(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)"></error> <error *ngIf="isError(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)"></error>
<passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" [dict]="item.dict" (onStrongsClicked)="getItemsNextToCard($event)"></passage> <passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" [dict]="item.dict" (onStrongsClicked)="getItemsNextToCard($event)"></passage>
<strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></strongs> <strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></strongs>
<words *ngIf="isWords(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></words> <words *ngIf="isWords(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></words>
<button ion-button icon-left clear small (click)="removeItem(item)">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>
</ion-card> </ion-card>
</ion-content> </ion-content>

View File

@ -4,9 +4,11 @@
line-height: 1em; line-height: 1em;
font-size: 1em; font-size: 1em;
} }
}
.search-card { .button-large-md {
height: 3.6rem !important;
}
.title { .title {
font-size: 1.3em; font-size: 1.3em;
font-family: 'Roboto', Helvetica, Arial, sans-serif; font-family: 'Roboto', Helvetica, Arial, sans-serif;
@ -31,4 +33,7 @@ body {
font-size: 1.2em; font-size: 1.2em;
font-weight: bold; font-weight: bold;
} }
.item-md.item-block .item-inner {padding: 0px;}
.item-md.item-block .item-inner {
padding: 0px;
}

View File

@ -1,40 +1,42 @@
/// <reference path="../../types.ts" /> import { Type, Component } from '@angular/core';
import {Type, Component} from "@angular/core"; import { Loading, LoadingController, ModalController, NavController, MenuController, ViewController, App, NavParams, IonicApp } from 'ionic-angular';
import {Reference} from "../../Reference"; import { Storage } from '@ionic/storage';
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 import { StrongsModal } from '../../components/strongs-modal/strongs-modal';
{
id: number; import { BiblePassageResult, BibleService } from '../../services/bible-service';
data: any; import { StrongsResult, StrongsService } from '../../services/strongs-service';
type: Type<any>; import { WordService } from '../../services/word-service';
dict: string; import { PagesService } from "../../services/pages-service";
}
import { UserProfile } from '../../libs/UserProfile';
import { Reference } from '../../libs/Reference';
import { MyApp } from '../../app/app.component';
@Component({ @Component({
templateUrl: "search.html", templateUrl: 'search.html',
providers: [BibleService, StrongsService, WordService], providers: [BibleService, StrongsService, WordService]
}) })
export class SearchPage export class SearchPage
{ {
searchQuery: string = ""; searchQuery = '';
userProfile: UserProfile; userProfile: UserProfile;
last: CardItem; last: CardItem;
loader: Loading; loader: Loading;
saved_results_title: string = "";
constructor( constructor(
private strongsService: StrongsService private strongsService: StrongsService
, private bibleService: BibleService , private bibleService: BibleService
, private wordService: WordService , private wordService: WordService
, private pagesService: PagesService
, public loadingCtrl: LoadingController , public loadingCtrl: LoadingController
, public modalCtrl: ModalController , public modalCtrl: ModalController
, public local: Storage) , public navCtl: NavController
, public menuCtl: MenuController
, public local: Storage
, public params: NavParams
)
{ {
this.userProfile = new UserProfile(UserProfile.createDefaultUser()); this.userProfile = new UserProfile(UserProfile.createDefaultUser());
@ -53,12 +55,22 @@ export class SearchPage
{ {
console.log(error); console.log(error);
}); });
}
addPage()
{
let p = { queries: this.userProfile.user.items.slice(), title: this.saved_results_title };
this.userProfile.user.saved_pages.push(p);
this.userProfile.save(this.local);
this.pagesService.addPage(p);
} }
initializeItems(u: UserProfile) initializeItems(u: UserProfile)
{ {
this.userProfile = u; this.userProfile = u;
this.pagesService.initializePages(u.user.saved_pages);
if (this.params.data.queries !== undefined)
this.userProfile.user.items = this.params.data.queries.slice();
} }
presentStrongsModal(strongs: StrongsResult) presentStrongsModal(strongs: StrongsResult)
@ -87,19 +99,19 @@ export class SearchPage
isError(t: string) isError(t: string)
{ {
return t === "Error"; return t === 'Error';
} }
isPassage(t: string) isPassage(t: string)
{ {
return t === "Passage"; return t === 'Passage';
} }
isStrongs(t: string) isStrongs(t: string)
{ {
return t === "Strongs"; return t === 'Strongs';
} }
isWords(t: string) isWords(t: string)
{ {
return t === "Words"; return t === 'Words';
} }
addItemToList(item) addItemToList(item)
@ -133,33 +145,32 @@ export class SearchPage
this.getItems(data.qry); this.getItems(data.qry);
} }
getItems(search) getItems(search)
{ {
this.loader = this.loadingCtrl.create({ this.loader = this.loadingCtrl.create({
content: "Looking up query..." content: 'Looking up query...'
}); });
this.loader.present().then( this.loader.present().then(
() => () =>
{ {
try try
{ {
let qs = search.split(";"); let qs = search.split(';');
for (let x in qs) for (let x in qs)
{ {
if (qs.hasOwnProperty(x)) if (qs.hasOwnProperty(x))
{ {
let q = qs[x].trim(); let q = qs[x].trim();
if (q !== "") if (q !== '')
{ {
// its a search term. // its a search term.
if (q.search(/[0-9]/i) === -1) if (q.search(/[0-9]/i) === -1)
{ {
let result = this.wordService.getResult(q); let result = this.wordService.getResult(q);
if (result.status == 0) if (result.status === 0)
this.addItemToList({ data: result, type: "Words", dict: "na" }); this.addItemToList({ data: result, type: 'Words', dict: 'na' });
else else
this.addItemToList({ data: result.msg, type: "Error", dict: "na" }); this.addItemToList({ data: result.msg, type: 'Error', dict: 'na' });
} }
else if (q.search(/(H|G)[0-9]/i) !== -1) else if (q.search(/(H|G)[0-9]/i) !== -1)
{ {
@ -168,48 +179,48 @@ export class SearchPage
if (dict.search(/h/i) !== -1) if (dict.search(/h/i) !== -1)
{ {
dict = "heb"; dict = 'heb';
} else } else
{ {
dict = "grk"; dict = 'grk';
} }
q = q.substring(1, q.length); q = q.substring(1, q.length);
let result = this.strongsService.getResult(parseInt(q), dict); let result = this.strongsService.getResult(parseInt(q), dict);
if (result.status == -1) if (result.status === -1)
this.addItemToList({ data: result.msg, type: "Error", dict: "na" }); this.addItemToList({ data: result.msg, type: 'Error', dict: 'na' });
else else
{ {
if (this.userProfile.user.strongs_modal) if (this.userProfile.user.strongs_modal)
this.presentStrongsModal(result); this.presentStrongsModal(result);
else else
this.addItemToList({ data: result, type: "Strongs", dict: "na" }); this.addItemToList({ data: result, type: 'Strongs', dict: 'na' });
} }
} }
else else
{ {
// its a verse reference. // its a verse reference.
if (q.trim() !== "") if (q.trim() !== '')
{ {
let myref = new Reference(q.trim()); let myref = new Reference(q.trim());
let r = this.bibleService.getResult(myref.Section); let r = this.bibleService.getResult(myref.Section);
r.ref = myref.toString(); r.ref = myref.toString();
if (r.status == 0) if (r.status === 0)
this.addItemToList({ data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" }); this.addItemToList({ data: r, type: 'Passage', dict: r.testament === 'new' ? 'G' : 'H' });
else else
this.addItemToList({ data: r.msg, type: "Error", dict: "na" }); this.addItemToList({ data: r.msg, type: 'Error', dict: 'na' });
} }
} }
} }
} }
} }
if (this.userProfile.user.clear_search_after_query) if (this.userProfile.user.clear_search_after_query)
$(".searchbar-input").val(""); $('.searchbar-input').val('');
this.userProfile.save(this.local); this.userProfile.save(this.local);
} }
catch (error) catch (error)
{ {
this.addItemToList({ data: error, type: "Error", dict: "na" }); this.addItemToList({ data: error, type: 'Error', dict: 'na' });
console.log(error); console.log(error);
} }
finally finally
@ -220,3 +231,15 @@ export class SearchPage
); );
} }
} }
export type OpenData = { card: CardItem, qry: string }
export type CardItem = { data: any, type: string, dict: string }
class Item
{
id: number;
data: any;
type: Type<any>;
dict: string;
}

View File

@ -38,5 +38,15 @@
<ion-item> <ion-item>
<button ion-button (click)="reset()">Reset Settings</button> <button ion-button (click)="reset()">Reset Settings</button>
</ion-item> </ion-item>
<ion-list>
<ion-list-header>Manage Pages</ion-list-header>
<div *ngFor="let p of userProfile.user.saved_pages">
<ion-item>
{{p.title}}
<button ion-button round (click)="removePage(p)"><ion-icon name="trash"></ion-icon></button>
</ion-item>
</div>
</ion-list>
</template> </template>
</ion-content> </ion-content>

View File

@ -1,9 +1,8 @@
/// <reference path="../../types.ts" />
/// <reference path="../../../typings/browser/ambient/jquery/index.d.ts" /> /// <reference path="../../../typings/browser/ambient/jquery/index.d.ts" />
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { NavController } from 'ionic-angular'; import { NavController } from 'ionic-angular';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { UserProfile } from '../../UserProfile'; import { SavedPage, UserProfile } from '../../libs/UserProfile';
@Component({ @Component({
selector: 'settings', selector: 'settings',
@ -48,4 +47,13 @@ export class SettingsPage
{ {
this.userProfile.reset(this.local); this.userProfile.reset(this.local);
} }
removePage(page: SavedPage)
{
let idx = this.userProfile.user.saved_pages.indexOf(page);
this.userProfile.user.saved_pages.splice(idx, 1);
// save the users settings.
this.userProfile.save(this.local);
}
} }

View File

@ -1,5 +1,5 @@
import {getTestBed, TestBed, inject} from '@angular/core/testing'; import {getTestBed, TestBed} from '@angular/core/testing';
import {XHRBackend, BaseRequestOptions, HttpModule, Http,} from '@angular/http'; import {BaseRequestOptions, HttpModule, Http,} from '@angular/http';
import {MockBackend} from '@angular/http/testing'; import {MockBackend} from '@angular/http/testing';
import {BibleService} from './bible-service'; import {BibleService} from './bible-service';
import {Reference} from './Reference'; import {Reference} from './Reference';

View File

@ -1,8 +1,7 @@
/// <reference path="../typings/browser/ambient/jquery/index.d.ts" /> /// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
/// <reference path="types.ts" />
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { Http } from "@angular/http"; import { Http } from "@angular/http";
import { Reference } from "./Reference"; import { Section, Reference } from "../libs/Reference";
@Injectable() @Injectable()
export class BibleService export class BibleService
@ -15,7 +14,7 @@ export class BibleService
constructor(private http: Http) constructor(private http: Http)
{ {
} }
getResult(section: Section): BiblePassageResult getResult(section: Section): BiblePassageResult
{ {
try try
@ -34,7 +33,7 @@ export class BibleService
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++) for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++)
{ {
const url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json"; const url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
$.ajax({ $.ajax({
async: false, async: false,
type: "GET", type: "GET",
@ -92,13 +91,35 @@ export class BibleService
this.result.testament = "new"; this.result.testament = "new";
else else
this.result.testament = "old"; this.result.testament = "old";
return this.result; return this.result;
} }
catch (error) catch (error)
{ {
console.log(error); console.log(error);
} }
return null; return null;
} }
}
export type BiblePassageResult = {
cs: BiblePassage[],
testament: string,
ref: string,
status: number,
msg: string
}
type BiblePassage = {
ch: number,
vss: BibleVerse[]
}
type BibleVerse = {
v: number,
w: [
{
t: string, s: string
}
]
} }

View File

@ -0,0 +1,42 @@
import { Injectable } from "@angular/core";
import { Storage } from '@ionic/storage';
import { SearchPage } from "../pages/search/search";
import { SettingsPage } from "../pages/settings/settings";
import { SavedPage } from "../libs/UserProfile";
@Injectable()
export class PagesService
{
pages: Array<{ title: string, component: any, params: any }>;
constructor(public local: Storage)
{
this.pages = [
{ title: 'Search', component: SearchPage, params: { queries: []} },
{ title: 'Settings', component: SettingsPage, params: {} }
];
}
getResult(): Array<{ title: string, component: any }>
{
return this.pages;
}
addPage(page: SavedPage)
{
this.pages.push({ title: page.title, component: SearchPage, params: { queries: page.queries } });
}
initializePages(page_array: SavedPage[])
{
this.pages = [
{ title: 'Search', component: SearchPage, params: { queries: [] } },
{ title: 'Settings', component: SettingsPage, params: {} }
];
for (let p of page_array)
{
this.pages.push({ title: p.title, component: SearchPage, params: { queries: p.queries } });
}
}
}

View File

@ -1,17 +1,19 @@
/// <reference path="../typings/browser/ambient/jquery/index.d.ts" /> /// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
/// <reference path="types.ts" />
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { Http } from "@angular/http"; import { Http } from "@angular/http";
@Injectable() @Injectable()
export class StrongsService { export class StrongsService
{
result: StrongsResult; result: StrongsResult;
count = 0; count = 0;
constructor(private http: Http) { constructor(private http: Http)
{
} }
getResult(sn: number, dict: string): StrongsResult { getResult(sn: number, dict: string): StrongsResult
{
const self = this; const self = this;
this.result = { this.result = {
prefix: "", prefix: "",
@ -25,15 +27,20 @@ export class StrongsService {
msg: ":)" msg: ":)"
}; };
let url = dict + Math.ceil(sn / 100) + ".json"; let url = dict + Math.ceil(sn / 100) + ".json";
if (dict === "grk") { if (dict === "grk")
{
self.result.prefix = "G"; self.result.prefix = "G";
if (sn > 5624 || sn < 1) { if (sn > 5624 || sn < 1)
{
self.result.status = -1; self.result.status = -1;
self.result.msg = "Strongs Number G" + sn + " is out of range."; self.result.msg = "Strongs Number G" + sn + " is out of range.";
} }
} else { }
else
{
self.result.prefix = "H"; self.result.prefix = "H";
if (sn > 8674 || sn < 1) { if (sn > 8674 || sn < 1)
{
self.result.status = -1; self.result.status = -1;
self.result.msg = "Strongs Number H" + sn + " is out of range."; self.result.msg = "Strongs Number H" + sn + " is out of range.";
} }
@ -48,10 +55,12 @@ export class StrongsService {
type: "GET", type: "GET",
url: "data/strongs/" + url, url: "data/strongs/" + url,
dataType: "json", dataType: "json",
success: function (d: StrongsDefinition[], t, x) { success: function (d: StrongsDefinition[], t, x)
{
self.result.strongs = d; self.result.strongs = d;
}, },
error: function (request, status, error) { error: function (request, status, error)
{
console.log(error); console.log(error);
self.result.status = -1; self.result.status = -1;
self.result.msg = "Unable to retrieve Strongs Data for " + self.result.prefix + self.result.sn; self.result.msg = "Unable to retrieve Strongs Data for " + self.result.prefix + self.result.sn;
@ -69,15 +78,19 @@ export class StrongsService {
type: "GET", type: "GET",
url: "data/strongscr/cr" + url, url: "data/strongscr/cr" + url,
dataType: "json", dataType: "json",
success: function (d: StrongsCrossReference[], t, x) { success: function (d: StrongsCrossReference[], t, x)
for (let cr of d) { {
if (cr.id.toUpperCase() == self.result.prefix + self.result.sn) { for (let cr of d)
{
if (cr.id.toUpperCase() == self.result.prefix + self.result.sn)
{
self.result.crossrefs = cr; self.result.crossrefs = cr;
break; break;
} }
} }
}, },
error: function (request, status, error) { error: function (request, status, error)
{
console.log(error); console.log(error);
self.result.status = -1; self.result.status = -1;
self.result.msg = "Unable to retrieve Strongs Cross References for " + self.result.prefix + self.result.sn; self.result.msg = "Unable to retrieve Strongs Cross References for " + self.result.prefix + self.result.sn;
@ -87,7 +100,8 @@ export class StrongsService {
if (self.result.status === -1) if (self.result.status === -1)
return self.result; return self.result;
if (dict === "grk") { if (dict === "grk")
{
url = "data/rmac/rs" + (Math.ceil(sn / 1000)) + ".json"; url = "data/rmac/rs" + (Math.ceil(sn / 1000)) + ".json";
let rmac_cross_references: RMACCrossReference[]; let rmac_cross_references: RMACCrossReference[];
@ -97,36 +111,43 @@ export class StrongsService {
type: "GET", type: "GET",
url: url, url: url,
dataType: "json", dataType: "json",
success: function (d: RMACCrossReference[], t, x) { success: function (d: RMACCrossReference[], t, x)
{
rmac_cross_references = d; rmac_cross_references = d;
}, },
error: function (request, status, error) { error: function (request, status, error)
{
console.log(error); console.log(error);
} }
}); });
// deal with RMAC // deal with RMAC
let tmp = $.grep<RMACCrossReference>(rmac_cross_references, (el, i) => { if (el.i == sn + "") { return true; } else { return false; } }); let tmp = $.grep<RMACCrossReference>(rmac_cross_references, (el, i) => { return el.i == sn + "" ? true : false; });
if (tmp.length == 0) if (tmp.length == 0)
return this.result; return this.result;
this.result.rmaccode = tmp[0].r; this.result.rmaccode = tmp[0].r;
if (this.result.rmaccode != undefined) { if (this.result.rmaccode != undefined)
{
url = `data/rmac/r-${this.result.rmaccode.substring(0, 1)}.json`; url = `data/rmac/r-${this.result.rmaccode.substring(0, 1)}.json`;
$.ajax({ $.ajax({
async: false, async: false,
type: "GET", type: "GET",
url: url, url: url,
dataType: "json", dataType: "json",
success: function (d: RMACDefinition[], t, x) { success: function (d: RMACDefinition[], t, x)
for (let rmac of d) { {
if (rmac.id.toLowerCase() == self.result.rmaccode) { for (let rmac of d)
{
if (rmac.id.toLowerCase() == self.result.rmaccode)
{
self.result.rmac = rmac; self.result.rmac = rmac;
break; break;
} }
} }
}, },
error: function (request, status, error) { error: function (request, status, error)
{
console.log(error); console.log(error);
} }
}); });
@ -134,4 +155,37 @@ export class StrongsService {
} }
return this.result; return this.result;
} }
} }
export type StrongsResult =
{
prefix: string,
sn: number,
strongs: StrongsDefinition[],
def: StrongsDefinition,
rmac: RMACDefinition,
crossrefs: StrongsCrossReference,
rmaccode: string,
status: number,
msg: string
};
type StrongsDefinition = { n: number, i: string, tr: string, de: string, lemma: string, p: string }
type StrongsCrossReference =
{
id: string, // strongs id H1|G1
t: string, // strongs testament grk|heb
d: string, // strongs word/data Aaron {ah-ar-ohn'}
ss: [
{
w: string,
rs: [
{ r: string }
]
}
]
}
type RMACDefinition = { id: string, d: string[] }
type RMACCrossReference = { i: string, r: string }

View File

@ -1,5 +1,4 @@
/// <reference path="../typings/browser/ambient/jquery/index.d.ts" /> /// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
/// <reference path="types.ts" />
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { Http } from "@angular/http"; import { Http } from "@angular/http";
@ -34,7 +33,7 @@ export class WordService
results.unshift(this.getSearchReferences("data/index/" + words[w] + "idx.json", q)); results.unshift(this.getSearchReferences("data/index/" + words[w] + "idx.json", q));
break; break;
} }
} }
else else
{ {
if (q <= words[w] && q > words[w - 1]) if (q <= words[w] && q > words[w - 1])
@ -444,4 +443,16 @@ export class WordService
// are identical. // are identical.
return x; return x;
} }
}
export type WordLookupResult = {
refs: string[],
word: string,
status: number,
msg: string
}
type IndexResult = {
refs: string[];
word: string;
} }

View File

@ -1,97 +0,0 @@
type OpenData = {
card: CardItem,
qry: string
}
type WordLookupResult = {
refs: string[],
word: string,
status: number,
msg: string
}
type IndexResult = {
refs: string[];
word: string;
}
type CardItem = { data: any, type: string, dict: string }
type User = {
strongs_modal: boolean,
clear_search_after_query: boolean,
items: CardItem[],
append_to_bottom: boolean,
insert_next_to_item: boolean,
font_size: number
}
type BiblePassage = {
ch: number,
vss: BibleVerse[]
}
type BibleVerse = {
v: number,
w: [
{
t: string, s: string
}
]
}
type BiblePassageResult = {
cs: BiblePassage[],
testament: string,
ref: string,
status: number,
msg: string
}
type StrongsDefinition = { n: number, i: string, tr: string, de: string, lemma: string, p: string }
type StrongsCrossReference =
{
id: string, // strongs id H1|G1
t: string, // strongs testament grk|heb
d: string, // strongs word/data Aaron {ah-ar-ohn'}
ss: [
{
w: string,
rs: [
{ r: string }
]
}
]
}
type RMACDefinition = { id: string, d: string[] }
type RMACCrossReference = { i: string, r: string }
type StrongsResult =
{
prefix: string,
sn: number,
strongs: StrongsDefinition[],
def: StrongsDefinition,
rmac: RMACDefinition,
crossrefs: StrongsCrossReference,
rmaccode: string,
status: number,
msg: string
};
type Section = {
start: {
book: number,
bookname: string,
longbookname: string,
lastchapter: number,
chapter: string,
verse: string
},
end: {
book: number,
bookname: string,
longbookname: string,
lastchapter: number,
chapter: string,
verse: string
}
};