-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
36 lines (34 loc) · 1.32 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Socket.io</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
</head>
<body>
<h1>Real time application</h1>
<table id="one" class="table table-dark">
<thead>
<tr>
<th scope="col">date</th>
<th scope="col">endpoints</th>
<th scope="col">states</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.min.js"></script>
<script>
var tab = document.getElementById("one");
var sokcet_io_client_1 = io.connect("http://localhost:8080");
sokcet_io_client_1.on("titi", function (data) {
var obj = JSON.parse(data.toString());
if (obj.type == "ChannelStateChange") {
console.log(obj);
var date = obj.timestamp.split(".")[0].replace("T", " ");
tab.insertAdjacentHTML("beforeend", "<td>" + date + "</td><td>" + obj.channel.id + "</td><td>" + obj.channel.state + "</td>");
}
});
</script>
</body>
</html>