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/.idea
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="SplashScreenDelay" value="12000"/>
<preference name="ShowSplashScreen" value="true"/>
<preference name="AutoHideSplashScreen" value="true"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="SplashShowOnlyFirstTime" value="false"/>
<preference name="FadeSplashScreen" value="false"/>
<feature name="SplashScreen">

Binary file not shown.

View File

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

View File

@ -8,7 +8,7 @@
<ion-content>
<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}}
</button>
</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 { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
@ -6,15 +6,15 @@ import { Storage } from '@ionic/storage';
import { MyApp } from './app.component';
import {SearchPage} from "../pages/search/search";
import {SettingsPage} from "../pages/settings/settings";
import { SearchPage } from "../pages/search/search";
import { SettingsPage } from "../pages/settings/settings";
import {ComponentLoader} from "../components/component-loader/component-loader";
import {Passage} from "../components/passage/passage";
import {Strongs} from "../components/strongs/strongs";
import {Words} from "../components/words/words";
import {Error} from "../components/error/error";
import {StrongsModal} from "../components/strongs-modal/strongs-modal";
import { ComponentLoader } from "../components/component-loader/component-loader";
import { Passage } from "../components/passage/passage";
import { Strongs } from "../components/strongs/strongs";
import { Words } from "../components/words/words";
import { Error } from "../components/error/error";
import { StrongsModal } from "../components/strongs-modal/strongs-modal";
@NgModule({
declarations: [
@ -45,4 +45,4 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal";
],
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);
this.cmpRef = this.target.createComponent(factory)
this.cmpRef = this.target.createComponent(factory);
// to access the created instance use
// this.compRef.instance.someProperty = 'someValue';
// this.compRef.instance.someOutput.subscribe(val => doSomething());

View File

@ -7,4 +7,8 @@
<ion-card-content>
<br>
<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 { CardItem } from "../../pages/search/search";
@Component({
selector: "error",

View File

@ -1,4 +1,4 @@
<ion-item class="title passage-title">
<ion-item class="title passage-title">
{{item.ref}}
<button ion-button icon-only item-right large clear (click)="close()">
<ion-icon name="close-circle"></ion-icon>
@ -6,11 +6,23 @@
</ion-item>
<ion-card-content>
<br>
<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>
<span *ngFor="let vs of ch.vss"><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>
<span *ngFor="let vs of ch.vss">
<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>
</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;
}
passage .passage-text {
margin-bottom: 10px;
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 {
-webkit-column-count: 2; /* Chrome, Safari, Opera */
-moz-column-count: 2; /* Firefox */
@ -16,16 +21,16 @@ passage .passage-text {
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */
column-gap: 30px;
-webkit-column-rule-style: solid; /* Chrome, Safari, Opera */
-moz-column-rule-style: solid; /* Firefox */
column-rule-style: solid;
-webkit-column-rule-style: dotted; /* Chrome, Safari, Opera */
-moz-column-rule-style: dotted; /* Firefox */
column-rule-style: dotted;
-webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */
-moz-column-rule-width: 1px; /* Firefox */
column-rule-width: 1px;
}
}
@media screen and (min-width: 850px) {
@media screen and (min-width: 950px) {
passage .passage-text {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
@ -33,9 +38,9 @@ passage .passage-text {
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */
column-gap: 30px;
-webkit-column-rule-style: solid; /* Chrome, Safari, Opera */
-moz-column-rule-style: solid; /* Firefox */
column-rule-style: solid;
-webkit-column-rule-style: dotted; /* Chrome, Safari, Opera */
-moz-column-rule-style: dotted; /* Firefox */
column-rule-style: dotted;
-webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */
-moz-column-rule-width: 1px; /* Firefox */
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({
selector: "passage",
templateUrl: "passage.html"
})
export class Passage {
export class Passage
{
@Output()
onStrongsClicked = new EventEmitter<OpenData>();
@Output()
@ -18,18 +22,23 @@ export class Passage {
@Input()
cardItem: CardItem;
constructor() {
constructor()
{
}
close() {
close()
{
this.onClose.emit(this.cardItem);
}
openStrongs(strongs: string) {
openStrongs(strongs: string)
{
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)
}
}

View File

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

View File

@ -32,4 +32,8 @@
</dl>
</ion-scroll>
</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;
}

View File

@ -1,11 +1,14 @@
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({
selector: "strongs",
templateUrl: "strongs.html"
})
export class Strongs {
export class Strongs
{
@Output()
onClose = new EventEmitter<CardItem>();
@ -18,18 +21,21 @@ export class Strongs {
@Input()
cardItem: CardItem;
constructor() {
constructor()
{
}
close()
{
this.onClose.emit(this.cardItem);
}
makePassage(p: string) {
makePassage(p: string)
{
return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2];
}
openPassage(p: string) {
openPassage(p: string)
{
let ref = this.makePassage(p);
this.onPassageClicked.emit({ card: this.cardItem, qry: ref });
}
}
}

View File

@ -8,4 +8,8 @@
<ion-scroll scrollY="true" overflow-scroll="true">
<a class="passage-button" *ngFor="let ref of item.refs" (click)="openPassage(ref)">{{makePassage(ref)}}</a>
</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 {
.button-clear-md {
color: #632761;
}
.words-title {
background-color: #f5b9f3;
}

View File

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

View File

@ -3,28 +3,33 @@
// Jason@walljm.com // www.walljm.com
// Jeremy@marzhillstudios.com // jeremy.marzhillstudios.com
/// <reference path="types.ts"/>
class StringUtils {
public static trim(str: string): string {
class StringUtils
{
public static trim(str: string): string
{
return str.replace(/^\s+|\s+$/g, "");
}
public static ltrim(str: string): string {
public static ltrim(str: string): string
{
return str.replace(/^\s+/, "");
}
public static rtrim(str: string): string {
public static rtrim(str: string): string
{
return str.replace(/\s+$/, "");
}
}
export class Reference {
export class Reference
{
private ref: string;
public Section: Section;
public errAcc: string;
constructor(reference: string) {
constructor(reference: string)
{
this.Section = {
start: {
book: -1,
@ -46,7 +51,8 @@ export class Reference {
this.ref = reference.toLowerCase().trim();
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.bookname = this.Section.start.bookname;
this.Section.end.longbookname = this.Section.start.longbookname;
@ -63,7 +69,8 @@ export class Reference {
if (this.Section.end.verse == "") this.Section.end.verse = "*";
}
private parseReference() {
private parseReference()
{
this.parseBook(false);
this.parseFirstNum(false);
let foundFirstVerse = this.ref.search(/:.*-/) != -1;
@ -76,7 +83,8 @@ export class Reference {
this.maybeParseSecondNum(true);
};
private parseBook(isEnd?: boolean) {
private parseBook(isEnd?: boolean)
{
this.ref = this.ref.toLowerCase().trim();
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);
}
private parseFirstNum(isEnd: boolean) {
private parseFirstNum(isEnd: boolean)
{
let thing = this.Section.start;
if (isEnd) thing = this.Section.end;
this.ref = StringUtils.ltrim(this.ref);
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);
// 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;
thing.chapter = thing.chapter.concat(c);
} else {
}
else
{
// 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 + "\".";
return;
} else if (!found) {
}
else if (!found)
{
this.errAcc = "No chapter found" + this.ref;
}
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;
if (isEnd) thing = this.Section.end;
this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (!skipColon) {
if (this.ref[0] != ":") {
if (!skipColon)
{
if (this.ref[0] != ":")
{
return;
}
this.ref = this.ref.slice(1);
}
this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (this.ref[0] == "*") {
if (this.ref[0] == "*")
{
thing.verse = "*";
this.ref = this.ref.slice(1);
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);
if ("0".charAt(0) <= c && c <= "9".charAt(0)) {
if ("0".charAt(0) <= c && c <= "9".charAt(0))
{
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 + "\".";
return "";
}
@ -145,31 +170,41 @@ export class Reference {
}
}
private maybeParseBook(isEnd: boolean) {
return this.maybeDo(() => {
if (this.ref.search(/\w\s+\d/i) == -1) {
private maybeParseBook(isEnd: boolean)
{
return this.maybeDo(() =>
{
if (this.ref.search(/\w\s+\d/i) == -1)
{
this.Section.end.book = this.Section.start.book;
this.Section.end.bookname = this.Section.start.bookname;
this.Section.end.longbookname = this.Section.start.longbookname;
this.Section.end.lastchapter = this.Section.start.lastchapter;
}
else {
else
{
this.parseBook(isEnd)
}
});
};
private maybeParseSecondNum(isEnd?: boolean) {
return this.maybeDo(() => {
private maybeParseSecondNum(isEnd?: boolean)
{
return this.maybeDo(() =>
{
this.parseSecondNum(false, isEnd);
});
};
private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean) {
private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean)
{
let self = this;
return this.maybeDo(() => {
if (self.Section.end.book == self.Section.start.book) {
if (self.ref.search(/:/) != -1 || foundSecondBook || !foundFirstVerse) {
return this.maybeDo(() =>
{
if (self.Section.end.book == self.Section.start.book)
{
if (self.ref.search(/:/) != -1 || foundSecondBook || !foundFirstVerse)
{
self.parseFirstNum(isEnd);
}
self.parseSecondNum(true, isEnd);
@ -177,29 +212,36 @@ export class Reference {
});
};
private maybeParseRangeSep() {
private maybeParseRangeSep()
{
let self = this;
return this.maybeDo(() => {
if (self.ref[0] == "-") {
return this.maybeDo(() =>
{
if (self.ref[0] == "-")
{
self.ref = StringUtils.ltrim(self.ref.slice(1));
}
});
};
private maybeDo(f) {
private maybeDo(f)
{
let func = f;
this.ref = StringUtils.ltrim(this.ref.toLowerCase());
if (this.ref != "") {
if (this.ref != "")
{
func();
}
};
public toString() {
public toString()
{
// get the starting book, chapter, verse
return Reference.toString(this.Section);
};
public static parseBook(fbook: string) {
public static parseBook(fbook: string)
{
let thing = {
book: 0,
bookname: "",
@ -208,397 +250,463 @@ export class Reference {
chapter: "",
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.bookname = "Genesis";
thing.longbookname = "Genesis";
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.bookname = "Exodus";
thing.longbookname = "Exodus";
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.bookname = "Leviticus";
thing.longbookname = "Leviticus";
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.bookname = "Numbers";
thing.longbookname = "Book_of_Numbers";
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.bookname = "Deuteronomy";
thing.longbookname = "Deuteronomy";
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.bookname = "Joshua";
thing.longbookname = "Book_of_Joshua";
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.bookname = "Judges";
thing.longbookname = "Book_of_Judges";
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.bookname = "Ruth";
thing.longbookname = "Book_of_Ruth";
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.bookname = "1 Samuel";
thing.longbookname = "First_Samuel";
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.bookname = "2 Samuel";
thing.longbookname = "Second_Samuel";
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.bookname = "1 Kings";
thing.longbookname = "First_Kings";
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.bookname = "2 Kings";
thing.longbookname = "Second_Kings";
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.bookname = "1 Chronicles";
thing.longbookname = "First_Chronicles";
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.bookname = "2 Chronicles";
thing.longbookname = "Second_Chronicles";
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.bookname = "Ezra";
thing.longbookname = "Book_of_Ezra";
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.bookname = "Nehemiah";
thing.longbookname = "Book_of_Nehemiah";
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.bookname = "Esther";
thing.longbookname = "Book_of_Esther";
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.bookname = "Job";
thing.longbookname = "Book_of_Job";
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.bookname = "Psalm";
thing.longbookname = "Psalm";
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.bookname = "Proverbs";
thing.longbookname = "Book_of_Proverbs";
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.bookname = "Ecclesiastes";
thing.longbookname = "Ecclesiastes";
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.bookname = "Song of Solomon";
thing.longbookname = "Song_of_Solomon";
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.bookname = "Isaiah";
thing.longbookname = "Book_of_Isaiah";
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.bookname = "Jeremiah";
thing.longbookname = "Book_of_Jeremiah";
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.bookname = "Lamentations";
thing.longbookname = "Book_of_Lamentations";
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.bookname = "Ezekiel";
thing.longbookname = "Book_of_Ezekiel";
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.bookname = "Daniel";
thing.longbookname = "Book_of_Daniel";
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.bookname = "Hosea";
thing.longbookname = "Book_of_Hosea";
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.bookname = "Joel";
thing.longbookname = "Book_of_Joel";
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.bookname = "Amos";
thing.longbookname = "Book_of_Amos";
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.bookname = "Obadiah";
thing.longbookname = "Book_of_Obadiah";
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.bookname = "Jonah";
thing.longbookname = "Book_of_Jonah";
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.bookname = "Micah";
thing.longbookname = "Book_of_Micah";
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.bookname = "Nahum";
thing.longbookname = "Book_of_Nahum";
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.bookname = "Habakkuk";
thing.longbookname = "Book_of_Habakkuk";
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.bookname = "Zephaniah";
thing.longbookname = "Book_of_Zephaniah";
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.bookname = "Haggai";
thing.longbookname = "Book_of_Haggai";
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.bookname = "Zechariah";
thing.longbookname = "Book_of_Zechariah";
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.bookname = "Malachi";
thing.longbookname = "Book_of_Malachi";
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.bookname = "Matthew";
thing.longbookname = "Gospel_of_Matthew";
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.bookname = "Mark";
thing.longbookname = "Gospel_of_Mark";
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.bookname = "Luke";
thing.longbookname = "Gospel_of_Luke";
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.bookname = "John";
thing.longbookname = "Gospel_of_John";
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.bookname = "Acts";
thing.longbookname = "Acts_of_the_Apostles";
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.bookname = "Romans";
thing.longbookname = "Epistle_to_the_Romans";
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.bookname = "1 Corinthians";
thing.longbookname = "First_Epistle_to_the_Corinthians";
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.bookname = "2 Corinthians";
thing.longbookname = "Second_Epistle_to_the_Corinthians";
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.bookname = "Galatians";
thing.longbookname = "Epistle_to_the_Galatians";
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.bookname = "Ephesians";
thing.longbookname = "Epistle_to_the_Ephesians";
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.bookname = "Philippians";
thing.longbookname = "Epistle_to_the_Philippians";
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.bookname = "Colossians";
thing.longbookname = "Epistle_to_the_Colossians";
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.bookname = "1 Thessalonians";
thing.longbookname = "First_Epistle_to_the_Thessalonians";
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.bookname = "2 Thessalonians";
thing.longbookname = "Second_Epistle_to_the_Thessalonians";
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.bookname = "1 Timothy";
thing.longbookname = "First_Epistle_to_Timothy";
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.bookname = "2 Timothy";
thing.longbookname = "Second_Epistle_to_Timothy";
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.bookname = "Titus";
thing.longbookname = "Epistle_to_Titus";
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.bookname = "Philemon";
thing.longbookname = "Epistle_to_Philemon";
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.bookname = "Hebrews";
thing.longbookname = "Epistle_to_the_Hebrews";
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.bookname = "James";
thing.longbookname = "Epistle_of_James";
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.bookname = "1 Peter";
thing.longbookname = "First_Epistle_of_Peter";
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.bookname = "2 Peter";
thing.longbookname = "Second_Epistle_of_Peter";
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.bookname = "1 John";
thing.longbookname = "First_Epistle_of_John";
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.bookname = "2 John";
thing.longbookname = "Second_Epistle_of_John";
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.bookname = "3 John";
thing.longbookname = "Third_Epistle_of_John";
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.bookname = "Jude";
thing.longbookname = "Epistle_of_Jude";
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.bookname = "Revelation";
thing.longbookname = "Book_of_Revelations";
@ -608,7 +716,8 @@ export class Reference {
return thing;
}
public static toString(section: Section) {
public static toString(section: Section)
{
// get the starting book, chapter, verse
let ref = section.start.bookname.concat(" ").
concat(section.start.chapter).concat(":").
@ -616,20 +725,24 @@ export class Reference {
if (section.start.chapter == section.end.chapter &&
section.start.verse == section.end.verse &&
section.start.book == section.end.book) {
section.start.book == section.end.book)
{
return ref;
}
if (section.start.chapter == section.end.chapter &&
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);
}
if (section.start.book != section.end.book) {
if (section.start.book != section.end.book)
{
ref = ref.concat(" - ").concat(section.end.bookname).concat(" ");
}
else {
else
{
ref = ref.concat(" - ");
}
@ -638,7 +751,8 @@ export class Reference {
return ref.concat(section.end.verse);
}
public static bookName(booknum: number): string {
public static bookName(booknum: number): string
{
let book = new Array();
book[0] = "";
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 { CardItem } from "../pages/search/search";
export class UserProfile
{
user: User;
constructor(u: User)
{
this.user = u;
@ -48,6 +49,7 @@ export class UserProfile
this.user.append_to_bottom = false;
this.user.insert_next_to_item = false;
this.user.font_size = 10;
this.user.saved_pages = [];
this.save(local);
}
@ -59,7 +61,23 @@ export class UserProfile
items: [],
append_to_bottom: 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-navbar>
</ion-header>
<ion-content padding class="search-card">
<!--<ion-list [virtualScroll]="userProfile.user.items" no-lines approxItemHeight="200px" bufferRatio="10">
<div *virtualItem="let item" style="width: 100%">
<ion-card>
<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>
<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>
<div style="height:10px"></div>
</div>
</ion-list>-->
<ion-card>
<ion-grid>
<ion-row>
<ion-col style="width: 95px;">
<button ion-button right small (click)="addPage()">
<ion-icon name="cloud-upload"></ion-icon><div>&nbsp;&nbsp;Save</div>
</button>
</ion-col>
<ion-col style="flex-grow: 100 !important">
<ion-item>
<ion-input type="text" placeholder="Saved Results Title goes here" [(ngModel)]="saved_results_title"></ion-input>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
</ion-card>
<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>
<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>
<button ion-button icon-left clear small (click)="removeItem(item)">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>
</button>
<words *ngIf="isWords(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItemsNextToCard($event)"></words>
</ion-card>
</ion-content>

View File

@ -4,9 +4,11 @@
line-height: 1em;
font-size: 1em;
}
}
.search-card {
.button-large-md {
height: 3.6rem !important;
}
.title {
font-size: 1.3em;
font-family: 'Roboto', Helvetica, Arial, sans-serif;
@ -31,4 +33,7 @@ body {
font-size: 1.2em;
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 {Reference} from "../../Reference";
import {BibleService} from "../../bible-service";
import {Loading, LoadingController, ModalController } from "ionic-angular";
import {StrongsService} from "../../strongs-service";
import {WordService} from "../../word-service";
import {StrongsModal} from "../../components/strongs-modal/strongs-modal";
import {Storage} from '@ionic/storage';
import {UserProfile} from '../../UserProfile';
import { Type, Component } from '@angular/core';
import { Loading, LoadingController, ModalController, NavController, MenuController, ViewController, App, NavParams, IonicApp } from 'ionic-angular';
import { Storage } from '@ionic/storage';
class Item
{
id: number;
data: any;
type: Type<any>;
dict: string;
}
import { StrongsModal } from '../../components/strongs-modal/strongs-modal';
import { BiblePassageResult, BibleService } from '../../services/bible-service';
import { StrongsResult, StrongsService } from '../../services/strongs-service';
import { WordService } from '../../services/word-service';
import { PagesService } from "../../services/pages-service";
import { UserProfile } from '../../libs/UserProfile';
import { Reference } from '../../libs/Reference';
import { MyApp } from '../../app/app.component';
@Component({
templateUrl: "search.html",
providers: [BibleService, StrongsService, WordService],
templateUrl: 'search.html',
providers: [BibleService, StrongsService, WordService]
})
export class SearchPage
{
searchQuery: string = "";
searchQuery = '';
userProfile: UserProfile;
last: CardItem;
loader: Loading;
saved_results_title: string = "";
constructor(
private strongsService: StrongsService
, private bibleService: BibleService
, private wordService: WordService
, private pagesService: PagesService
, public loadingCtrl: LoadingController
, public modalCtrl: ModalController
, public local: Storage)
, public navCtl: NavController
, public menuCtl: MenuController
, public local: Storage
, public params: NavParams
)
{
this.userProfile = new UserProfile(UserProfile.createDefaultUser());
@ -53,12 +55,22 @@ export class SearchPage
{
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)
{
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)
@ -87,19 +99,19 @@ export class SearchPage
isError(t: string)
{
return t === "Error";
return t === 'Error';
}
isPassage(t: string)
{
return t === "Passage";
return t === 'Passage';
}
isStrongs(t: string)
{
return t === "Strongs";
return t === 'Strongs';
}
isWords(t: string)
{
return t === "Words";
return t === 'Words';
}
addItemToList(item)
@ -133,33 +145,32 @@ export class SearchPage
this.getItems(data.qry);
}
getItems(search)
{
this.loader = this.loadingCtrl.create({
content: "Looking up query..."
content: 'Looking up query...'
});
this.loader.present().then(
() =>
{
try
{
let qs = search.split(";");
let qs = search.split(';');
for (let x in qs)
{
if (qs.hasOwnProperty(x))
{
let q = qs[x].trim();
if (q !== "")
if (q !== '')
{
// its a search term.
if (q.search(/[0-9]/i) === -1)
{
let result = this.wordService.getResult(q);
if (result.status == 0)
this.addItemToList({ data: result, type: "Words", dict: "na" });
if (result.status === 0)
this.addItemToList({ data: result, type: 'Words', dict: 'na' });
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)
{
@ -168,48 +179,48 @@ export class SearchPage
if (dict.search(/h/i) !== -1)
{
dict = "heb";
dict = 'heb';
} else
{
dict = "grk";
dict = 'grk';
}
q = q.substring(1, q.length);
let result = this.strongsService.getResult(parseInt(q), dict);
if (result.status == -1)
this.addItemToList({ data: result.msg, type: "Error", dict: "na" });
if (result.status === -1)
this.addItemToList({ data: result.msg, type: 'Error', dict: 'na' });
else
{
if (this.userProfile.user.strongs_modal)
this.presentStrongsModal(result);
else
this.addItemToList({ data: result, type: "Strongs", dict: "na" });
this.addItemToList({ data: result, type: 'Strongs', dict: 'na' });
}
}
else
{
// its a verse reference.
if (q.trim() !== "")
if (q.trim() !== '')
{
let myref = new Reference(q.trim());
let r = this.bibleService.getResult(myref.Section);
r.ref = myref.toString();
if (r.status == 0)
this.addItemToList({ data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" });
if (r.status === 0)
this.addItemToList({ data: r, type: 'Passage', dict: r.testament === 'new' ? 'G' : 'H' });
else
this.addItemToList({ data: r.msg, type: "Error", dict: "na" });
this.addItemToList({ data: r.msg, type: 'Error', dict: 'na' });
}
}
}
}
}
if (this.userProfile.user.clear_search_after_query)
$(".searchbar-input").val("");
$('.searchbar-input').val('');
this.userProfile.save(this.local);
}
catch (error)
{
this.addItemToList({ data: error, type: "Error", dict: "na" });
this.addItemToList({ data: error, type: 'Error', dict: 'na' });
console.log(error);
}
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>
<button ion-button (click)="reset()">Reset Settings</button>
</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>
</ion-content>

View File

@ -1,9 +1,8 @@
/// <reference path="../../types.ts" />
/// <reference path="../../../typings/browser/ambient/jquery/index.d.ts" />
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { UserProfile } from '../../UserProfile';
import { SavedPage, UserProfile } from '../../libs/UserProfile';
@Component({
selector: 'settings',
@ -48,4 +47,13 @@ export class SettingsPage
{
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 {XHRBackend, BaseRequestOptions, HttpModule, Http,} from '@angular/http';
import {getTestBed, TestBed} from '@angular/core/testing';
import {BaseRequestOptions, HttpModule, Http,} from '@angular/http';
import {MockBackend} from '@angular/http/testing';
import {BibleService} from './bible-service';
import {Reference} from './Reference';

View File

@ -1,8 +1,7 @@
/// <reference path="../typings/browser/ambient/jquery/index.d.ts" />
/// <reference path="types.ts" />
/// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { Reference } from "./Reference";
import { Section, Reference } from "../libs/Reference";
@Injectable()
export class BibleService
@ -15,7 +14,7 @@ export class BibleService
constructor(private http: Http)
{
}
getResult(section: Section): BiblePassageResult
{
try
@ -34,7 +33,7 @@ export class BibleService
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++)
{
const url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
$.ajax({
async: false,
type: "GET",
@ -92,13 +91,35 @@ export class BibleService
this.result.testament = "new";
else
this.result.testament = "old";
return this.result;
}
}
catch (error)
{
console.log(error);
}
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="types.ts" />
/// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
@Injectable()
export class StrongsService {
export class StrongsService
{
result: StrongsResult;
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;
this.result = {
prefix: "",
@ -25,15 +27,20 @@ export class StrongsService {
msg: ":)"
};
let url = dict + Math.ceil(sn / 100) + ".json";
if (dict === "grk") {
if (dict === "grk")
{
self.result.prefix = "G";
if (sn > 5624 || sn < 1) {
if (sn > 5624 || sn < 1)
{
self.result.status = -1;
self.result.msg = "Strongs Number G" + sn + " is out of range.";
}
} else {
}
else
{
self.result.prefix = "H";
if (sn > 8674 || sn < 1) {
if (sn > 8674 || sn < 1)
{
self.result.status = -1;
self.result.msg = "Strongs Number H" + sn + " is out of range.";
}
@ -48,10 +55,12 @@ export class StrongsService {
type: "GET",
url: "data/strongs/" + url,
dataType: "json",
success: function (d: StrongsDefinition[], t, x) {
success: function (d: StrongsDefinition[], t, x)
{
self.result.strongs = d;
},
error: function (request, status, error) {
error: function (request, status, error)
{
console.log(error);
self.result.status = -1;
self.result.msg = "Unable to retrieve Strongs Data for " + self.result.prefix + self.result.sn;
@ -69,15 +78,19 @@ export class StrongsService {
type: "GET",
url: "data/strongscr/cr" + url,
dataType: "json",
success: function (d: StrongsCrossReference[], t, x) {
for (let cr of d) {
if (cr.id.toUpperCase() == self.result.prefix + self.result.sn) {
success: function (d: StrongsCrossReference[], t, x)
{
for (let cr of d)
{
if (cr.id.toUpperCase() == self.result.prefix + self.result.sn)
{
self.result.crossrefs = cr;
break;
}
}
},
error: function (request, status, error) {
error: function (request, status, error)
{
console.log(error);
self.result.status = -1;
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)
return self.result;
if (dict === "grk") {
if (dict === "grk")
{
url = "data/rmac/rs" + (Math.ceil(sn / 1000)) + ".json";
let rmac_cross_references: RMACCrossReference[];
@ -97,36 +111,43 @@ export class StrongsService {
type: "GET",
url: url,
dataType: "json",
success: function (d: RMACCrossReference[], t, x) {
success: function (d: RMACCrossReference[], t, x)
{
rmac_cross_references = d;
},
error: function (request, status, error) {
error: function (request, status, error)
{
console.log(error);
}
});
// 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)
return this.result;
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`;
$.ajax({
async: false,
type: "GET",
url: url,
dataType: "json",
success: function (d: RMACDefinition[], t, x) {
for (let rmac of d) {
if (rmac.id.toLowerCase() == self.result.rmaccode) {
success: function (d: RMACDefinition[], t, x)
{
for (let rmac of d)
{
if (rmac.id.toLowerCase() == self.result.rmaccode)
{
self.result.rmac = rmac;
break;
}
}
},
error: function (request, status, error) {
error: function (request, status, error)
{
console.log(error);
}
});
@ -134,4 +155,37 @@ export class StrongsService {
}
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="types.ts" />
/// <reference path="../../typings/browser/ambient/jquery/index.d.ts" />
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
@ -34,7 +33,7 @@ export class WordService
results.unshift(this.getSearchReferences("data/index/" + words[w] + "idx.json", q));
break;
}
}
}
else
{
if (q <= words[w] && q > words[w - 1])
@ -444,4 +443,16 @@ export class WordService
// are identical.
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
}
};