-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
executable file
·265 lines (223 loc) · 6.48 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0">
<style>
body { font-family: Arial, Helvetica, sans-serif; width: 200px; margin: 0 auto; padding: 0px; }
canvas { border: 1px solid #9C9898; }
#container {width: 200px; margin: 0 auto; }
</style>
<script src="script_min.js"></script>
<script>
var mjpeg_img;
function reload_img () {
mjpeg_img.src = "http://192.168.0.129:22334/cam_pic.php?time=" + new Date().getTime();
}
function error_img () {
setTimeout("mjpeg_img.src = 'http://84.193.214.148:22334/cam_pic.php?time=' + new Date().getTime();", 100);
}
function init() {
mjpeg_img = document.getElementById("mjpeg_dest");
mjpeg_img.onload = reload_img;
mjpeg_img.onerror = error_img;
reload_img();
}
</script>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.7.1-beta.js"></script>
<script>
var socket = new WebSocket("ws://" + window.location.hostname + ":" + window.location.port + "/ws");
socket.onopen = function(){
console.log("connected");
};
socket.onmessage = function (message) {
console.log("receiving: " + message.data);
};
socket.onclose = function(){
console.log("disconnected");
};
sendMessage = function(message) {
socket.send(message);
};
var value = 0;
window.onload = function() {
var stage = new Kinetic.Stage({
container: "container",
width: 200,
height: 300
});
var layer = new Kinetic.Layer();
var circle = new Kinetic.Circle({
x: 100,
y: 50,
radius: 30,
fill: "blue",
stroke: "black",
strokeWidth: 4,
text: "fwd",
draggable: false
});
circle.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({forward: timedelay}));
});
circle.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text = new Kinetic.Text({
x: 90,
y: 80,
text: 'fwd',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle);
layer.add(text);
var circle2 = new Kinetic.Circle({
x: 100,
y: 200,
radius: 30,
fill: "green",
stroke: "black",
strokeWidth: 4,
draggable: false
});
circle2.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({reverse: timedelay}));
});
circle2.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text2 = new Kinetic.Text({
x: 90,
y: 230,
text: 'rev',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle2);
layer.add(text2);
var circle3 = new Kinetic.Circle({
x: 150,
y: 150,
radius: 30,
fill: "red",
stroke: "black",
strokeWidth: 4,
draggable: false
});
circle3.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({right: timedelay}));
});
circle3.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text3 = new Kinetic.Text({
x: 140,
y: 180,
text: 'right',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle3);
layer.add(text3);
var circle4 = new Kinetic.Circle({
x: 50,
y: 150,
radius: 30,
fill: "red",
stroke: "black",
strokeWidth: 4,
draggable: false
});
circle4.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({left: timedelay}));
});
circle4.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text4 = new Kinetic.Text({
x: 40,
y: 180,
text: 'left',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle4);
layer.add(text4);
var circle5 = new Kinetic.Circle({
x: 150,
y: 250,
radius: 30,
fill: "red",
stroke: "black",
strokeWidth: 4,
draggable: false
});
circle5.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({pivotright: timedelay}));
});
circle5.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text5 = new Kinetic.Text({
x: 140,
y: 280,
text: 'piv-right',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle5);
layer.add(text5);
var circle6 = new Kinetic.Circle({
x: 50,
y: 250,
radius: 30,
fill: "red",
stroke: "black",
strokeWidth: 4,
draggable: false
});
circle6.on("mousedown touchmove", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({pivotleft: timedelay}));
});
circle6.on("mouseup touchend", function() {
var timedelay = 0.030
sendMessage(JSON.stringify({stop: timedelay}));
});
var text6 = new Kinetic.Text({
x: 40,
y: 280,
text: 'piv-left',
fontSize: 15,
fontFamily: 'Arial',
fill: 'black'
});
layer.add(circle6);
layer.add(text6);
stage.add(layer);
};
</script>
</head>
<body onload="setTimeout('init();', 100);">
<h1>Picar</h1>
<div><img id="mjpeg_dest" style="width:200px;" alt="video not available"/></div>
<div id="container"></div>
<p>This is the controls page for Willem's thesis at Mobyus, formerly known as Ace GroepT</p>
<p>The aim of this project is to drive an RC car over wifi signals from a remote pc, tablet or mobile device</p>
</body>
</html>