-
Notifications
You must be signed in to change notification settings - Fork 1
/
example3.html
63 lines (60 loc) · 1.28 KB
/
example3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<body>
<h1>Timer Store Tsore.js Example</h1>
<timer></timer>
<p>Click on timer to reset</p>
<script type="riot/tag">
<timer>
<div>{time} seconds</div>
<button onclick={start}>Start</button>
<button onclick={stop}>Stop</button>
<button onclick={reset}>Reset</button>
<style scoped>
:scope {
font-size:40px;
}
</style>
this.mixin('tsore');
this.attach('timer',function(store){
this.time = store.time;
});
start() {
tsore.action('Start');
}
stop() {
tsore.action('Stop');
};
reset() {
tsore.action('Reset');
};
tsore.action('Start');
</timer>
</script>
<script src="riot+compiler.js"></script>
<script src="tsore.js"></script>
<script>
tsore.register('timer',
{
Reset: function(){
this.time = 0;
tsore.trigger('change');
},
Start: function(){
if(this.intervalId) clearInterval(this.intervalId);
this.intervalId = setInterval(function(){
this.time++;
tsore.trigger('change');
}.bind(this),1000);
},
Stop: function(){
if(this.intervalId) clearInterval(this.intervalId);
}
},
{
time: 0
}
);
riot.mount('*');
</script>
</body>
</html>