-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.html
73 lines (51 loc) · 1.24 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>事件中心</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript" src="../bower_components/jquery/dist/jquery.min.js"></script>
</head>
<body>
<input class="input1" type="text" />
<input class="input2" type="text" />
<p id="panel"></p>
<script type="text/javascript">
var EventCenter = (function(){
var events = {};
function on(evt, handler){
events[evt] = events[evt] || [];
events[evt].push({
handler: handler
});
}
function fire(evt, args){
if(!events[evt]){
return;
}
for(var i=0; i<events[evt].length; i++){
events[evt][i].handler(args);
}
}
return {
on: on,
fire: fire
}
})();
EventCenter.on('text-change', function(data){
$('#panel').text(data);
});
$('.input1').on('change', function(data){
$('#panel').text(data);
//EventCenter.fire('text-change', [$(this).val()]);
})
$('.input2').on('change', function(data){
$('#panel').text(data);
//EventCenter.fire('text-change', [$(this).val()]);
})
</script>
</body>
</html>