-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdelta.html
44 lines (39 loc) · 1.29 KB
/
delta.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
<!-- file I use for testing the small web-pp -->
<html>
<head>
<title>Deltas</title>
<meta charset="utf-8">
<script type="text/javascript">
var WebSocket = WebSocket || MozWebSocket;
var lastDelta = Date.now();
function connect() {
//var serverUrl = "ws://" + window.location.hostname + ":81";
var serverUrl = "ws://" + "192.168.0.50" + ":81";
connection = new WebSocket(serverUrl);
connection.onopen = function(evt) {
console.log("Connected!");
document.getElementById("box").innerHTML = "Connected!";
document.getElementById("last").innerHTML = "Last: N/A";
//document.getElementById("text").disabled = false;
//document.getElementById("send").disabled = false;
};
connection.onmessage = function(evt) {
var msg = JSON.parse(evt.data);
document.getElementById("box").innerHTML = JSON.stringify(msg, null, 2);
document.getElementById("last").innerHTML = "Last: " + ((Date.now() - lastDelta)/1000).toFixed(2) + "ms";
lastDelta = Date.now();
};
};
connect();
setInterval(function(){
document.getElementById("age").innerHTML = "Age: " + ((Date.now() - lastDelta)/1000).toFixed(1) + "ms";
}, 50);
</script>
</head>
<body>
<h3>Last Delta</h3>
<pre width="100%" height="50%" id="box"></pre>
<div id="last"></div>
<div id="age"></div>
</body>
</html>