2017-01-24 16:43:58 -05:00
|
|
|
import { EventEmitter, Component, Output, OnInit } from "@angular/core";
|
2016-12-01 15:21:07 -05:00
|
|
|
import { Platform, NavParams, ViewController } from 'ionic-angular';
|
2017-01-18 17:51:06 -05:00
|
|
|
import { Reference } from '../../libs/Reference';
|
2017-01-24 16:43:58 -05:00
|
|
|
import { StrongsResult, StrongsService } from '../../services/strongs-service';
|
2016-12-01 13:40:04 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "strongs-modal",
|
|
|
|
templateUrl: "strongs-modal.html"
|
|
|
|
})
|
2017-01-24 16:43:58 -05:00
|
|
|
export class StrongsModal implements OnInit
|
2017-01-18 17:51:06 -05:00
|
|
|
{
|
2017-01-24 16:43:58 -05:00
|
|
|
sn: number;
|
|
|
|
dict: string;
|
2016-12-01 13:40:04 -05:00
|
|
|
item: StrongsResult;
|
|
|
|
|
2016-12-02 13:00:55 -05:00
|
|
|
@Output()
|
2017-01-20 18:57:02 -05:00
|
|
|
onItemClicked = new EventEmitter<string>();
|
2016-12-02 13:00:55 -05:00
|
|
|
|
2017-01-24 16:43:58 -05:00
|
|
|
constructor(private strongsService: StrongsService,
|
2016-12-02 13:00:55 -05:00
|
|
|
public platform: Platform,
|
|
|
|
public params: NavParams,
|
|
|
|
public viewCtrl: ViewController
|
2017-01-18 17:51:06 -05:00
|
|
|
)
|
|
|
|
{
|
2017-01-24 16:43:58 -05:00
|
|
|
this.sn = this.params.get('sn') as number;
|
|
|
|
this.dict = this.params.get('dict') as string;
|
2017-01-20 18:57:02 -05:00
|
|
|
this.onItemClicked.subscribe(item =>
|
|
|
|
this.params.get('onItemClicked').getItems(item)
|
2017-01-18 17:51:06 -05:00
|
|
|
)
|
2016-12-01 13:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-01-24 16:43:58 -05:00
|
|
|
ngOnInit(): void
|
|
|
|
{
|
|
|
|
this.strongsService.getResultAsPromise(this.sn, this.dict).then(data => this.item = data);
|
|
|
|
}
|
|
|
|
|
2017-01-18 17:51:06 -05:00
|
|
|
dismiss()
|
|
|
|
{
|
2016-12-02 13:00:55 -05:00
|
|
|
this.viewCtrl.dismiss();
|
|
|
|
}
|
2017-01-24 16:43:58 -05:00
|
|
|
|
2017-01-20 18:57:02 -05:00
|
|
|
openItem(p: string)
|
|
|
|
{
|
|
|
|
this.onItemClicked.emit(p);
|
2017-01-24 16:43:58 -05:00
|
|
|
this.dismiss();
|
2017-01-20 18:57:02 -05:00
|
|
|
}
|
|
|
|
|
2017-01-18 17:51:06 -05:00
|
|
|
makePassage(p: string)
|
|
|
|
{
|
2016-12-27 21:10:00 -05:00
|
|
|
return Reference.bookName(parseInt(p.split(";")[0])) + ' ' + p.split(";")[1] + ":" + p.split(";")[2];
|
2016-12-02 13:00:55 -05:00
|
|
|
}
|
2017-01-20 18:57:02 -05:00
|
|
|
|
2017-01-18 17:51:06 -05:00
|
|
|
openPassage(p: string)
|
|
|
|
{
|
2016-12-02 13:00:55 -05:00
|
|
|
let ref = this.makePassage(p);
|
2017-01-20 18:57:02 -05:00
|
|
|
this.onItemClicked.emit(ref);
|
2016-12-01 13:40:04 -05:00
|
|
|
}
|
2017-01-18 17:51:06 -05:00
|
|
|
}
|