mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 16:29:49 -04:00
FEATURE: Functioning search is here.
* added saving of state. * moved all state into the user profile, this will allow us to load state after a user logs in when we add user accounts later.
This commit is contained in:
parent
dcfb927581
commit
8badd5dfc1
@ -10,7 +10,8 @@ import {SettingsPage} from "../pages/settings/settings";
|
|||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'app.html'
|
templateUrl: 'app.html'
|
||||||
})
|
})
|
||||||
export class MyApp {
|
export class MyApp
|
||||||
|
{
|
||||||
@ViewChild(Nav) nav: Nav;
|
@ViewChild(Nav) nav: Nav;
|
||||||
|
|
||||||
// make HelloIonicPage the root (or first) page
|
// make HelloIonicPage the root (or first) page
|
||||||
@ -20,7 +21,8 @@ export class MyApp {
|
|||||||
constructor(
|
constructor(
|
||||||
public platform: Platform,
|
public platform: Platform,
|
||||||
public menu: MenuController
|
public menu: MenuController
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
this.initializeApp();
|
this.initializeApp();
|
||||||
|
|
||||||
// set our app's pages
|
// set our app's pages
|
||||||
@ -30,8 +32,10 @@ export class MyApp {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeApp() {
|
initializeApp()
|
||||||
this.platform.ready().then(() => {
|
{
|
||||||
|
this.platform.ready().then(() =>
|
||||||
|
{
|
||||||
// Okay, so the platform is ready and our plugins are available.
|
// Okay, so the platform is ready and our plugins are available.
|
||||||
// Here you can do any higher level native things you might need.
|
// Here you can do any higher level native things you might need.
|
||||||
StatusBar.styleDefault();
|
StatusBar.styleDefault();
|
||||||
@ -39,7 +43,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
|
||||||
|
@ -12,6 +12,7 @@ import {SettingsPage} from "../pages/settings/settings";
|
|||||||
import {ComponentLoader} from "../components/component-loader/component-loader.ts";
|
import {ComponentLoader} from "../components/component-loader/component-loader.ts";
|
||||||
import {Passage} from "../components/passage/passage.ts";
|
import {Passage} from "../components/passage/passage.ts";
|
||||||
import {Strongs} from "../components/strongs/strongs.ts";
|
import {Strongs} from "../components/strongs/strongs.ts";
|
||||||
|
import {Words} from "../components/words/words.ts";
|
||||||
import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -23,6 +24,7 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
|||||||
Passage,
|
Passage,
|
||||||
Strongs,
|
Strongs,
|
||||||
StrongsModal,
|
StrongsModal,
|
||||||
|
Words
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
IonicModule.forRoot(MyApp),
|
IonicModule.forRoot(MyApp),
|
||||||
@ -36,6 +38,7 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts";
|
|||||||
Passage,
|
Passage,
|
||||||
Strongs,
|
Strongs,
|
||||||
StrongsModal,
|
StrongsModal,
|
||||||
|
Words
|
||||||
],
|
],
|
||||||
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
|
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
|
||||||
})
|
})
|
||||||
|
@ -14,3 +14,8 @@
|
|||||||
// To declare rules for a specific mode, create a child rule
|
// To declare rules for a specific mode, create a child rule
|
||||||
// for the .md, .ios, or .wp mode classes. The mode class is
|
// for the .md, .ios, or .wp mode classes. The mode class is
|
||||||
// automatically applied to the <body> element in the app.
|
// automatically applied to the <body> element in the app.
|
||||||
|
|
||||||
|
.item-md {
|
||||||
|
padding: 0px !important;
|
||||||
|
padding-left: 16px !important;
|
||||||
|
}
|
@ -27,7 +27,8 @@ export class BibleService
|
|||||||
};
|
};
|
||||||
this.count = Number(section.end.chapter) - Number(section.start.chapter) + 1;
|
this.count = Number(section.end.chapter) - Number(section.start.chapter) + 1;
|
||||||
|
|
||||||
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";
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
async: false,
|
async: false,
|
||||||
@ -40,7 +41,7 @@ export class BibleService
|
|||||||
},
|
},
|
||||||
error: function (request, status, error)
|
error: function (request, status, error)
|
||||||
{
|
{
|
||||||
//Util.HandleError(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,15 +92,14 @@ export class BibleService
|
|||||||
if (section.start.book >= 40)
|
if (section.start.book >= 40)
|
||||||
{
|
{
|
||||||
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 (err)
|
} catch (error)
|
||||||
{
|
{
|
||||||
//Util.HandleError(err);
|
console.log(error);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<ion-item class="title" padding>
|
|
||||||
{{item.prefix}}{{item.sn}}
|
|
||||||
<button ion-button icon-only item-right large clear (click)="close()">
|
|
||||||
<ion-icon name="close-circle"></ion-icon>
|
|
||||||
</button>
|
|
||||||
</ion-item>
|
|
||||||
<ion-card-content>
|
|
||||||
<p>
|
|
||||||
<b>{{item.def.tr}} ({{item.def.sn}})</b> - {{item.def.p}} - {{item.def.lemma}} - <span [innerHTML]="item.def.de"></span><br />
|
|
||||||
</p>
|
|
||||||
</ion-card-content>
|
|
@ -1,23 +0,0 @@
|
|||||||
import {EventEmitter, Component, Input, Output} from "@angular/core";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: "search",
|
|
||||||
templateUrl: "search.html"
|
|
||||||
})
|
|
||||||
export class Search {
|
|
||||||
@Output()
|
|
||||||
onClose = new EventEmitter<CardItem>();
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
item: SearchResult;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
cardItem: CardItem;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
close() {
|
|
||||||
this.onClose.emit(this.cardItem);
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,11 +27,10 @@ export class StrongsModal {
|
|||||||
this.viewCtrl.dismiss();
|
this.viewCtrl.dismiss();
|
||||||
}
|
}
|
||||||
makePassage(p: string) {
|
makePassage(p: string) {
|
||||||
return Reference.bookName(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.dismiss();
|
|
||||||
this.onPassageClicked.emit(ref);
|
this.onPassageClicked.emit(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,11 +21,12 @@ export class Strongs {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close()
|
||||||
|
{
|
||||||
this.onClose.emit(this.cardItem);
|
this.onClose.emit(this.cardItem);
|
||||||
}
|
}
|
||||||
makePassage(p: string) {
|
makePassage(p: string) {
|
||||||
return Reference.bookName(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);
|
||||||
|
15
DynamicBibleIonic/src/components/words/words.html
Normal file
15
DynamicBibleIonic/src/components/words/words.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<ion-item class="title" padding>
|
||||||
|
{{item.refs.length}} results for {{item.word}}
|
||||||
|
<button ion-button icon-only item-right large clear (click)="close()">
|
||||||
|
<ion-icon name="close-circle"></ion-icon>
|
||||||
|
</button>
|
||||||
|
</ion-item>
|
||||||
|
<ion-card-content>
|
||||||
|
<ion-scroll scrollY="true">
|
||||||
|
<ion-grid>
|
||||||
|
<ion-row responsive-sm responsive-md wrap *ngFor="let i of getColumns()">
|
||||||
|
<ion-col width-25 *ngFor="let ref of item.refs | slice:(i*4):(i+1)*4" (click)="openPassage(ref)"><span class="button">{{makePassage(ref)}}</span></ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</ion-grid>
|
||||||
|
</ion-scroll>
|
||||||
|
</ion-card-content>
|
42
DynamicBibleIonic/src/components/words/words.ts
Normal file
42
DynamicBibleIonic/src/components/words/words.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import {EventEmitter, Component, Input, Output} from "@angular/core";
|
||||||
|
import { Reference } from '../../Reference.ts';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "words",
|
||||||
|
templateUrl: "words.html"
|
||||||
|
})
|
||||||
|
export class Words {
|
||||||
|
@Output()
|
||||||
|
onClose = new EventEmitter<CardItem>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
onPassageClicked = new EventEmitter<string>();
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
item: WordLookupResult;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
cardItem: CardItem;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
this.onClose.emit(this.cardItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
getColumns()
|
||||||
|
{
|
||||||
|
return Array.from(Array(Math.ceil(this.item.refs.length / 4)).keys())
|
||||||
|
}
|
||||||
|
|
||||||
|
makePassage(p: string)
|
||||||
|
{
|
||||||
|
return Reference.bookName(parseInt(p.split(":")[0])) + ' ' + p.split(":")[1] + ":" + p.split(":")[2];
|
||||||
|
}
|
||||||
|
openPassage(p: string)
|
||||||
|
{
|
||||||
|
let ref = this.makePassage(p);
|
||||||
|
this.onPassageClicked.emit(ref);
|
||||||
|
}
|
||||||
|
}
|
@ -3,13 +3,14 @@
|
|||||||
<button menuToggle large>
|
<button menuToggle large>
|
||||||
<ion-icon name="menu"></ion-icon>
|
<ion-icon name="menu"></ion-icon>
|
||||||
</button>
|
</button>
|
||||||
<ion-searchbar (search)="getQuery($event)" (input)="setQuery($event)"></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-card *ngFor="let item of items">
|
<ion-card *ngFor="let item of user.items">
|
||||||
<passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" [dict]="item.dict" (onStrongsClicked)="getItems($event)"></passage>
|
<passage *ngIf="isPassage(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" [dict]="item.dict" (onStrongsClicked)="getItems($event)"></passage>
|
||||||
<strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItems($event)"></strongs>
|
<strongs *ngIf="isStrongs(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItems($event)"></strongs>
|
||||||
|
<words *ngIf="isWords(item.type)" [cardItem]="item" [item]="item.data" (onClose)="removeItem($event)" (onPassageClicked)="getItems($event)"></words>
|
||||||
<button ion-button icon-left clear small (click)="removeItem(item)">
|
<button ion-button icon-left clear small (click)="removeItem(item)">
|
||||||
<ion-icon name="close-circle"></ion-icon>
|
<ion-icon name="close-circle"></ion-icon>
|
||||||
<div>Close</div>
|
<div>Close</div>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
.search-card {
|
.search-card {
|
||||||
.title {
|
.title {
|
||||||
background-color: gainsboro;
|
background-color: gainsboro;
|
||||||
font-size: 2em;
|
font-size: 1.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@ -27,4 +27,24 @@ body {
|
|||||||
|
|
||||||
.card-md h2 {
|
.card-md h2 {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-scroll {
|
||||||
|
white-space: nowrap;
|
||||||
|
height: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-col {
|
||||||
|
//border-bottom: 1px solid #cbcbcb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-col .button{
|
||||||
|
background-color: #fbfbfb;
|
||||||
|
padding: 9px 6px 9px 6px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-col {
|
||||||
|
margin-bottom: 0px !important;
|
||||||
}
|
}
|
@ -4,12 +4,15 @@ import {Reference} from "../../Reference";
|
|||||||
import {BibleService} from "../../bible-service";
|
import {BibleService} from "../../bible-service";
|
||||||
import {LoadingController, ModalController } from "ionic-angular";
|
import {LoadingController, ModalController } from "ionic-angular";
|
||||||
import {StrongsService} from "../../strongs-service";
|
import {StrongsService} from "../../strongs-service";
|
||||||
|
import {WordService} from "../../word-service";
|
||||||
import {Strongs} from "../../components/strongs/strongs";
|
import {Strongs} from "../../components/strongs/strongs";
|
||||||
import {Passage} from "../../components/passage/passage.ts";
|
import {Passage} from "../../components/passage/passage.ts";
|
||||||
import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts";
|
import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts";
|
||||||
import {Storage} from '@ionic/storage';
|
import {Storage} from '@ionic/storage';
|
||||||
|
import {Words} from '../../components/words/words.ts';
|
||||||
|
|
||||||
class Item {
|
class Item
|
||||||
|
{
|
||||||
id: number;
|
id: number;
|
||||||
data: any;
|
data: any;
|
||||||
type: Type<any>;
|
type: Type<any>;
|
||||||
@ -18,81 +21,118 @@ class Item {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "search.html",
|
templateUrl: "search.html",
|
||||||
providers: [BibleService, StrongsService],
|
providers: [BibleService, StrongsService, WordService],
|
||||||
})
|
})
|
||||||
export class SearchPage {
|
export class SearchPage
|
||||||
|
{
|
||||||
searchQuery: string = "";
|
searchQuery: string = "";
|
||||||
items: CardItem[];
|
|
||||||
last: number;
|
last: number;
|
||||||
user: User = { strongs_modal: true };
|
user: User = { strongs_modal: true, clear_search_after_query: true, items: [] };
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private strongsService: StrongsService
|
private strongsService: StrongsService
|
||||||
, private bibleService: BibleService
|
, private bibleService: BibleService
|
||||||
|
, private wordService: WordService
|
||||||
, public loadingCtrl: LoadingController
|
, public loadingCtrl: LoadingController
|
||||||
, public modalCtrl: ModalController
|
, public modalCtrl: ModalController
|
||||||
, public local: Storage) {
|
, public local: Storage)
|
||||||
this.initializeItems();
|
{
|
||||||
// Check if there is a profile saved in local storage
|
// Check if there is a profile saved in local storage
|
||||||
this.local.get('profile').then(profile => {
|
this.local.get('profile').then(profile =>
|
||||||
if (profile === null) {
|
{
|
||||||
|
let t = this.user;
|
||||||
|
if (profile === null)
|
||||||
this.local.set('profile', JSON.stringify(this.user));
|
this.local.set('profile', JSON.stringify(this.user));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
this.user = JSON.parse(profile);
|
{
|
||||||
}).catch(error => {
|
t = JSON.parse(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initializeItems(t);
|
||||||
|
}).catch(error =>
|
||||||
|
{
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeItems() {
|
initializeItems(u: User)
|
||||||
this.items = [];
|
{
|
||||||
this.last = 0;
|
this.last = u.items.length;
|
||||||
|
this.user = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
presentStrongsModal(strongs: StrongsResult) {
|
presentStrongsModal(strongs: StrongsResult)
|
||||||
|
{
|
||||||
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs, onPassageClicked: this });
|
let modal = this.modalCtrl.create(StrongsModal, { strongsid: strongs, onPassageClicked: this });
|
||||||
modal.present();
|
modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
setQuery(searchbar) {
|
setQuery(searchbar)
|
||||||
|
{
|
||||||
this.searchQuery = searchbar.target.value;
|
this.searchQuery = searchbar.target.value;
|
||||||
}
|
}
|
||||||
getQuery(searchbar) {
|
getQuery(searchbar)
|
||||||
|
{
|
||||||
this.getItems(this.searchQuery);
|
this.getItems(this.searchQuery);
|
||||||
}
|
}
|
||||||
removeItem(item) {
|
|
||||||
let idx = this.items.indexOf(item);
|
removeItem(item)
|
||||||
this.items.splice(idx, 1);
|
{
|
||||||
|
let idx = this.user.items.indexOf(item);
|
||||||
|
this.user.items.splice(idx, 1);
|
||||||
|
|
||||||
|
// save the users settings.
|
||||||
|
this.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
isPassage(t: Type<any>) {
|
isPassage(t: string)
|
||||||
return t === Passage;
|
{
|
||||||
|
return t === "Passage";
|
||||||
}
|
}
|
||||||
|
|
||||||
isStrongs(t: Type<any>) {
|
isStrongs(t: string)
|
||||||
return t === Strongs;
|
{
|
||||||
|
return t === "Strongs";
|
||||||
}
|
}
|
||||||
|
|
||||||
getItems(search) {
|
isWords(t: string)
|
||||||
try {
|
{
|
||||||
|
return t === "Words";
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSettings()
|
||||||
|
{
|
||||||
|
this.local.set('profile', JSON.stringify(this.user));
|
||||||
|
}
|
||||||
|
|
||||||
|
getItems(search)
|
||||||
|
{
|
||||||
|
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)
|
||||||
// get new results.
|
{
|
||||||
//Words.FindReferences(q);
|
let result = this.wordService.getResult(q);
|
||||||
//$("#searchpanel").panel("open");
|
this.user.items.unshift({ id: this.last++, data: result, type: "Words", dict: "na" });
|
||||||
} else if (q.search(/(H|G)[0-9]/i) !== -1) {
|
}
|
||||||
|
else if (q.search(/(H|G)[0-9]/i) !== -1)
|
||||||
|
{
|
||||||
// its a strongs lookup
|
// its a strongs lookup
|
||||||
let dict = q.substring(0, 1);
|
let dict = q.substring(0, 1);
|
||||||
|
|
||||||
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);
|
||||||
@ -100,25 +140,30 @@ export class SearchPage {
|
|||||||
if (this.user.strongs_modal)
|
if (this.user.strongs_modal)
|
||||||
this.presentStrongsModal(result);
|
this.presentStrongsModal(result);
|
||||||
else
|
else
|
||||||
this.items.unshift({ id: this.last++, data: result, type: Strongs, dict: "na" });
|
this.user.items.unshift({ id: this.last++, 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();
|
||||||
this.items.unshift({ id: this.last++, data: r, type: Passage, dict: r.testament == 'new' ? "G" : "H" });
|
this.user.items.unshift({ id: this.last++, data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//loader.dismiss();
|
if (this.user.clear_search_after_query)
|
||||||
|
$(".searchbar-input").val("");
|
||||||
|
|
||||||
//Settings.SaveResults();
|
this.saveSettings();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (error)
|
||||||
//Util.HandleError(err);
|
{
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,4 +12,11 @@
|
|||||||
<ion-label>Show Strongs as Modal</ion-label>
|
<ion-label>Show Strongs as Modal</ion-label>
|
||||||
<ion-toggle color="dark" [(ngModel)]="user.strongs_modal" (ionChange)="save()"></ion-toggle>
|
<ion-toggle color="dark" [(ngModel)]="user.strongs_modal" (ionChange)="save()"></ion-toggle>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
<ion-item *ngIf="user">
|
||||||
|
<ion-label>Clear Search Bar after Query</ion-label>
|
||||||
|
<ion-toggle color="dark" [(ngModel)]="user.clear_search_after_query" (ionChange)="save()"></ion-toggle>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item *ngIf="user">
|
||||||
|
<button ion-button (click)="reset()">Reset Settings</button>
|
||||||
|
</ion-item>
|
||||||
</ion-content>
|
</ion-content>
|
@ -7,27 +7,38 @@ import { Storage } from '@ionic/storage';
|
|||||||
selector: 'settings',
|
selector: 'settings',
|
||||||
templateUrl: 'settings.html'
|
templateUrl: 'settings.html'
|
||||||
})
|
})
|
||||||
export class SettingsPage {
|
export class SettingsPage
|
||||||
user: User = { strongs_modal: true };
|
{
|
||||||
constructor(public navCtrl: NavController, public local: Storage) {
|
user: User = { strongs_modal: true, clear_search_after_query: true, items: [] };
|
||||||
|
|
||||||
|
constructor(public navCtrl: NavController, public local: Storage)
|
||||||
|
{
|
||||||
// Check if there is a profile saved in local storage
|
// Check if there is a profile saved in local storage
|
||||||
this.local.get('profile').then(profile => {
|
this.local.get('profile').then(profile =>
|
||||||
if (profile === null) {
|
{
|
||||||
|
if (profile === null)
|
||||||
this.save();
|
this.save();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
this.user = JSON.parse(profile);
|
this.user = JSON.parse(profile);
|
||||||
}).catch(error => {
|
}).catch(error =>
|
||||||
|
{
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save()
|
||||||
|
{
|
||||||
this.local.set('profile', JSON.stringify(this.user));
|
this.local.set('profile', JSON.stringify(this.user));
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidLoad() {
|
reset()
|
||||||
|
{
|
||||||
|
this.user = { strongs_modal: true, clear_search_after_query: true, items: [] };
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad()
|
||||||
|
{
|
||||||
console.log('Hello SettingsPage Page');
|
console.log('Hello SettingsPage Page');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,124 +4,128 @@ 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
|
||||||
try {
|
{
|
||||||
const self = this;
|
const self = this;
|
||||||
this.result = {
|
this.result = {
|
||||||
prefix: "",
|
prefix: "",
|
||||||
sn: -1,
|
sn: -1,
|
||||||
strongs: [],
|
strongs: [],
|
||||||
def: null,
|
def: null,
|
||||||
rmac: null,
|
rmac: null,
|
||||||
crossrefs: null,
|
crossrefs: null,
|
||||||
rmaccode: ""
|
rmaccode: ""
|
||||||
};
|
};
|
||||||
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";
|
||||||
|
if (sn > 5624) return this.result;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
self.result.prefix = "H";
|
||||||
|
if (sn > 8674) return this.result;
|
||||||
|
}
|
||||||
|
this.result.sn = sn;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
async: false,
|
||||||
|
type: "GET",
|
||||||
|
url: `data/strongs/${url}`,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (d: StrongsDefinition[], t, x)
|
||||||
{
|
{
|
||||||
self.result.prefix = "G";
|
self.result.strongs = d;
|
||||||
if (sn > 5624) return this.result;
|
},
|
||||||
} else
|
error: function (request, status, error)
|
||||||
{
|
{
|
||||||
self.result.prefix = "H";
|
console.log(error);
|
||||||
if (sn > 8674) return this.result;
|
|
||||||
}
|
}
|
||||||
this.result.sn = sn;
|
});
|
||||||
|
|
||||||
$.ajax({
|
self.result.def = self.result.strongs.find(el => (el.i === this.result.prefix + this.result.sn));
|
||||||
async: false,
|
self.result.strongs = [];
|
||||||
type: "GET",
|
|
||||||
url: `data/strongs/${url}`,
|
|
||||||
dataType: "json",
|
|
||||||
success: function (d: StrongsDefinition[], t, x)
|
|
||||||
{
|
|
||||||
self.result.strongs = d;
|
|
||||||
},
|
|
||||||
error: function (request, status, error)
|
|
||||||
{
|
|
||||||
//Util.HandleError(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self.result.def = self.result.strongs.find(el => (el.i === this.result.prefix + this.result.sn));
|
$.ajax({
|
||||||
self.result.strongs = [];
|
async: false,
|
||||||
|
type: "GET",
|
||||||
$.ajax({
|
url: `data/strongscr/cr${url}`,
|
||||||
async: false,
|
dataType: "json",
|
||||||
type: "GET",
|
success: function (d: StrongsCrossReference[], t, x)
|
||||||
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) {
|
|
||||||
self.result.crossrefs = cr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (request, status, error)
|
|
||||||
{
|
|
||||||
//Util.HandleError(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dict === "grk")
|
|
||||||
{
|
{
|
||||||
url = `data/rmac/rs${Math.ceil(sn / 1000)}.json`;
|
for (let cr of d)
|
||||||
let rmac_cross_references: RMACCrossReference[];
|
{
|
||||||
|
if (cr.id.toUpperCase() == self.result.prefix + self.result.sn)
|
||||||
|
{
|
||||||
|
self.result.crossrefs = cr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (request, status, error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// rmac is a two get process.
|
if (dict === "grk")
|
||||||
|
{
|
||||||
|
url = `data/rmac/rs${Math.ceil(sn / 1000)}.json`;
|
||||||
|
let rmac_cross_references: RMACCrossReference[];
|
||||||
|
|
||||||
|
// rmac is a two get process.
|
||||||
|
$.ajax({
|
||||||
|
async: false,
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (d: RMACCrossReference[], t, x)
|
||||||
|
{
|
||||||
|
rmac_cross_references = d;
|
||||||
|
},
|
||||||
|
error: function (request, status, error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// deal with RMAC
|
||||||
|
this.result.rmaccode = $.grep<RMACCrossReference>(rmac_cross_references, (el, i) => { if (el.i == sn + "") { return true; } else { return false; } })[0].r;
|
||||||
|
if (this.result.rmaccode != undefined)
|
||||||
|
{
|
||||||
|
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: RMACCrossReference[], t, x)
|
success: function (d: RMACDefinition[], t, x)
|
||||||
{
|
{
|
||||||
rmac_cross_references = d;
|
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)
|
||||||
{
|
{
|
||||||
//Util.HandleError(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// deal with RMAC
|
|
||||||
this.result.rmaccode = $.grep<RMACCrossReference>(rmac_cross_references, (el, i) => { if (el.i == sn + "") { return true; } else { return false; } })[0].r;
|
|
||||||
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) {
|
|
||||||
self.result.rmac = rmac;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (request, status, error)
|
|
||||||
{
|
|
||||||
//Util.HandleError(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this.result;
|
|
||||||
} catch (err)
|
|
||||||
{
|
|
||||||
//Util.HandleError(err);
|
|
||||||
}
|
}
|
||||||
return null;
|
return this.result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,21 @@
|
|||||||
type SearchResult = {
|
type WordLookupResult = {
|
||||||
refs: string[],
|
refs: string[],
|
||||||
word: string,
|
word: string,
|
||||||
status: Status,
|
status: Status,
|
||||||
msg: string
|
msg: string
|
||||||
}
|
}
|
||||||
enum Status {Success, Failure};
|
enum Status { Success, Failure };
|
||||||
|
|
||||||
type IndexResult = {
|
type IndexResult = {
|
||||||
refs: string[];
|
refs: string[];
|
||||||
word: string;
|
word: string;
|
||||||
}
|
}
|
||||||
type CardItem = { id: number, data: any, type: any, dict: string}
|
type CardItem = { id: number, data: any, type: string, dict: string }
|
||||||
|
|
||||||
type User = {
|
type User = {
|
||||||
strongs_modal: boolean
|
strongs_modal: boolean,
|
||||||
|
clear_search_after_query: boolean,
|
||||||
|
items: CardItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type BiblePassage = {
|
type BiblePassage = {
|
||||||
@ -36,7 +38,6 @@ type BiblePassageResult = {
|
|||||||
ref: string
|
ref: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type StrongsDefinition = { n: number, i: string, tr: string, de: string, lemma: string, p: string }
|
type StrongsDefinition = { n: number, i: string, tr: string, de: string, lemma: string, p: string }
|
||||||
type StrongsCrossReference =
|
type StrongsCrossReference =
|
||||||
{
|
{
|
||||||
|
@ -4,16 +4,13 @@ import { Injectable } from "@angular/core";
|
|||||||
import { Http } from "@angular/http";
|
import { Http } from "@angular/http";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SearchService
|
export class WordService
|
||||||
{
|
{
|
||||||
result: SearchResult;
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
constructor(private http: Http)
|
constructor(private http: Http)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
getResult(qry)
|
getResult(qry: string): WordLookupResult
|
||||||
{
|
{
|
||||||
qry = qry.toLowerCase();
|
qry = qry.toLowerCase();
|
||||||
let qs = qry.split(" ");
|
let qs = qry.split(" ");
|
||||||
@ -52,20 +49,21 @@ export class SearchService
|
|||||||
// that is shared by all of them. IF not, we can just return those refs.
|
// that is shared by all of them. IF not, we can just return those refs.
|
||||||
if (results.length == 0)
|
if (results.length == 0)
|
||||||
{
|
{
|
||||||
this.result = { word: qry, refs: null, status: Status.Failure, msg: ":)" };
|
return { word: qry, refs: null, status: 1, msg: ":)" };
|
||||||
}
|
}
|
||||||
else if (results.length == 1)
|
else if (results.length == 1)
|
||||||
{
|
{
|
||||||
this.result = { word: qry, refs: results[0].refs, status: Status.Success, msg: ":)" };
|
let temp = { word: qry, refs: results[0], status: 0, msg: ":)" };
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let shared = this.findSharedSet(results);
|
let shared = this.findSharedSet(results);
|
||||||
if (shared == null)
|
if (shared == null)
|
||||||
{
|
{
|
||||||
this.result = { word: qry, refs: null, status: Status.Failure, msg: "No passages found." };
|
return { word: qry, refs: null, status: 1, msg: "No passages found." };
|
||||||
}
|
}
|
||||||
this.result = { word: qry, refs: shared[0].refs, status: Status.Success, msg: ":)" };
|
return { word: qry, refs: shared[0], status: 0, msg: ":)" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +89,7 @@ export class SearchService
|
|||||||
},
|
},
|
||||||
error: function (request, status, error)
|
error: function (request, status, error)
|
||||||
{
|
{
|
||||||
//Util.HandleError(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user