-
Notifications
You must be signed in to change notification settings - Fork 1
/
index2.html
36 lines (34 loc) · 970 Bytes
/
index2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>nada</title>
<style>
* { list-style: none; }
.flex {
display: flex;
}
.event { width: 250px; }
.fields { flex: 1; }
</style>
<script>
document.addEventListener("DOMContentLoaded", () => {
let ws = new WebSocket("ws://localhost:8001/")
ws.onmessage = (e) => {
console.log(e.data)
const data = JSON.parse(e.data)
let div = document.getElementById("container")
div.innerHTML = div.innerHTML +
"<div class=\"flex\">" +
"<div class=\"event\">" + data.event + " " + data.table + "</div>" +
"<div class=\"fields\">" + JSON.stringify(data.fields) + "</div>" +
"</div>"
window.scrollTo(0,document.body.scrollHeight)
}
})
</script>
</head>
<body>
<div id="container"><div>
</body>
</html>