-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
50 lines (46 loc) · 1009 Bytes
/
demo.html
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!--
Demo for _var - a javascript library for seamless variable-to-DOM binding
Yufei Liu (yufeiliu.com)
released under MIT license
-->
<html>
<head>
<script src="src/_var.js" type="text/javascript"></script>
<style>
#clock-container {
padding:5px;
border:1px solid black;
width:500px;
margin-left:auto;
margin-right:auto;
font-family:"Helvetica Neue";
font-size:13px;
}
strong {
color: red;
}
</style>
</head>
<div id="clock-container">
It has been <strong id="clock-view"></strong> seconds since you refereshed this page.
<br/>
Works on input box as well: <input type="text" id="textbox" />
</div>
<script>
counter = 0;
_var("counter")
.bind(document.getElementById("clock-view"))
.bind(document.getElementById("textbox"))
//Remove binding after 30 seconds
.bind(function(val) {
if (val==30) {
_var("counter").unbind(document.getElementById("clock-view"));
}
});
function startTimer() {
counter++;
setTimeout('startTimer()',1000);
}
startTimer();
</script>
</html>