forked from microsoft/TypeScriptSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreeter.ts
More file actions
27 lines (23 loc) · 652 Bytes
/
greeter.ts
File metadata and controls
27 lines (23 loc) · 652 Bytes
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
import repeat from "core-js/library/fn/string/repeat"
export class Greeter
{
element: HTMLElement;
span: HTMLElement;
timerToken: number;
constructor (element: HTMLElement)
{
this.element = element;
this.element.innerText += "The time is: ";
this.span = document.createElement('span');
this.element.appendChild(this.span);
this.span.innerText = new Date().toUTCString();
}
start()
{
this.timerToken = setInterval(() => this.span.innerText = `"${repeat(new Date().toUTCString() + " ", 2)}"`, 500);
}
stop()
{
clearTimeout(this.timerToken);
}
}