-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.html
More file actions
41 lines (33 loc) · 862 Bytes
/
client.html
File metadata and controls
41 lines (33 loc) · 862 Bytes
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
<img id="camera" src="/img">
<script>
speed = 0
const setSpeed = (val) => {
if (val != speed){
var xhttp = new XMLHttpRequest();
xhttp.open('POST', '/setSpeed?speed='+val, true);
xhttp.send();
}
speed = val
}
const turn = (val) => {
}
window.onload = function() {
var image = document.getElementById("camera");
function updateImage() {
image.src = image.src.split("?")[0] + "?" + new Date().getTime();
}
setInterval(updateImage, 1000);
}
document.addEventListener('keydown', (e)=>{
c = e.code;
if (c=='KeyW'){
setSpeed(1);
}
if (c=='KeyS'){
setSpeed(-1);
}
})
document.addEventListener('keyup', (e)=>{
setSpeed(0)
})
</script>