/
clock-generator-app.ts
32 lines (25 loc) · 1.08 KB
/
clock-generator-app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ClockGeneratorApp {
private clkgenInputs: HTMLInputElement[];
constructor(document: Document, private driver) {
this.clkgenInputs = <HTMLInputElement[]><any>document.getElementsByClassName("clkgen-input");
this.initClkgenInputs();
this.updateReferenceClock();
}
private initClkgenInputs(): void {
for (let i = 0; i < this.clkgenInputs.length; i ++) {
this.clkgenInputs[i].addEventListener('change', (event) => {
this.driver[(<HTMLInputElement>event.currentTarget).dataset.command](parseInt((<HTMLInputElement>event.currentTarget).value));
})
}
}
private updateReferenceClock() {
this.driver.getReferenceClock( (clkin: number) => {
let clkIndex: string = "0";
if (clkin !== 0) {
clkIndex = "2";
}
(<HTMLInputElement>document.querySelector("[data-command='setReferenceClock'][value='" + clkIndex + "']")).checked = true;
requestAnimationFrame( () => { this.updateReferenceClock(); } )
});
}
}