-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
41 lines (36 loc) · 1.61 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
<!DOCTYPE html>
<html>
<title>Cartesian Server</title>
<body>
<h2>Cartesian Server</h2>
<p id="status">status: heyyyyy (we are waiting for you)</p>
<p id="xPos">xPos: ...</p>
<p id="yPos">yPos: ...</p>
<p id="zPos">zPos: ....</p>
<!-- <p id="debugmsg">debug: </p>
<p id="debugjson">debugjson: </p> -->
<!-- <script src="./server.js"></script> -->
<script>
var HOST = location.origin.replace(/^http/, 'ws')
var ws = new WebSocket(HOST);
ws.onopen = function (event) {
document.getElementById('status').innerHTML = "status: websocket is open and ready";
}
ws.onclose = function (event) {
document.getElementById('status').innerHTML = "status: websocket is closed";
}
ws.onerror = function (event) {
document.getElementById('status').innerHTML = "status: websocket error: " + event.data;
}
ws.onmessage = function (event) {
var string = event.data;
var dataobj = JSON.parse(string);
document.getElementById('xPos').innerHTML = "xPos: " + dataobj.xPos;
document.getElementById('yPos').innerHTML = "yPos: " + dataobj.yPos;
document.getElementById('zPos').innerHTML = "zPos: " + dataobj.zPos;
//document.getElementById('debugmsg').innerHTML = "debugmsg: " + string;
//docuemnt.getElementById('debugjson').innerHTML = "debugjson: " + dataobj;
}
</script>
</body>
</html>