-
Notifications
You must be signed in to change notification settings - Fork 1
/
robo.html
75 lines (69 loc) · 1.72 KB
/
robo.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
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<title>RoboRemote</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var conn;
if (window["WebSocket"]) {
conn = new WebSocket("ws://{{$}}/ws");
conn.onclose = function(event) {
console.log("Connection closed.")
}
conn.onmessage = function(event) {
switch (event.data) {
case 'left':
$("#left").css("background-color","white");
$("#right").css("background-color","black");
break;
case 'right':
$("#left").css("background-color","black");
$("#right").css("background-color","white");
break;
case 'forward':
$("#left").css("background-color","white");
$("#right").css("background-color","white");
break;
case 'stop':
$("#left").css("background-color","black");
$("#right").css("background-color","black");
}
}
} else {
console.log("Your browser does not support WebSockets.")
}
});
</script>
<style type="text/css">
html {
overflow: hidden;
height:100%;
}
body {
overflow: hidden;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: black;
}
#left {
float:left;
width:50%;
height:100%;
background: black;
}
#right {
float:right;
width:50%;
height:100%;
background: black;
}
</style>
</head>
<body>
<div id="left"></div>
<div id="right"></div>
</body>
</html>