mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 16:29:49 -04:00
FIX: Bug Fixes
* fixed misspelling of Titus in verse picker * fixed paragraph heading option being ignored * added option to sync items * adjusted max width of the cards, as multiple columns is difficult to navigate or read. * fixed sync| we now use a simple method where we take whatever is on the server. this will result in lost pages if you save pages when logged out then log in, but it works better than any other method for now.
This commit is contained in:
parent
7a0bc2f2b2
commit
4de4039d6e
File diff suppressed because one or more lines are too long
@ -11,7 +11,7 @@
|
||||
<b>Chapter {{ch.ch}}</b>
|
||||
</h2>
|
||||
<div *ngFor="let para of ch.paras">
|
||||
<h3 *ngIf="hasHeader(para.p)">{{para.p.h}}</h3>
|
||||
<h3 *ngIf="this.profileService.profile().show_paragraph_headings && hasHeader(para.p)">{{para.p.h}}</h3>
|
||||
<p>
|
||||
<ng-template ngFor let-vs [ngForOf]="para.vss">
|
||||
<b *ngIf="this.profileService.profile().show_verse_numbers">{{vs.v}}.</b> <ng-template ngFor let-w [ngForOf]="vs.w">
|
||||
|
@ -15,15 +15,12 @@ passage .button {
|
||||
|
||||
passage .passage-text {
|
||||
padding-bottom: 12px;
|
||||
|
||||
h3 {
|
||||
font-size: 1.6rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p {
|
||||
//text-indent: 1em;
|
||||
}
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.passage-text + .passage-text {
|
||||
@ -31,36 +28,20 @@ passage .passage-text {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 700px) {
|
||||
passage .passage-text {
|
||||
-webkit-column-count: 2; /* Chrome, Safari, Opera */
|
||||
-moz-column-count: 2; /* Firefox */
|
||||
column-count: 2;
|
||||
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
|
||||
-moz-column-gap: 30px; /* Firefox */
|
||||
column-gap: 30px;
|
||||
-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: 600px) {
|
||||
// passage .passage-text {
|
||||
// -webkit-column-count: 2; /* Chrome, Safari, Opera */
|
||||
// -moz-column-count: 2; /* Firefox */
|
||||
// column-count: 2;
|
||||
// -webkit-column-gap: 30px; /* Chrome, Safari, Opera */
|
||||
// -moz-column-gap: 30px; /* Firefox */
|
||||
// column-gap: 30px;
|
||||
// -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: 900px) {
|
||||
passage .passage-text {
|
||||
-webkit-column-count: 3; /* Chrome, Safari, Opera */
|
||||
-moz-column-count: 3; /* Firefox */
|
||||
column-count: 3;
|
||||
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
|
||||
-moz-column-gap: 30px; /* Firefox */
|
||||
column-gap: 30px;
|
||||
-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;
|
||||
}
|
||||
}
|
||||
|
29
DynamicBibleIonic/src/directives/long-press.ts
Normal file
29
DynamicBibleIonic/src/directives/long-press.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {Directive, ElementRef, OnInit, OnDestroy, Output, EventEmitter} from '@angular/core';
|
||||
import {Gesture} from 'ionic-angular/gestures/gesture';
|
||||
|
||||
@Directive({
|
||||
selector: '[longPress]'
|
||||
})
|
||||
export class PressDirective implements OnInit, OnDestroy {
|
||||
el: HTMLElement;
|
||||
pressGesture: Gesture;
|
||||
|
||||
@Output()
|
||||
longPress: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
constructor(el: ElementRef) {
|
||||
this.el = el.nativeElement;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.pressGesture = new Gesture(this.el);
|
||||
this.pressGesture.listen();
|
||||
this.pressGesture.on('press', e => {
|
||||
this.longPress.emit(e);
|
||||
})
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.pressGesture.destroy();
|
||||
}
|
||||
}
|
@ -986,7 +986,7 @@ export class Reference
|
||||
{
|
||||
book_number: 56,
|
||||
name: 'Titus',
|
||||
short_name: 'Titis',
|
||||
short_name: 'Titus',
|
||||
long_name: 'Epistle to Titus',
|
||||
last_chapter: 3,
|
||||
chapters: [0, 16, 15, 15]
|
||||
@ -1085,7 +1085,7 @@ export type Book = {
|
||||
long_name: string,
|
||||
book_number: number,
|
||||
last_chapter: number,
|
||||
chapters: [number],
|
||||
chapters: Array<number>,
|
||||
};
|
||||
|
||||
export type Section = {
|
||||
|
@ -9,8 +9,7 @@
|
||||
<ion-content padding>
|
||||
<h2>How to search for a verse</h2>
|
||||
<p>
|
||||
Dynamic Bible doesn't yet have a verse picker. If you need a verse picker, hang on, we're diligently working on that feature. In the mean time, to bring up a passage,
|
||||
just type in a reference. Dynamic Bible will recognize most abbreviations of books, and can handle ranges within a book. Here are a few examples to get you started:
|
||||
To bring up a passage, just type in a reference, or use the verse picker in the top right corner. Dynamic Bible will recognize most abbreviations of books, and can handle ranges within a book. Here are a few examples to get you started:
|
||||
</p>
|
||||
<h3>Examples of Search Items:</h3>
|
||||
<ul>
|
||||
@ -40,7 +39,7 @@
|
||||
<h3>Visit Us Online</h3>
|
||||
<p>
|
||||
<a href="http://www.dynamicbible.com">www.dynamicbible.com</a> hosts the online version of the web app. We are currently available on the
|
||||
<a href="https://bitbucket.org/walljm/dynamicbible/downloads/DynamicBible-3.0.0-beta15.apk">Windows Platform</a> via the <a href="http://electron.atom.io/">Electron app from atom.io</a>
|
||||
<a href="https://bitbucket.org/walljm/dynamicbible/downloads/DynamicBible-3.1.0.zip">Windows Platform</a> via the <a href="http://electron.atom.io/">Electron app from atom.io</a>
|
||||
and on the <a href="https://play.google.com/store/apps/details?id=walljm.dynamicbible">Google Android Play store</a>.
|
||||
|
||||
We are working on an IOS distribution and will be releasing that soon.
|
||||
|
@ -36,6 +36,8 @@
|
||||
<ion-label>Insert Result Next to Item</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="this.profileService.profile().insert_next_to_item" (ionChange)="this.profileService.localSave()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-list-header>Display Settings</ion-list-header>
|
||||
<ion-item>
|
||||
<ion-label>Each Verse on New Line</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="this.profileService.profile().verses_on_new_line" (ionChange)="this.profileService.localSave()"></ion-toggle>
|
||||
@ -53,6 +55,12 @@
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().show_paragraph_headings" (ionChange)="this.profileService.localSave()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-list-header>Profile Settings</ion-list-header>
|
||||
<ion-item>
|
||||
<ion-label>Sync Search Items</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().sync_search_items" (ionChange)="this.profileService.localSave()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-list-header>Adjust Text</ion-list-header>
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
|
@ -25,13 +25,20 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
ion-content {
|
||||
.scroll-content {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
h2 {
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
font-family: "Roboto", "Arial", "Helvetica", sans-serif;
|
||||
max-width: 800px;
|
||||
margin: 12px auto;
|
||||
}
|
||||
|
||||
.item.item-block .item-inner {
|
||||
|
@ -12,7 +12,8 @@ import { VersePickerModal } from '../../components/verse-picker/verse-picker';
|
||||
@Component({
|
||||
templateUrl: 'search.html'
|
||||
})
|
||||
export class SearchPage implements OnInit {
|
||||
export class SearchPage implements OnInit
|
||||
{
|
||||
searchQuery = '';
|
||||
last: CardItem;
|
||||
loader: Loading;
|
||||
@ -26,14 +27,18 @@ export class SearchPage implements OnInit {
|
||||
, public modalCtrl: ModalController
|
||||
, public profileService: ProfileService
|
||||
, public params: NavParams
|
||||
) {
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
ngOnInit(): void
|
||||
{
|
||||
|
||||
if (this.profileService.localIsLoaded) {
|
||||
if (this.profileService.localIsLoaded)
|
||||
{
|
||||
this.loader = this.loadingCtrl.create({ content: 'Loading Page...' });
|
||||
this.loader.present().then(() => {
|
||||
this.loader.present().then(() =>
|
||||
{
|
||||
let t = this.profileService.profile();
|
||||
this.initializeItems(t);
|
||||
this.loader.dismiss();
|
||||
@ -41,28 +46,35 @@ export class SearchPage implements OnInit {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.profileService.onLocalStorageLoaded.subscribe(t => {
|
||||
this.profileService.onLocalStorageLoaded.subscribe(t =>
|
||||
{
|
||||
// Check if there is a profile saved in local storage
|
||||
this.loader = this.loadingCtrl.create({ content: 'Loading Page...' });
|
||||
this.loader.present().then(() => {
|
||||
this.loader.present().then(() =>
|
||||
{
|
||||
this.initializeItems(t);
|
||||
this.loader.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
this.profileService.onSavedPagesChanged.subscribe(sp => {
|
||||
this.profileService.onSavedPagesChanged.subscribe(sp =>
|
||||
{
|
||||
this.pagesService.initializePages(sp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initializeItems(u: User) {
|
||||
initializeItems(u: User)
|
||||
{
|
||||
// migrate old way of storing card items to the new.
|
||||
let has_migrated = false;
|
||||
for (let i in u.items) {
|
||||
if (u.items.hasOwnProperty(i)) {
|
||||
for (let i in u.items)
|
||||
{
|
||||
if (u.items.hasOwnProperty(i))
|
||||
{
|
||||
let ci = u.items[i];
|
||||
if (ci['data'] !== undefined) {
|
||||
if (ci['data'] !== undefined)
|
||||
{
|
||||
if (ci['data'].qry !== undefined)
|
||||
u.items[i] = { qry: ci['data'].qry, dict: ci.dict, type: ci.type };
|
||||
else if (ci['data'].ref !== undefined)
|
||||
@ -81,11 +93,15 @@ export class SearchPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
for (let pg of u.saved_pages) {
|
||||
for (let i in pg.queries) {
|
||||
if (pg.queries.hasOwnProperty(i)) {
|
||||
for (let pg of u.saved_pages)
|
||||
{
|
||||
for (let i in pg.queries)
|
||||
{
|
||||
if (pg.queries.hasOwnProperty(i))
|
||||
{
|
||||
let ci = pg.queries[i];
|
||||
if (ci['data'] !== undefined) {
|
||||
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)
|
||||
@ -107,7 +123,8 @@ export class SearchPage implements OnInit {
|
||||
|
||||
// initialize the pages.
|
||||
this.pagesService.initializePages(u.saved_pages);
|
||||
|
||||
this.profileService.save(); // save the new items list
|
||||
|
||||
if (this.params.data.queries !== undefined)
|
||||
this.profileService.profile().items = JSON.parse(JSON.stringify(this.params.data.queries));
|
||||
|
||||
@ -119,18 +136,26 @@ export class SearchPage implements OnInit {
|
||||
if (has_migrated)
|
||||
this.profileService.save();
|
||||
|
||||
if (this.profileService.profile().items === undefined)
|
||||
{
|
||||
this.profileService.profile().items = []; // sometimes, maybe because of all the weirdness with the remote syncing, this gets set to undefined, and it needs to be reset.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
textSizeChanged() {
|
||||
textSizeChanged()
|
||||
{
|
||||
this.profileService.textSizeChanged();
|
||||
this.profileService.localSave();
|
||||
}
|
||||
|
||||
actionsMenu() {
|
||||
actionsMenu()
|
||||
{
|
||||
this.menu.open('actions');
|
||||
}
|
||||
|
||||
addPage() {
|
||||
addPage()
|
||||
{
|
||||
const alert = this.alertCtrl.create({
|
||||
title: 'Save Search as Page',
|
||||
inputs: [
|
||||
@ -143,13 +168,15 @@ export class SearchPage implements OnInit {
|
||||
{
|
||||
text: 'Cancel',
|
||||
role: 'cancel',
|
||||
handler: (): void => {
|
||||
handler: (): void =>
|
||||
{
|
||||
console.log('Cancel clicked');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Save',
|
||||
handler: data => {
|
||||
handler: data =>
|
||||
{
|
||||
const p = { queries: this.profileService.profile().items.slice(), title: data.title };
|
||||
this.profileService.profile().saved_pages.push(p);
|
||||
this.profileService.save();
|
||||
@ -161,7 +188,8 @@ export class SearchPage implements OnInit {
|
||||
alert.present();
|
||||
}
|
||||
|
||||
updatePage() {
|
||||
updatePage()
|
||||
{
|
||||
const page = this.profileService.profile().saved_pages.find(
|
||||
i =>
|
||||
i.title === this.params.data.title
|
||||
@ -170,49 +198,62 @@ export class SearchPage implements OnInit {
|
||||
this.profileService.save();
|
||||
}
|
||||
|
||||
setQuery(searchbar) {
|
||||
setQuery(searchbar)
|
||||
{
|
||||
this.searchQuery = searchbar.target.value;
|
||||
}
|
||||
getQuery(searchbar) {
|
||||
getQuery(searchbar)
|
||||
{
|
||||
this.updateUIwithItems(this.searchQuery, true);
|
||||
}
|
||||
|
||||
isError(t: string) {
|
||||
isError(t: string)
|
||||
{
|
||||
return t === 'Error';
|
||||
}
|
||||
isPassage(t: string) {
|
||||
isPassage(t: string)
|
||||
{
|
||||
return t === 'Passage';
|
||||
}
|
||||
isStrongs(t: string) {
|
||||
isStrongs(t: string)
|
||||
{
|
||||
return t === 'Strongs';
|
||||
}
|
||||
isWords(t: string) {
|
||||
isWords(t: string)
|
||||
{
|
||||
return t === 'Words';
|
||||
}
|
||||
|
||||
versePicker() {
|
||||
versePicker()
|
||||
{
|
||||
const modal = this.modalCtrl.create(VersePickerModal, { onItemClicked: this });
|
||||
modal.present();
|
||||
}
|
||||
|
||||
removeItem(item) {
|
||||
removeItem(item)
|
||||
{
|
||||
const idx = this.profileService.profile().items.indexOf(item);
|
||||
this.profileService.profile().items.splice(idx, 1);
|
||||
|
||||
// save the users settings.
|
||||
this.profileService.localSave();
|
||||
this.profileService.save();
|
||||
}
|
||||
|
||||
addItemToList(item: CardItem) {
|
||||
if (this.profileService.profile().append_to_bottom) {
|
||||
if (this.last != null && this.profileService.profile().insert_next_to_item) {
|
||||
addItemToList(item: CardItem)
|
||||
{
|
||||
if (this.profileService.profile().append_to_bottom)
|
||||
{
|
||||
if (this.last != null && this.profileService.profile().insert_next_to_item)
|
||||
{
|
||||
const idx = this.profileService.profile().items.indexOf(this.last);
|
||||
this.profileService.profile().items.splice(idx + 1, 0, item);
|
||||
} else
|
||||
this.profileService.profile().items.push(item);
|
||||
}
|
||||
else {
|
||||
if (this.last != null && this.profileService.profile().insert_next_to_item) {
|
||||
else
|
||||
{
|
||||
if (this.last != null && this.profileService.profile().insert_next_to_item)
|
||||
{
|
||||
const idx = this.profileService.profile().items.indexOf(this.last);
|
||||
this.profileService.profile().items.splice(idx, 0, item);
|
||||
} else
|
||||
@ -220,25 +261,33 @@ export class SearchPage implements OnInit {
|
||||
}
|
||||
this.last = null;
|
||||
}
|
||||
getItemsNextToCard(data: OpenData) {
|
||||
getItemsNextToCard(data: OpenData)
|
||||
{
|
||||
this.last = data.card;
|
||||
this.updateUIwithItems(data.qry, data.from_search_bar);
|
||||
}
|
||||
|
||||
getItemList(search: string): Promise<CardItem[]> {
|
||||
return new Promise((resolve) => {
|
||||
getItemList(search: string): Promise<CardItem[]>
|
||||
{
|
||||
return new Promise((resolve) =>
|
||||
{
|
||||
const list: CardItem[] = [];
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
const qs = search.split(';');
|
||||
for (let x in qs) {
|
||||
if (qs.hasOwnProperty(x)) {
|
||||
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)
|
||||
list.push({ qry: q, dict: 'na', type: 'Words' });
|
||||
else if (q.search(/(H|G)[0-9]/i) !== -1) {
|
||||
else if (q.search(/(H|G)[0-9]/i) !== -1)
|
||||
{
|
||||
// its a strongs lookup
|
||||
let dict = q.substring(0, 1);
|
||||
|
||||
@ -250,9 +299,11 @@ export class SearchPage implements OnInit {
|
||||
q = q.substring(1, q.length);
|
||||
list.push({ qry: q, dict: dict, type: 'Strongs' });
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// its a verse reference.
|
||||
if (q.trim() !== '') {
|
||||
if (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' });
|
||||
}
|
||||
@ -265,7 +316,8 @@ export class SearchPage implements OnInit {
|
||||
|
||||
this.profileService.save();
|
||||
}
|
||||
catch (error) {
|
||||
catch (error)
|
||||
{
|
||||
list.push({ qry: error, type: 'Error', dict: 'na' });
|
||||
console.log(error);
|
||||
}
|
||||
@ -274,13 +326,18 @@ export class SearchPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
updateUIwithItems(search: string, from_search_bar: boolean) {
|
||||
this.getItemList(search).then(lst => {
|
||||
updateUIwithItems(search: string, from_search_bar: boolean)
|
||||
{
|
||||
this.getItemList(search).then(lst =>
|
||||
{
|
||||
this.loader = this.loadingCtrl.create({ content: 'Looking up Query...' });
|
||||
this.loader.present().then(
|
||||
() => {
|
||||
for (let item of lst) {
|
||||
if (item.type === 'Strongs' && this.profileService.profile().strongs_modal && !from_search_bar) {
|
||||
() =>
|
||||
{
|
||||
for (let item of lst)
|
||||
{
|
||||
if (item.type === 'Strongs' && this.profileService.profile().strongs_modal && !from_search_bar)
|
||||
{
|
||||
const modal = this.modalCtrl.create(StrongsModal, { sn: parseInt(item.qry), dict: item.dict, onItemClicked: this });
|
||||
modal.present();
|
||||
} else
|
||||
@ -297,7 +354,8 @@ export type OpenData = { card: CardItem, qry: string, from_search_bar: boolean }
|
||||
|
||||
export type CardItem = { qry: string, type: string, dict: string }
|
||||
|
||||
class Item {
|
||||
class Item
|
||||
{
|
||||
id: number;
|
||||
data: any;
|
||||
type: Type<any>;
|
||||
|
@ -36,10 +36,16 @@
|
||||
<ion-label>Insert Result Next to Item</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().insert_next_to_item" (ionChange)="save()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-list-header>Display Settings</ion-list-header>
|
||||
<ion-item>
|
||||
<ion-label>Each Verse on New Line</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().verses_on_new_line" (ionChange)="save()"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Show Verse #'s</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="this.profileService.profile().show_verse_numbers" (ionChange)="save()"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Show Paragraphs</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().show_paragraphs" (ionChange)="save()"></ion-toggle>
|
||||
@ -49,6 +55,12 @@
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().show_paragraph_headings" (ionChange)="save()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-list-header>Profile Settings</ion-list-header>
|
||||
<ion-item>
|
||||
<ion-label>Sync Search Items</ion-label>
|
||||
<ion-toggle color="dark" [(ngModel)]="profileService.profile().sync_search_items" (ionChange)="save()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<h4>Adjust Text</h4>
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
|
@ -63,7 +63,7 @@ export class ProfileService
|
||||
}
|
||||
|
||||
poll(self);
|
||||
}, 10000);
|
||||
}, 2000);
|
||||
})(this);
|
||||
|
||||
this.local.get('profile').then(json_profile =>
|
||||
@ -122,59 +122,6 @@ export class ProfileService
|
||||
return -1;
|
||||
|
||||
}
|
||||
private returnYonly(a: SavedPage[], b: SavedPage[])
|
||||
{
|
||||
let r: SavedPage[] = [];
|
||||
if (b === undefined)
|
||||
return r;
|
||||
|
||||
if (a !== undefined && a.length === 0 && b !== undefined && b.length > 0)
|
||||
return [...b];
|
||||
|
||||
let x = [...a];
|
||||
let y = [...b];
|
||||
|
||||
/// <summary>
|
||||
/// Takes two javascript arrays and returns an array
|
||||
/// containing a set of values shared by arrays.
|
||||
/// </summary>
|
||||
// declare iterator
|
||||
let i = 0;
|
||||
// declare terminator
|
||||
let t = (x.length < y.length) ? x.length : y.length;
|
||||
// sort the arrays
|
||||
x.sort(this.comparePage);
|
||||
y.sort(this.comparePage);
|
||||
|
||||
// in this loop, we remove from the arrays, the
|
||||
// values that aren't shared between them.
|
||||
while (i < t)
|
||||
{
|
||||
if (x[i].title === y[i].title)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (x.length > i && y.length > i && x[i].title < y[i].title)
|
||||
x.splice(i, 1);
|
||||
|
||||
if (x.length > i && y.length > i && x[i].title > y[i].title)
|
||||
{
|
||||
r.unshift(y[i]);
|
||||
y.splice(i, 1);
|
||||
}
|
||||
|
||||
t = (x.length < y.length) ? x.length : y.length;
|
||||
|
||||
if (t === i && t < y.length)
|
||||
{
|
||||
r = r.concat(y);
|
||||
}
|
||||
}
|
||||
// we could return y, because at this time, both arrays
|
||||
// are identical.
|
||||
return r;
|
||||
}
|
||||
|
||||
handleRemotePreferenceChange(user: User)
|
||||
{
|
||||
@ -184,34 +131,32 @@ export class ProfileService
|
||||
let changed = false;
|
||||
let local_was_empty = this.profile().saved_pages.length === 0;
|
||||
|
||||
// merge the saved pages so you don't loose those either
|
||||
// don't add if they are the same.
|
||||
let ys = this.returnYonly(this.profile().saved_pages, user.saved_pages);
|
||||
|
||||
if (ys.length > 0)
|
||||
{
|
||||
this.localProfile.saved_pages = this.localProfile.saved_pages.concat(ys);
|
||||
this.onSavedPagesChanged.emit(this.localProfile.saved_pages);
|
||||
|
||||
if (!local_was_empty)
|
||||
{
|
||||
changed = true;
|
||||
this.needsSync = true;
|
||||
}
|
||||
}
|
||||
if (this.profile().saved_pages.length > 0 && user.saved_pages === undefined)
|
||||
if (user.saved_pages !== undefined)
|
||||
{
|
||||
this.localProfile.saved_pages = user.saved_pages;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (this.profile().sync_search_items)
|
||||
{
|
||||
if (user === undefined || user.items === undefined)
|
||||
{
|
||||
this.localProfile.items = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.localProfile.items = user.items;
|
||||
}
|
||||
changed = true;
|
||||
this.needsSync = true;
|
||||
}
|
||||
|
||||
// don't sync things that don't make sense.
|
||||
if (this.profile().uid !== user.uid)
|
||||
if (user.uid !== undefined && this.profile().uid !== user.uid)
|
||||
{
|
||||
this.profile().uid = user.uid;
|
||||
changed = true;
|
||||
}
|
||||
if (this.profile().username !== user.username)
|
||||
if (user.username !== undefined && this.profile().username !== user.username)
|
||||
{
|
||||
this.profile().username = user.username;
|
||||
changed = true;
|
||||
@ -334,6 +279,7 @@ export class ProfileService
|
||||
this.profile().show_verse_numbers = true;
|
||||
this.profile().show_paragraph_headings = true;
|
||||
this.profile().show_paragraphs = true;
|
||||
this.profile().sync_search_items = false;
|
||||
}
|
||||
|
||||
reset()
|
||||
@ -377,6 +323,7 @@ export class ProfileService
|
||||
show_verse_numbers: true,
|
||||
show_paragraphs: true,
|
||||
show_paragraph_headings: true,
|
||||
sync_search_items: false
|
||||
};
|
||||
}
|
||||
|
||||
@ -402,6 +349,7 @@ export type User = {
|
||||
show_verse_numbers: boolean,
|
||||
show_paragraphs: boolean,
|
||||
show_paragraph_headings: boolean,
|
||||
sync_search_items: boolean
|
||||
}
|
||||
|
||||
export type SavedPage = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user