Spaces:
Runtime error
Runtime error
Commit
·
19b663b
1
Parent(s):
3863641
Update static/index.html
Browse files- static/index.html +44 -33
static/index.html
CHANGED
@@ -1,36 +1,47 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
-
|
4 |
-
<meta charset="UTF-8"
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"
|
6 |
-
<title>
|
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 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Simulator</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<canvas id="displayCanvas" width="800" height="600"></canvas>
|
10 |
+
|
11 |
+
<script>
|
12 |
+
const canvas = document.getElementById('displayCanvas');
|
13 |
+
const ctx = canvas.getContext('2d');
|
14 |
+
|
15 |
+
let socket = new WebSocket("ws://localhost:8000/ws");
|
16 |
+
|
17 |
+
// Capture mouse movements and clicks
|
18 |
+
canvas.addEventListener("mousemove", function (event) {
|
19 |
+
let rect = canvas.getBoundingClientRect();
|
20 |
+
let x = event.clientX - rect.left;
|
21 |
+
let y = event.clientY - rect.top;
|
22 |
+
|
23 |
+
socket.send(JSON.stringify({
|
24 |
+
"action_type": "move",
|
25 |
+
"mouse_position": [x, y]
|
26 |
+
}));
|
27 |
+
});
|
28 |
+
|
29 |
+
canvas.addEventListener("click", function (event) {
|
30 |
+
let rect = canvas.getBoundingClientRect();
|
31 |
+
let x = event.clientX - rect.left;
|
32 |
+
let y = event.clientY - rect.top;
|
33 |
+
|
34 |
+
socket.send(JSON.stringify({
|
35 |
+
"action_type": "left_click",
|
36 |
+
"mouse_position": [x, y]
|
37 |
+
}));
|
38 |
+
});
|
39 |
+
|
40 |
+
// Receive predicted frames and render them on the canvas
|
41 |
+
socket.onmessage = function (event) {
|
42 |
+
ctx.fillStyle = "black"; // Placeholder rendering
|
43 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
44 |
+
};
|
45 |
+
</script>
|
46 |
+
</body>
|
47 |
</html>
|