From 83b33958c4fd7e08064690987f37e72a0fed1dc2 Mon Sep 17 00:00:00 2001 From: "jason.wall" Date: Thu, 24 Aug 2017 10:54:15 -0400 Subject: [PATCH] MAID: tighten up syntax per the linter, fix a couple of minor display issues with verse picker, removed call to stemmer.js in index.html, updated to ng-template tag as template had been deprecated --- DynamicBibleIonic/src/app/app.component.ts | 4 +- DynamicBibleIonic/src/app/app.module.ts | 24 +-- .../component-loader/component-loader.ts | 8 +- .../components/error-message/error-message.ts | 6 +- .../src/components/error/error.ts | 12 +- .../src/components/passage/passage.html | 4 +- .../src/components/passage/passage.ts | 4 +- .../strongs-modal/strongs-modal.html | 8 +- .../src/components/strongs/strongs.html | 8 +- .../src/components/strongs/strongs.ts | 8 +- .../components/verse-picker/verse-picker.ts | 2 +- .../src/components/words/words.ts | 10 +- DynamicBibleIonic/src/index.html | 1 - DynamicBibleIonic/src/libs/Reference.ts | 37 ++-- DynamicBibleIonic/src/libs/Stemmer.ts | 54 +++--- DynamicBibleIonic/src/pages/search/search.ts | 162 ++++++++++-------- .../src/pages/settings/settings.html | 4 +- .../src/pages/settings/settings.ts | 6 +- DynamicBibleIonic/src/pipes/reverse-pipe.ts | 8 +- .../src/services/bible-service.ts | 12 +- .../src/services/strongs-service.ts | 10 +- .../src/services/word-service.ts | 6 +- DynamicBibleIonic/tslint.json | 70 ++++++-- DynamicBibleIonic/www/index.html | 1 - 24 files changed, 264 insertions(+), 205 deletions(-) diff --git a/DynamicBibleIonic/src/app/app.component.ts b/DynamicBibleIonic/src/app/app.component.ts index f993009f..10d49ddc 100644 --- a/DynamicBibleIonic/src/app/app.component.ts +++ b/DynamicBibleIonic/src/app/app.component.ts @@ -2,9 +2,9 @@ import { Component, ViewChild } from '@angular/core'; import { Platform, MenuController, Nav } from 'ionic-angular'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; -import { SearchPage } from "../pages/search/search"; +import { SearchPage } from '../pages/search/search'; -import { PagesService } from "../services/pages-service"; +import { PagesService } from '../services/pages-service'; @Component({ templateUrl: 'app.html', diff --git a/DynamicBibleIonic/src/app/app.module.ts b/DynamicBibleIonic/src/app/app.module.ts index f0ef45af..2521188d 100644 --- a/DynamicBibleIonic/src/app/app.module.ts +++ b/DynamicBibleIonic/src/app/app.module.ts @@ -1,27 +1,27 @@ import { NgModule, ErrorHandler } from '@angular/core'; -import { BrowserModule} from '@angular/platform-browser'; +import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; -import { IonicStorageModule } from '@ionic/storage'; +import { IonicStorageModule } from '@ionic/storage'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { MyApp } from './app.component'; -import { SearchPage } from "../pages/search/search"; -import { SettingsPage } from "../pages/settings/settings"; -import { HelpPage } from "../pages/help/help"; +import { SearchPage } from '../pages/search/search'; +import { SettingsPage } from '../pages/settings/settings'; +import { HelpPage } from '../pages/help/help'; -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'; import { ErrorMessage } from '../components/error-message/error-message'; -import { VersePickerModal} from '../components/verse-picker/verse-picker'; +import { VersePickerModal } from '../components/verse-picker/verse-picker'; @NgModule({ declarations: [ diff --git a/DynamicBibleIonic/src/components/component-loader/component-loader.ts b/DynamicBibleIonic/src/components/component-loader/component-loader.ts index 801e55b9..56b6b7ee 100644 --- a/DynamicBibleIonic/src/components/component-loader/component-loader.ts +++ b/DynamicBibleIonic/src/components/component-loader/component-loader.ts @@ -1,4 +1,4 @@ -//our root app component +// our root app component import {Component, Compiler, ViewContainerRef, ViewChild, Input, ComponentRef, ComponentFactoryResolver, ChangeDetectorRef} from '@angular/core' // Helper component to add dynamic components @@ -11,7 +11,7 @@ export class ComponentLoader { @Input() type; @Input() data; cmpRef: ComponentRef; - private isViewInitialized: boolean = false; + private isViewInitialized = false; constructor(private componentFactoryResolver: ComponentFactoryResolver, private compiler: Compiler, private cdRef: ChangeDetectorRef) { } @@ -24,7 +24,7 @@ export class ComponentLoader { this.cmpRef.destroy(); } - let factory = this.componentFactoryResolver.resolveComponentFactory(this.type); + const factory = this.componentFactoryResolver.resolveComponentFactory(this.type); this.cmpRef = this.target.createComponent(factory); // to access the created instance use // this.compRef.instance.someProperty = 'someValue'; @@ -49,4 +49,4 @@ export class ComponentLoader { this.cmpRef.destroy(); } } -} \ No newline at end of file +} diff --git a/DynamicBibleIonic/src/components/error-message/error-message.ts b/DynamicBibleIonic/src/components/error-message/error-message.ts index 3e7c6740..a1e65bc5 100644 --- a/DynamicBibleIonic/src/components/error-message/error-message.ts +++ b/DynamicBibleIonic/src/components/error-message/error-message.ts @@ -1,4 +1,4 @@ -import { Component, Input} from "@angular/core"; +import { Component, Input} from '@angular/core'; @Component({ selector: 'error-message', @@ -11,6 +11,6 @@ export class ErrorMessage constructor() { - this.msg = ""; + this.msg = ''; } -} \ No newline at end of file +} diff --git a/DynamicBibleIonic/src/components/error/error.ts b/DynamicBibleIonic/src/components/error/error.ts index eb4fa540..3a9ffa38 100644 --- a/DynamicBibleIonic/src/components/error/error.ts +++ b/DynamicBibleIonic/src/components/error/error.ts @@ -1,9 +1,9 @@ -import { EventEmitter, Component, Input, Output, ElementRef } from "@angular/core"; -import { CardItem } from "../../pages/search/search"; +import { EventEmitter, Component, Input, Output, ElementRef } from '@angular/core'; +import { CardItem } from '../../pages/search/search'; @Component({ - selector: "error", - templateUrl: "error.html" + selector: 'error', + templateUrl: 'error.html' }) export class Error { @@ -19,7 +19,7 @@ export class Error close() { - let d = 275; + const d = 275; this.elementRef.nativeElement.parentElement.animate({ transform: ['none', 'translate3d(110%, 0, 0)'] }, { @@ -33,4 +33,4 @@ export class Error this.onClose.emit(this.cardItem); }, d); } -} \ No newline at end of file +} diff --git a/DynamicBibleIonic/src/components/passage/passage.html b/DynamicBibleIonic/src/components/passage/passage.html index b314d948..ba1e127a 100644 --- a/DynamicBibleIonic/src/components/passage/passage.html +++ b/DynamicBibleIonic/src/components/passage/passage.html @@ -12,8 +12,8 @@ {{vs.v}}. - {{w.t}} - + {{w.t}} + {{w.t}}
diff --git a/DynamicBibleIonic/src/components/passage/passage.ts b/DynamicBibleIonic/src/components/passage/passage.ts index b9d3a8d2..0360b6d6 100644 --- a/DynamicBibleIonic/src/components/passage/passage.ts +++ b/DynamicBibleIonic/src/components/passage/passage.ts @@ -53,7 +53,7 @@ export class Passage implements OnInit next() { - let last_verse_for_end = this.ref.Section.end.book.chapters[parseInt(this.ref.Section.end.chapter)].toString(); + const last_verse_for_end = this.ref.Section.end.book.chapters[parseInt(this.ref.Section.end.chapter)].toString(); if (this.ref.Section.end.verse !== '*' && this.ref.Section.end.verse !== last_verse_for_end) this.ref.Section.end.chapter = this.ref.Section.end.chapter; @@ -93,7 +93,7 @@ export class Passage implements OnInit expand() { - let last_verse_for_end = this.ref.Section.end.book.chapters[parseInt(this.ref.Section.end.chapter)]; + const last_verse_for_end = this.ref.Section.end.book.chapters[parseInt(this.ref.Section.end.chapter)]; // if your verse is at the beginning, to go the prev chapter and add 3 verses from that if (parseInt(this.ref.Section.start.verse) < 4) diff --git a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html index 45e6125e..82d5d538 100644 --- a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html +++ b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html @@ -14,11 +14,11 @@

Strong's Definitition

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

- +

Cross References

   Translated as {{item.crossrefs.ss.length}} words diff --git a/DynamicBibleIonic/src/components/strongs/strongs.html b/DynamicBibleIonic/src/components/strongs/strongs.html index e894c235..f2837b90 100644 --- a/DynamicBibleIonic/src/components/strongs/strongs.html +++ b/DynamicBibleIonic/src/components/strongs/strongs.html @@ -9,11 +9,11 @@

Strong's Definitition

- {{data.def.tr}} + {{data.def.tr}} ({{data.def.sn}}) - {{data.def.p}} - {{data.def.lemma}} - -
+ {{part.sn}}

- +

Cross References

diff --git a/DynamicBibleIonic/src/components/strongs/strongs.ts b/DynamicBibleIonic/src/components/strongs/strongs.ts index 9882fdf5..cfb8a088 100644 --- a/DynamicBibleIonic/src/components/strongs/strongs.ts +++ b/DynamicBibleIonic/src/components/strongs/strongs.ts @@ -8,7 +8,7 @@ import { StrongsResult, StrongsService } from '../../services/strongs-service'; templateUrl: 'strongs.html', providers: [StrongsService] }) -export class Strongs implements AfterViewChecked, OnInit +export class Strongs implements AfterViewChecked, OnInit { @Output() onClose = new EventEmitter(); @@ -53,7 +53,7 @@ export class Strongs implements AfterViewChecked, OnInit close() { - let d = 275; + const d = 275; this.elementRef.nativeElement.parentElement.animate({ transform: ['none', 'translate3d(110%, 0, 0)'] }, { @@ -78,9 +78,9 @@ export class Strongs implements AfterViewChecked, OnInit return Reference.bookName(parseInt(p.split(';')[0])).name + ' ' + p.split(';')[1] + ':' + p.split(';')[2]; } - openPassage(p: string) + openPassage(p: string) { - let ref = this.makePassage(p); + const ref = this.makePassage(p); this.onItemClicked.emit({ card: this.cardItem, qry: ref, from_search_bar: false }); } } diff --git a/DynamicBibleIonic/src/components/verse-picker/verse-picker.ts b/DynamicBibleIonic/src/components/verse-picker/verse-picker.ts index 9b9b9e22..22e5f763 100644 --- a/DynamicBibleIonic/src/components/verse-picker/verse-picker.ts +++ b/DynamicBibleIonic/src/components/verse-picker/verse-picker.ts @@ -11,7 +11,7 @@ export class VersePickerModal @Output() onItemClicked = new EventEmitter(); books: Array; - hasBook: boolean = false; + hasBook = false; book: Book; constructor( diff --git a/DynamicBibleIonic/src/components/words/words.ts b/DynamicBibleIonic/src/components/words/words.ts index f4ff6a9e..5bdcb935 100644 --- a/DynamicBibleIonic/src/components/words/words.ts +++ b/DynamicBibleIonic/src/components/words/words.ts @@ -9,7 +9,7 @@ import { WordLookupResult, WordService } from '../../services/word-service'; templateUrl: 'words.html', providers: [WordService] }) -export class Words implements AfterViewChecked, OnInit +export class Words implements AfterViewChecked, OnInit { @Output() onClose = new EventEmitter(); @@ -33,8 +33,8 @@ export class Words implements AfterViewChecked, OnInit { $('words ion-scroll').each((i, el) => { - let wr = $(el).find('.scroll-content .scroll-zoom-wrapper')[0]; - let len = $(el).find('.scroll-zoom-wrapper a').length; + const wr = $(el).find('.scroll-content .scroll-zoom-wrapper')[0]; + const len = $(el).find('.scroll-zoom-wrapper a').length; if (wr.scrollWidth < 500) // 1 col { @@ -82,7 +82,7 @@ export class Words implements AfterViewChecked, OnInit close() { - let d = 275; + const d = 275; this.elementRef.nativeElement.parentElement.animate({ transform: ['none', 'translate3d(110%, 0, 0)'] }, { @@ -104,7 +104,7 @@ export class Words implements AfterViewChecked, OnInit openPassage(p: string) { - let ref = this.makePassage(p); + const ref = this.makePassage(p); this.onItemClicked.emit({ card: this.cardItem, qry: ref, from_search_bar: false }); } } diff --git a/DynamicBibleIonic/src/index.html b/DynamicBibleIonic/src/index.html index a1bbc74d..715d7613 100644 --- a/DynamicBibleIonic/src/index.html +++ b/DynamicBibleIonic/src/index.html @@ -34,6 +34,5 @@ - diff --git a/DynamicBibleIonic/src/libs/Reference.ts b/DynamicBibleIonic/src/libs/Reference.ts index ca0fe672..8b103dec 100644 --- a/DynamicBibleIonic/src/libs/Reference.ts +++ b/DynamicBibleIonic/src/libs/Reference.ts @@ -24,9 +24,8 @@ class StringUtils export class Reference { private ref: string; - public Section: Section; - - public errAcc: string; + Section: Section; + errAcc: string; constructor(reference: string) { @@ -64,10 +63,10 @@ export class Reference { this.parseBook(false); this.parseFirstNum(false); - let foundFirstVerse = this.ref.search(/:.*-/) !== -1; + const foundFirstVerse = this.ref.search(/:.*-/) !== -1; this.maybeParseSecondNum(false); this.maybeParseRangeSep(); - let foundSecondBook = this.ref.search(/\w\s+\d/i) !== -1; + const foundSecondBook = this.ref.search(/\w\s+\d/i) !== -1; this.maybeParseBook(true); this.maybeParseFirstNumOrVerse(foundSecondBook, foundFirstVerse, true); @@ -95,7 +94,7 @@ export class Reference let found = false; for (let i = 0; i <= this.ref.length; i++) { - let c = this.ref.charAt(i); + const c = this.ref.charAt(i); // Grab characters until we hit a non digit. if ('0'.charAt(0) <= c && c <= '9'.charAt(0)) { @@ -141,9 +140,9 @@ export class Reference this.ref = this.ref.slice(1); return; } - for (var i = 0; i <= this.ref.length; i++) + for (let i = 0; i <= this.ref.length; i++) { - let c = this.ref.charAt(i); + const c = this.ref.charAt(i); if ('0'.charAt(0) <= c && c <= '9'.charAt(0)) { thing.verse = thing.verse.concat(c); @@ -186,7 +185,7 @@ export class Reference private maybeParseFirstNumOrVerse(foundSecondBook: boolean, foundFirstVerse: boolean, isEnd: boolean) { - let self = this; + const self = this; return this.maybeDo(() => { if (self.Section.end.book.name === self.Section.start.book.name) @@ -202,7 +201,7 @@ export class Reference private maybeParseRangeSep() { - let self = this; + const self = this; return this.maybeDo(() => { if (self.ref[0] === '-') @@ -214,7 +213,7 @@ export class Reference private maybeDo(f) { - let func = f; + const func = f; this.ref = StringUtils.ltrim(this.ref.toLowerCase()); if (this.ref !== '') { @@ -585,7 +584,7 @@ export class Reference { book_number: 6, name: 'Joshua', - short_name: 'Joshua', + short_name: 'Josh', long_name: 'Book of Joshua', last_chapter: 24, chapters: [0, 18, 24, 17, 24, 15, 27, 26, 35, 27, 43, 23, 24, 33, 15, 63, 10, 18, 28, 51, 9, 45, 34, 16, 33] @@ -593,7 +592,7 @@ export class Reference { book_number: 7, name: 'Judges', - short_name: 'Judges', + short_name: 'Jud', long_name: 'Book of Judges', last_chapter: 21, chapters: [0, 36, 23, 31, 24, 31, 40, 25, 35, 57, 18, 40, 15, 25, 20, 20, 31, 13, 31, 30, 48, 25] @@ -625,7 +624,7 @@ export class Reference { book_number: 11, name: '1 Kings', - short_name: '1 Kngs', + short_name: '1 Kng', long_name: 'First Book of Kings', last_chapter: 22, chapters: [0, 53, 46, 28, 34, 18, 38, 51, 66, 28, 29, 43, 33, 34, 31, 34, 34, 24, 46, 21, 43, 29, 53] @@ -633,7 +632,7 @@ export class Reference { book_number: 12, name: '2 Kings', - short_name: '2 Kngs', + short_name: '2 Kng', long_name: 'Second Book of Kings', last_chapter: 25, chapters: [0, 18, 25, 27, 44, 27, 33, 20, 29, 37, 36, 21, 21, 25, 29, 38, 20, 41, 37, 37, 21, 26, 20, 37, 20, 30] @@ -721,7 +720,7 @@ export class Reference { book_number: 23, name: 'Isaiah', - short_name: 'Isaiah', + short_name: 'Isa', long_name: 'Book of Isaiah', last_chapter: 66, chapters: [0, 31, 22, 26, 6, 30, 13, 25, 22, 21, 34, 16, 6, 22, 32, 9, 14, 14, 7, 25, 6, 17, 25, 18, 23, 12, 21, 13, 29, 24, 33, 9, 20, 24, 17, 10, 22, 38, 22, 8, 31, 29, 25, 28, 28, 25, 13, 15, 22, 26, 11, 23, 15, 12, 17, 13, 12, 21, 14, 21, 22, 11, 12, 19, 12, 25, 24] @@ -753,7 +752,7 @@ export class Reference { book_number: 27, name: 'Daniel', - short_name: 'Daniel', + short_name: 'Dan', long_name: 'Book of Daniel', last_chapter: 12, chapters: [0, 21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13] @@ -953,7 +952,7 @@ export class Reference { book_number: 52, name: '1 Thessalonians', - short_name: '1 Thess', + short_name: '1 Thes', long_name: 'First Epistle to the Thessalonians', last_chapter: 5, chapters: [0, 10, 20, 13, 18, 28] @@ -961,7 +960,7 @@ export class Reference { book_number: 53, name: '2 Thessalonians', - short_name: '2 Thess', + short_name: '2 Thes', long_name: 'Second Epistle to the Thessalonians', last_chapter: 3, chapters: [0, 12, 17, 18] diff --git a/DynamicBibleIonic/src/libs/Stemmer.ts b/DynamicBibleIonic/src/libs/Stemmer.ts index 512bfa24..861df1d8 100644 --- a/DynamicBibleIonic/src/libs/Stemmer.ts +++ b/DynamicBibleIonic/src/libs/Stemmer.ts @@ -1,9 +1,9 @@ /* Character code for `y`. */ -var CC_Y = 'y'.charCodeAt(0); +const CC_Y = 'y'.charCodeAt(0); /* Standard suffix manipulations. */ -var step2list = { +const step2list = { ational: 'ate', tional: 'tion', enci: 'ence', @@ -27,7 +27,7 @@ var step2list = { logi: 'log' }; -var step3list = { +const step3list = { icate: 'ic', ative: '', alize: 'al', @@ -39,52 +39,52 @@ var step3list = { /* Consonant-vowel sequences. */ -var consonant = '[^aeiou]'; -var vowel = '[aeiouy]'; -var consonantSequence = '(' + consonant + '[^aeiouy]*)'; -var vowelSequence = '(' + vowel + '[aeiou]*)'; +const consonant = '[^aeiou]'; +const vowel = '[aeiouy]'; +const consonantSequence = '(' + consonant + '[^aeiouy]*)'; +const vowelSequence = '(' + vowel + '[aeiou]*)'; -var MEASURE_GT_0 = new RegExp( +const MEASURE_GT_0 = new RegExp( '^' + consonantSequence + '?' + vowelSequence + consonantSequence ); -var MEASURE_EQ_1 = new RegExp( +const MEASURE_EQ_1 = new RegExp( '^' + consonantSequence + '?' + vowelSequence + consonantSequence + vowelSequence + '?$' ); -var MEASURE_GT_1 = new RegExp( +const MEASURE_GT_1 = new RegExp( '^' + consonantSequence + '?' + '(' + vowelSequence + consonantSequence + '){2,}' ); -var VOWEL_IN_STEM = new RegExp( +const VOWEL_IN_STEM = new RegExp( '^' + consonantSequence + '?' + vowel ); -var CONSONANT_LIKE = new RegExp( +const CONSONANT_LIKE = new RegExp( '^' + consonantSequence + vowel + '[^aeiouwxy]$' ); /* Exception expressions. */ -var SUFFIX_LL = /ll$/; -var SUFFIX_E = /^(.+?)e$/; -var SUFFIX_Y = /^(.+?)y$/; -var SUFFIX_ION = /^(.+?(s|t))(ion)$/; -var SUFFIX_ED_OR_ING = /^(.+?)(ed|ing)$/; -var SUFFIX_AT_OR_BL_OR_IZ = /(at|bl|iz)$/; -var SUFFIX_EED = /^(.+?)eed$/; -var SUFFIX_S = /^.+?[^s]s$/; -var SUFFIX_SSES_OR_IES = /^.+?(ss|i)es$/; -var SUFFIX_MULTI_CONSONANT_LIKE = /([^aeiouylsz])\1$/; -var STEP_2 = new RegExp( +const SUFFIX_LL = /ll$/; +const SUFFIX_E = /^(.+?)e$/; +const SUFFIX_Y = /^(.+?)y$/; +const SUFFIX_ION = /^(.+?(s|t))(ion)$/; +const SUFFIX_ED_OR_ING = /^(.+?)(ed|ing)$/; +const SUFFIX_AT_OR_BL_OR_IZ = /(at|bl|iz)$/; +const SUFFIX_EED = /^(.+?)eed$/; +const SUFFIX_S = /^.+?[^s]s$/; +const SUFFIX_SSES_OR_IES = /^.+?(ss|i)es$/; +const SUFFIX_MULTI_CONSONANT_LIKE = /([^aeiouylsz])\1$/; +const STEP_2 = new RegExp( '^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|' + 'ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|' + 'biliti|logi)$' ); -var STEP_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; -var STEP_4 = new RegExp( +const STEP_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; +const STEP_4 = new RegExp( '^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|' + 'iti|ous|ive|ize)$' ); @@ -92,8 +92,8 @@ var STEP_4 = new RegExp( /* Stem `value`. */ export function stemmer(value) { - var firstCharacterWasLowerCaseY; - var match; + let firstCharacterWasLowerCaseY; + let match; value = String(value).toLowerCase(); diff --git a/DynamicBibleIonic/src/pages/search/search.ts b/DynamicBibleIonic/src/pages/search/search.ts index b209fde0..7fee9e62 100644 --- a/DynamicBibleIonic/src/pages/search/search.ts +++ b/DynamicBibleIonic/src/pages/search/search.ts @@ -64,41 +64,55 @@ export class SearchPage implements OnInit let has_migrated = false; for (let i in u.user.items) { - let ci = u.user.items[i]; - if (ci['data'] !== undefined) - { - if (ci['data'].qry !== undefined) - u.user.items[i] = { qry: ci['data'].qry, dict: ci.dict, type: ci.type }; - else if (ci['data'].ref !== undefined) - u.user.items[i] = { qry: ci['data'].ref, dict: ci.dict, type: ci.type }; - else if (ci['data'].word !== undefined) - u.user.items[i] = { qry: ci['data'].word, dict: ci.dict, type: ci.type }; - else if (ci['data'].sn !== undefined) - u.user.items[i] = { qry: ci['data'].sn, dict: ci['prefix'] === 'G' ? 'grk' : 'heb', type: ci.type }; - - has_migrated = true; - } - } - + if (u.user.items.hasOwnProperty(i)) + { + let ci = u.user.items[i]; + if (ci['data'] !== undefined) + { + if (ci['data'].qry !== undefined) + u.user.items[i] = { qry: ci['data'].qry, dict: ci.dict, type: ci.type }; + else if (ci['data'].ref !== undefined) + u.user.items[i] = { qry: ci['data'].ref, dict: ci.dict, type: ci.type }; + else if (ci['data'].word !== undefined) + u.user.items[i] = { qry: ci['data'].word, dict: ci.dict, type: ci.type }; + else if (ci['data'].sn !== undefined) + u.user.items[i] = { + qry: ci['data'].sn, + dict: ci['prefix'] === 'G' ? 'grk' : 'heb', + type: ci.type + }; + + has_migrated = true; + } + } + } + for (let pg of u.user.saved_pages) { for (let i in pg.queries) { - let ci = pg.queries[i]; - if (ci['data'] !== undefined) - { - if (ci['data'].qry !== undefined) - pg.queries[i] = { qry: ci['data'].qry, dict: ci.dict, type: ci.type }; - else if (ci['data'].ref !== undefined) - pg.queries[i] = { qry: ci['data'].ref, dict: ci.dict, type: ci.type }; - else if (ci['data'].word !== undefined) - pg.queries[i] = { qry: ci['data'].word, dict: ci.dict, type: ci.type }; - else if (ci['data'].sn !== undefined) - pg.queries[i] = { qry: ci['data'].sn, dict: ci['prefix'] === 'G' ? 'grk' : 'heb', type: ci.type }; - - has_migrated = true; - } - } + if (pg.queries.hasOwnProperty(i)) + { + let ci = pg.queries[i]; + if (ci['data'] !== undefined) + { + if (ci['data'].qry !== undefined) + pg.queries[i] = { qry: ci['data'].qry, dict: ci.dict, type: ci.type }; + else if (ci['data'].ref !== undefined) + pg.queries[i] = { qry: ci['data'].ref, dict: ci.dict, type: ci.type }; + else if (ci['data'].word !== undefined) + pg.queries[i] = { qry: ci['data'].word, dict: ci.dict, type: ci.type }; + else if (ci['data'].sn !== undefined) + pg.queries[i] = { + qry: ci['data'].sn, + dict: ci['prefix'] === 'G' ? 'grk' : 'heb', + type: ci.type + }; + + has_migrated = true; + } + } + } } // initialize the pages. @@ -130,44 +144,45 @@ export class SearchPage implements OnInit this.menu.open('actions'); } - addPage() + addPage() { - let alert = this.alertCtrl.create({ - title: 'Save Search as Page', - inputs: [ - { - name: 'title', - placeholder: 'Page Title' - } - ], - buttons: [ - { - text: 'Cancel', - role: 'cancel', - handler: (): void => - { - console.log('Cancel clicked'); - } - }, - { - text: 'Save', - handler: data => - { - let p = { queries: this.userProfile.user.items.slice(), title: data.title }; + const alert = this.alertCtrl.create({ + title: 'Save Search as Page', + inputs: [ + { + name: 'title', + placeholder: 'Page Title' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + handler: (): void => + { + console.log('Cancel clicked'); + } + }, + { + text: 'Save', + handler: data => + { + const p = { queries: this.userProfile.user.items.slice(), title: data.title }; this.userProfile.user.saved_pages.push(p); this.userProfile.save(this.local); - this.pagesService.addPage(p); - } - } - ] - }); + this.pagesService.addPage(p); + } + } + ] + }); alert.present(); } + updatePage() { - let page = this.userProfile.user.saved_pages.find( + const page = this.userProfile.user.saved_pages.find( i => - i.title === this.params.data.title + i.title === this.params.data.title ); page.queries = this.userProfile.user.items.slice(); this.userProfile.save(this.local); @@ -201,13 +216,13 @@ export class SearchPage implements OnInit versePicker() { - let modal = this.modalCtrl.create(VersePickerModal, { onItemClicked: this }); + const modal = this.modalCtrl.create(VersePickerModal, { onItemClicked: this }); modal.present(); } removeItem(item) { - let idx = this.userProfile.user.items.indexOf(item); + const idx = this.userProfile.user.items.indexOf(item); this.userProfile.user.items.splice(idx, 1); // save the users settings. @@ -219,20 +234,18 @@ export class SearchPage implements OnInit { if (this.last != null && this.userProfile.user.insert_next_to_item) { - let idx = this.userProfile.user.items.indexOf(this.last); + const idx = this.userProfile.user.items.indexOf(this.last); this.userProfile.user.items.splice(idx + 1, 0, item); - } - else + } else this.userProfile.user.items.push(item); } else { if (this.last != null && this.userProfile.user.insert_next_to_item) { - let idx = this.userProfile.user.items.indexOf(this.last); + const idx = this.userProfile.user.items.indexOf(this.last); this.userProfile.user.items.splice(idx, 0, item); - } - else + } else this.userProfile.user.items.unshift(item); } this.last = null; @@ -247,11 +260,11 @@ export class SearchPage implements OnInit { return new Promise((resolve) => { - let list: CardItem[] = []; + const list: CardItem[] = []; try { - let qs = search.split(';'); + const qs = search.split(';'); for (let x in qs) { if (qs.hasOwnProperty(x)) @@ -280,7 +293,7 @@ export class SearchPage implements OnInit // its a verse reference. if (q.trim() !== '') { - let myref = new Reference(q.trim()); + const myref = new Reference(q.trim()); list.push({ qry: myref.toString(), dict: myref.Section.start.book.book_number > 39 ? 'G' : 'H', type: 'Passage' }); } } @@ -314,10 +327,9 @@ export class SearchPage implements OnInit { if (item.type === 'Strongs' && this.userProfile.user.strongs_modal && !from_search_bar) { - let modal = this.modalCtrl.create(StrongsModal, { sn: parseInt(item.qry), dict: item.dict, onItemClicked: this }); + const modal = this.modalCtrl.create(StrongsModal, { sn: parseInt(item.qry), dict: item.dict, onItemClicked: this }); modal.present(); - } - else + } else this.addItemToList(item); } this.loader.dismiss(); diff --git a/DynamicBibleIonic/src/pages/settings/settings.html b/DynamicBibleIonic/src/pages/settings/settings.html index 5b8b3de3..aacb688b 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.html +++ b/DynamicBibleIonic/src/pages/settings/settings.html @@ -7,7 +7,7 @@ - + diff --git a/DynamicBibleIonic/src/pages/settings/settings.ts b/DynamicBibleIonic/src/pages/settings/settings.ts index b0900ac4..38396cec 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.ts +++ b/DynamicBibleIonic/src/pages/settings/settings.ts @@ -1,4 +1,4 @@ -/// +/// import { Component } from '@angular/core'; import { NavController, AlertController } from 'ionic-angular'; import { Storage } from '@ionic/storage'; @@ -10,7 +10,7 @@ import { SavedPage, UserProfile } from '../../libs/UserProfile'; }) export class SettingsPage { - textSize: number = 0; + textSize = 0; userProfile: UserProfile; constructor( @@ -80,4 +80,4 @@ export class SettingsPage }); alert.present(); } -} \ No newline at end of file +} diff --git a/DynamicBibleIonic/src/pipes/reverse-pipe.ts b/DynamicBibleIonic/src/pipes/reverse-pipe.ts index c1a1b6c3..fdc7b088 100644 --- a/DynamicBibleIonic/src/pipes/reverse-pipe.ts +++ b/DynamicBibleIonic/src/pipes/reverse-pipe.ts @@ -1,12 +1,12 @@ -import { Pipe, PipeTransform } from "@angular/core"; +import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ - name: "reverse" + name: 'reverse' }) export class ReversePipe implements PipeTransform { - transform(value: any[]) : any[] + transform(value: any[]): any[] { return value.slice().reverse(); } -} \ No newline at end of file +} diff --git a/DynamicBibleIonic/src/services/bible-service.ts b/DynamicBibleIonic/src/services/bible-service.ts index c513482c..01bd5203 100644 --- a/DynamicBibleIonic/src/services/bible-service.ts +++ b/DynamicBibleIonic/src/services/bible-service.ts @@ -9,7 +9,7 @@ export class BibleService { chapters: BiblePassage[]; result: BiblePassageResult; - count: number = 0; + count = 0; $: any; constructor(private http: Http) @@ -25,7 +25,7 @@ export class BibleService { try { - var self = this; + const self = this; this.chapters = []; // the verses from the chapter. this.result = { cs: [], @@ -60,11 +60,11 @@ export class BibleService type: 'GET', url: url, dataType: 'json', - success(d: BiblePassage, t, x) + success(d: BiblePassage) { self.chapters.push(d); }, - error(request, status, error) + error() { self.result.status = -1; self.result.msg = 'Unable to retrieve bible passage ' + self.result.ref + '.'; @@ -117,8 +117,8 @@ export class BibleService vss.push(this.chapters[j].vss[i - 1]); this.result.cs.push({ - "ch": this.chapters[j].ch, - "vss": vss + ch: this.chapters[j].ch, + vss: vss }); } diff --git a/DynamicBibleIonic/src/services/strongs-service.ts b/DynamicBibleIonic/src/services/strongs-service.ts index df85ee62..588a685c 100644 --- a/DynamicBibleIonic/src/services/strongs-service.ts +++ b/DynamicBibleIonic/src/services/strongs-service.ts @@ -38,7 +38,7 @@ export class StrongsService if (sn > 5624 || sn < 1) { self.result.status = -1; - self.result.msg = "Strong's Number G" + sn + " is out of range. Strong's numbers range from 1 - 5624 in the New Testament."; + self.result.msg = 'Strong\'s Number G' + sn + ' is out of range. Strong\'s numbers range from 1 - 5624 in the New Testament.'; } } else @@ -47,7 +47,7 @@ export class StrongsService if (sn > 8674 || sn < 1) { self.result.status = -1; - self.result.msg = "Strong's Number H" + sn + " is out of range. Strong's numbers range from 1 - 8674 in the Old Testament."; + self.result.msg = 'Strong\'s Number H' + sn + ' is out of range. Strong\'s numbers range from 1 - 8674 in the Old Testament.'; } } this.result.sn = sn; @@ -68,7 +68,7 @@ export class StrongsService { console.log(error); self.result.status = -1; - self.result.msg = "Unable to retrieve Strong's Data for " + self.result.prefix + self.result.sn; + self.result.msg = 'Unable to retrieve Strong\'s Data for ' + self.result.prefix + self.result.sn; } }); @@ -98,7 +98,7 @@ export class StrongsService { console.log(error); self.result.status = -1; - self.result.msg = "Unable to retrieve Strong's Cross References for " + self.result.prefix + self.result.sn; + self.result.msg = 'Unable to retrieve Strong\'s Cross References for ' + self.result.prefix + self.result.sn; } }); @@ -132,7 +132,7 @@ export class StrongsService 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({ diff --git a/DynamicBibleIonic/src/services/word-service.ts b/DynamicBibleIonic/src/services/word-service.ts index 79a72304..565f43fd 100644 --- a/DynamicBibleIonic/src/services/word-service.ts +++ b/DynamicBibleIonic/src/services/word-service.ts @@ -114,7 +114,7 @@ export class WordService private buildIndexArray() { - let words = new Array(); + const words = new Array(); words.unshift('abishur'); words.unshift('achor'); words.unshift('adoni'); @@ -358,8 +358,8 @@ export class WordService // declare terminator let t = (x.length < y.length) ? x.length : y.length; // sort the arrays - x.sort((x, y) => x - y); - y.sort((x, y) => x - y); + x.sort((a, b) => a - b); + y.sort((a, b) => a - b); // in this loop, we remove from the arrays, the // values that aren't shared between them. while (i < t) diff --git a/DynamicBibleIonic/tslint.json b/DynamicBibleIonic/tslint.json index 564c9ba0..db3310a5 100644 --- a/DynamicBibleIonic/tslint.json +++ b/DynamicBibleIonic/tslint.json @@ -1,11 +1,61 @@ -{ - "rules": { - "no-duplicate-variable": true, - "no-unused-variable": [ - false - ] - }, - "rulesDirectory": [ - "node_modules/tslint-eslint-rules/dist/rules" - ] +{ + "rules": { + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "forin": true, + "import-blacklist": [ true, "rxjs" ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "label-position": true, + "member-access": false, + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "quotemark": [ + true, + "single" + ], + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false + + }, + "rulesDirectory": [ + "node_modules/tslint-eslint-rules/dist/rules" + ] } diff --git a/DynamicBibleIonic/www/index.html b/DynamicBibleIonic/www/index.html index 052d21b5..0d323bb4 100644 --- a/DynamicBibleIonic/www/index.html +++ b/DynamicBibleIonic/www/index.html @@ -37,6 +37,5 @@ -