.
I have built an ionic app and need guidance on adding my javascript to it.
My files are on GitHub https://github.com/ksnyd/simpleApp.git
The javascript (getTLE2018.js) I want to add to my ionic App is in the ‘test’ folder but Im not sure how or where to add it. getTLE2018.js calls the jStrip function located in the root of the ‘test’ folder.
Please offer assistance.
Thank you…
> home.html
<ion-header padding color="dark">
<ion-icon padding name="home"> {{ today | date: 'short' }}</ion-icon>
<ion-navbar>
<ion-title>
Simple App
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding color='dark'>
<p>
After button click, display results below button.
</p>
<button ion-button small (click)="check()">Run my script</button>
<ion-list padding color="dark">
My script results:
<ion-list padding color="dark">
<p><b>...{{script_txt}}...</b></p>
</ion-list>
</ion-list>
</ion-content>
> home.ts
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { ToastController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public today: number = Date.now();
satellite: string;
constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController) {
this.satellite = ('');
}
showToast1(position: string) {
let toast = this.toastCtrl.create({
message: '{myScript_Data}',
duration: 2000,
position: position
});
toast.present(toast);
}
script_txt = 'empty data';
check() {
if (this.script_txt == 'empty data') {
//do some logic
this.script_txt = 'myScript ran, here are the results!';
} else {
console.log('go to next page');
}
}
}
> getTLE2018.js
const jStrip = require('jStrip');
const jStrip1 = new jStrip(console.clear());
const linz = "-".repeat(70);
console.log('Getting INTELSAT 33E (IS-33E) TLE\n'+linz);
jStrip1.on("sat1", (d) => {console.log(`${d.data.replace(/ /g, '#')}`+'\n'+linz+'\n'+new Date()+'\n'+linz+'\n');
})
jStrip1.getData("https://www.pulsesat.com/satellites/s/0bcd3a1c-ea73-49b8-8e15-8738f5a32693/").
selector(".callout.secondary pre").
marker("sat1")
Results of getTLE2018.js:
Getting INTELSAT 33E (IS-33E) TLE
--------------------------------------
1#41748U#16053B###18135.18654197##.00000049##00000-0##00000-0#0##9991
2#41748###0.0231##15.5385#0001851##55.6213#288.8760##1.00271641##6632
--------------------------------------
Wed May 16 2018 08:09:20 GMT+0430 (+0430)
--------------------------------------