-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.html
47 lines (31 loc) · 1.26 KB
/
ui.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
<html>
<head>
<title>jsonp test</title>
<h1>Real Time Data</h1>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.2/socket.io.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
var socket = io.connect('http://localhost:5000');
$(function(){
$('#select_on').click(function(e){
e.preventDefault();
console.log('select_on clicked');
socket.emit('publish',{topic:'garage/open'});
});
$('#select_off').click(function(e){
e.preventDefault();
console.log('select_off clicked');
socket.emit('publish',{topic:'garage/close'});
});
});
</script>
</head>
<body>
<div id="select_div1">
<a href="#" id="select_on">ON</a>
</div>
<div id="select_div2">
<a href="#" id="select_off">OFF</a>
</div>
</body>
</html>