-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
172 lines (143 loc) · 3.2 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<html>
<head>
<title>Robotin ohjaus</title>
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script>
function refreshIt(element) {
setTimeout(function() {
element.src = element.src.split('?')[0] + '?' + new Date().getTime();
refreshIt(element);
}, 150); // refresh every 150ms
}
</script>
<script>
var ws, interval;
ws = new WebSocket("ws://10.8.0.6:8888/ws");
ws.onmessage = function(evt) {
logger(evt.data);
};
ws.onclose = function(evt) {
};
ws.onopen = function(evt) {
ws.send('Hello!');
};
window.addEventListener("gamepadconnected", function(e) {
ws.send("Gamepad connected");
});
window.addEventListener("gamepaddisconnected", function(e) {
ws.send("Gamepad disconnected");
});
if (!('ongamepadconnected' in window)) {
// No gamepad events available, poll instead.
interval = setInterval(pollGamepads, 150);
}
function pollGamepads() {
var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
for (var i = 0; i < gamepads.length; i++) {
var gp = gamepads[i];
if (gp) {
//gp.index + gp.id
//gp.buttons.length
//gp.axes.length + " axes.";
ws.send("Axis: " + gp.axes[0] + " " + gp.axes[1]);
}
}
}
</script>
</head>
<body>
<iframe height=300px width=350px src="http://10.8.0.6:8090/?action=stream"></iframe>
<table style="width:300px">
<tr>
<th>-</th>
<th>
<button type="button" id="fw" onclick="fw()">FORWARD!</button>
<button type="button" id="fw" onclick="fwsm()">tinyforward</button>
</th>
<th>-</th>
</tr>
<tr>
<td>
<button type="button" id="le" onclick="le()">LEFT!</button>
<button type="button" id="le" onclick="lesm()">tinyleft</button>
</td>
<td>
<button type="button" id="bw" onclick="bw()">BACKWARDS!</button>
<button type="button" id="bw" onclick="bwsm()">tinybackward</button>
</td>
<td>
<button type="button" id="ri" onclick="ri()">RIGHT!</button>
<button type="button" id="ri" onclick="rism()">tinyright</button>
</td>
</tr>
</table>
<button type="button" id="stoptornado" onclick="ws.send('stop')">STOP TORNADO</button>
<script type="text/javascript">
function fw(){
jQuery.ajax({
type: "GET",
url: "forward",
success: function (msg) {
}
});
}
function bw(){
jQuery.ajax({
type: "GET",
url: "backward",
success: function (msg) {
}
});
}
function fwsm(){
jQuery.ajax({
type: "GET",
url: "forwardsm",
success: function (msg) {
}
});
}
function bwsm(){
jQuery.ajax({
type: "GET",
url: "backwardsm",
success: function (msg) {
}
});
}
function ri(){
jQuery.ajax({
type: "GET",
url: "right",
success: function (msg) {
}
});
}
function le(){
jQuery.ajax({
type: "GET",
url: "left",
success: function (msg) {
}
});
}
function rism(){
jQuery.ajax({
type: "GET",
url: "rightsm",
success: function (msg) {
}
});
}
function lesm(){
jQuery.ajax({
type: "GET",
url: "leftsm",
success: function (msg) {
}
});
}
</script>
<p><img id="robomap" src='map.png' onload="refreshIt(this)"></p>
</body>
</html>