diff --git a/DynamicBibleIonic/src/app/app.component.ts b/DynamicBibleIonic/src/app/app.component.ts index ebd0b399..73325741 100644 --- a/DynamicBibleIonic/src/app/app.component.ts +++ b/DynamicBibleIonic/src/app/app.component.ts @@ -10,7 +10,8 @@ import {SettingsPage} from "../pages/settings/settings"; @Component({ templateUrl: 'app.html' }) -export class MyApp { +export class MyApp +{ @ViewChild(Nav) nav: Nav; // make HelloIonicPage the root (or first) page @@ -20,7 +21,8 @@ export class MyApp { constructor( public platform: Platform, public menu: MenuController - ) { + ) + { this.initializeApp(); // set our app's pages @@ -30,8 +32,10 @@ export class MyApp { ]; } - initializeApp() { - this.platform.ready().then(() => { + initializeApp() + { + this.platform.ready().then(() => + { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. StatusBar.styleDefault(); @@ -39,7 +43,8 @@ export class MyApp { }); } - openPage(page) { + openPage(page) + { // close the menu when clicking a link from the menu this.menu.close(); // navigate to the new page if it is not the current page diff --git a/DynamicBibleIonic/src/app/app.module.ts b/DynamicBibleIonic/src/app/app.module.ts index 56b19769..7d993d53 100644 --- a/DynamicBibleIonic/src/app/app.module.ts +++ b/DynamicBibleIonic/src/app/app.module.ts @@ -12,6 +12,7 @@ import {SettingsPage} from "../pages/settings/settings"; import {ComponentLoader} from "../components/component-loader/component-loader.ts"; import {Passage} from "../components/passage/passage.ts"; import {Strongs} from "../components/strongs/strongs.ts"; +import {Words} from "../components/words/words.ts"; import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts"; @NgModule({ @@ -23,6 +24,7 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts"; Passage, Strongs, StrongsModal, + Words ], imports: [ IonicModule.forRoot(MyApp), @@ -36,6 +38,7 @@ import {StrongsModal} from "../components/strongs-modal/strongs-modal.ts"; Passage, Strongs, StrongsModal, + Words ], providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage] }) diff --git a/DynamicBibleIonic/src/app/app.scss b/DynamicBibleIonic/src/app/app.scss index a967d6ff..e2204d50 100644 --- a/DynamicBibleIonic/src/app/app.scss +++ b/DynamicBibleIonic/src/app/app.scss @@ -14,3 +14,8 @@ // To declare rules for a specific mode, create a child rule // for the .md, .ios, or .wp mode classes. The mode class is // automatically applied to the element in the app. + +.item-md { + padding: 0px !important; + padding-left: 16px !important; +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/bible-service.ts b/DynamicBibleIonic/src/bible-service.ts index 4040cae2..634b561f 100644 --- a/DynamicBibleIonic/src/bible-service.ts +++ b/DynamicBibleIonic/src/bible-service.ts @@ -27,7 +27,8 @@ export class BibleService }; 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"; jQuery.ajax({ async: false, @@ -40,7 +41,7 @@ export class BibleService }, error: function (request, status, error) { - //Util.HandleError(error); + console.log(error); } }); } @@ -91,15 +92,14 @@ export class BibleService if (section.start.book >= 40) { this.result.testament = "new"; - } else { this.result.testament = "old"; } return this.result; - } catch (err) + } catch (error) { - //Util.HandleError(err); + console.log(error); } return null; } diff --git a/DynamicBibleIonic/src/components/search/search.html b/DynamicBibleIonic/src/components/search/search.html deleted file mode 100644 index b9d5e753..00000000 --- a/DynamicBibleIonic/src/components/search/search.html +++ /dev/null @@ -1,11 +0,0 @@ - - {{item.prefix}}{{item.sn}} - - - -

- {{item.def.tr}} ({{item.def.sn}}) - {{item.def.p}} - {{item.def.lemma}} -
-

-
\ No newline at end of file diff --git a/DynamicBibleIonic/src/components/search/search.ts b/DynamicBibleIonic/src/components/search/search.ts deleted file mode 100644 index 9b9ebf4f..00000000 --- a/DynamicBibleIonic/src/components/search/search.ts +++ /dev/null @@ -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(); - - @Input() - item: SearchResult; - - @Input() - cardItem: CardItem; - - constructor() { - } - - close() { - this.onClose.emit(this.cardItem); - } -} \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts index 5dbcd432..8d1cb09e 100644 --- a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts +++ b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts @@ -27,11 +27,10 @@ export class StrongsModal { this.viewCtrl.dismiss(); } 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) { let ref = this.makePassage(p); - //this.dismiss(); this.onPassageClicked.emit(ref); } } \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/strongs/strongs.ts b/DynamicBibleIonic/src/components/strongs/strongs.ts index bd0665d3..6f8a078b 100644 --- a/DynamicBibleIonic/src/components/strongs/strongs.ts +++ b/DynamicBibleIonic/src/components/strongs/strongs.ts @@ -21,11 +21,12 @@ export class Strongs { constructor() { } - close() { + close() + { this.onClose.emit(this.cardItem); } 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) { let ref = this.makePassage(p); diff --git a/DynamicBibleIonic/src/components/words/words.html b/DynamicBibleIonic/src/components/words/words.html new file mode 100644 index 00000000..f6cd7757 --- /dev/null +++ b/DynamicBibleIonic/src/components/words/words.html @@ -0,0 +1,15 @@ + + {{item.refs.length}} results for {{item.word}} + + + + + + + {{makePassage(ref)}} + + + + \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/words/words.ts b/DynamicBibleIonic/src/components/words/words.ts new file mode 100644 index 00000000..2117d9e1 --- /dev/null +++ b/DynamicBibleIonic/src/components/words/words.ts @@ -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(); + + @Output() + onPassageClicked = new EventEmitter(); + + @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); + } +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/search/search.html b/DynamicBibleIonic/src/pages/search/search.html index 79083948..a1749790 100644 --- a/DynamicBibleIonic/src/pages/search/search.html +++ b/DynamicBibleIonic/src/pages/search/search.html @@ -3,13 +3,14 @@ - + - + + + \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/settings/settings.ts b/DynamicBibleIonic/src/pages/settings/settings.ts index 679d9284..e1d9a0a4 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.ts +++ b/DynamicBibleIonic/src/pages/settings/settings.ts @@ -7,27 +7,38 @@ import { Storage } from '@ionic/storage'; selector: 'settings', templateUrl: 'settings.html' }) -export class SettingsPage { - user: User = { strongs_modal: true }; - constructor(public navCtrl: NavController, public local: Storage) { - +export class SettingsPage +{ + 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 - this.local.get('profile').then(profile => { - if (profile === null) { + this.local.get('profile').then(profile => + { + if (profile === null) this.save(); - } else this.user = JSON.parse(profile); - }).catch(error => { + }).catch(error => + { console.log(error); }); } - save() { + save() + { 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'); } } \ No newline at end of file diff --git a/DynamicBibleIonic/src/strongs-service.ts b/DynamicBibleIonic/src/strongs-service.ts index 7efad999..b458bcab 100644 --- a/DynamicBibleIonic/src/strongs-service.ts +++ b/DynamicBibleIonic/src/strongs-service.ts @@ -4,124 +4,128 @@ 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 - try { - const self = this; - this.result = { - prefix: "", - sn: -1, - strongs: [], - def: null, - rmac: null, - crossrefs: null, - rmaccode: "" - }; - let url = dict + Math.ceil(sn / 100) + ".json"; - if (dict === "grk") + { + const self = this; + this.result = { + prefix: "", + sn: -1, + strongs: [], + def: null, + rmac: null, + crossrefs: null, + rmaccode: "" + }; + let url = dict + Math.ceil(sn / 100) + ".json"; + 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"; - if (sn > 5624) return this.result; - } else + self.result.strongs = d; + }, + error: function (request, status, error) { - self.result.prefix = "H"; - if (sn > 8674) return this.result; + console.log(error); } - this.result.sn = sn; + }); - $.ajax({ - async: false, - 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)); + self.result.strongs = []; - self.result.def = self.result.strongs.find(el => (el.i === this.result.prefix + this.result.sn)); - self.result.strongs = []; - - $.ajax({ - async: false, - 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) { - self.result.crossrefs = cr; - break; - } - } - }, - error: function (request, status, error) - { - //Util.HandleError(error); - } - }); - - if (dict === "grk") + $.ajax({ + async: false, + type: "GET", + url: `data/strongscr/cr${url}`, + dataType: "json", + success: function (d: StrongsCrossReference[], t, x) { - url = `data/rmac/rs${Math.ceil(sn / 1000)}.json`; - let rmac_cross_references: RMACCrossReference[]; + 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) + { + 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(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: 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) { - //Util.HandleError(error); + console.log(error); } }); - - // deal with RMAC - this.result.rmaccode = $.grep(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; } } \ No newline at end of file diff --git a/DynamicBibleIonic/src/types.ts b/DynamicBibleIonic/src/types.ts index b5acd54f..21835783 100644 --- a/DynamicBibleIonic/src/types.ts +++ b/DynamicBibleIonic/src/types.ts @@ -1,19 +1,21 @@ -type SearchResult = { +type WordLookupResult = { refs: string[], word: string, status: Status, msg: string } -enum Status {Success, Failure}; +enum Status { Success, Failure }; type IndexResult = { refs: 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 = { - strongs_modal: boolean + strongs_modal: boolean, + clear_search_after_query: boolean, + items: CardItem[] } type BiblePassage = { @@ -36,7 +38,6 @@ type BiblePassageResult = { ref: string } - type StrongsDefinition = { n: number, i: string, tr: string, de: string, lemma: string, p: string } type StrongsCrossReference = { diff --git a/DynamicBibleIonic/src/search-service.ts b/DynamicBibleIonic/src/word-service.ts similarity index 93% rename from DynamicBibleIonic/src/search-service.ts rename to DynamicBibleIonic/src/word-service.ts index 85577c1f..2a120bf9 100644 --- a/DynamicBibleIonic/src/search-service.ts +++ b/DynamicBibleIonic/src/word-service.ts @@ -4,16 +4,13 @@ import { Injectable } from "@angular/core"; import { Http } from "@angular/http"; @Injectable() -export class SearchService +export class WordService { - result: SearchResult; - count = 0; - constructor(private http: Http) { } - getResult(qry) + getResult(qry: string): WordLookupResult { qry = qry.toLowerCase(); 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. 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) { - 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 { let shared = this.findSharedSet(results); 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) { - //Util.HandleError(error); + console.log(error); } });