Created
August 8, 2013 03:51
-
-
Save yareally/6181307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Greeter { | |
element: HTMLElement; | |
span: HTMLElement; | |
timerToken: number; | |
constructor(element: HTMLElement) { | |
this.element = element; | |
this.element.innerHTML += "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.innerHTML = new Date().toUTCString(), 500); | |
} | |
stop() { | |
clearTimeout(this.timerToken); | |
} | |
} | |
window.onload = () => { | |
var el = document.getElementById('content'); | |
var greeter = new Greeter(el); | |
greeter.start(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment