Skip to content

Commit 8e9b315

Browse files
committed
Adding extras code
1 parent adebbe5 commit 8e9b315

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

extras/timer.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<html>
2+
<head>
3+
<title>Webville Lounge</title>
4+
<script>
5+
6+
var dj = {
7+
playsound: function() {
8+
console.log("Playing ", this.sound);
9+
},
10+
sound: "bells"
11+
};
12+
13+
var controller = {
14+
timer: null,
15+
start: function() {
16+
this.timer = setInterval(dj.playsound.bind(dj), 1000);
17+
},
18+
stop: function() {
19+
clearInterval(this.timer);
20+
}
21+
};
22+
23+
window.onload = function() {
24+
25+
//controller.start();
26+
27+
var startButton = document.getElementById("start");
28+
startButton.onclick = function() {
29+
controller.start();
30+
};
31+
32+
var stopButton = document.getElementById("stop");
33+
stopButton.onclick = function() {
34+
controller.stop();
35+
};
36+
};
37+
38+
</script>
39+
</head>
40+
<body>
41+
<button id="start">start</button>
42+
<button id="stop">stop</button>
43+
</body>
44+
</html>
45+

0 commit comments

Comments
 (0)