Skip to content

Commit 2b967e4

Browse files
committed
Merge pull request Devristo#24 from DannyWilkerson/patch-3
Update time.html
2 parents 7774b46 + 556b271 commit 2b967e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: examples/time.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
</head>
55
<body>
66
<h1>Server Time</h1>
7-
<strong id="time"></strong>
8-
9-
<script>
10-
var socket = new WebSocket("ws://localhost:12345/");
11-
socket.onmessage = function(msg) {
12-
document.getElementById("time").innerText = msg.data;
13-
};
14-
</script>
7+
<div>Status: <span id="status"></span></div>
8+
<div>Time: <span style="font-size:bold;" id="time"></span></div>
9+
<script type ="text/javascript">
10+
var socket = new WebSocket("ws://localhost:12345");
11+
socket.onopen = function(msg){ document.getElementById("status").innerHTML = 'Online'; };
12+
socket.onclose = function(msg){ document.getElementById("status").innerHTML = 'Offline'; }
13+
socket.onmessage = function(msg){ document.getElementById("time").innerHTML = msg.data; };
14+
</script>
1515
</body>
16-
</html>
16+
</html>

0 commit comments

Comments
 (0)