-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
38 lines (34 loc) · 1.15 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
<html>
<head>
</head>
<body>
Logs
<div id="out" style="font-family: Consolas, monaco, San Francisco, monospace; font-size: 11px">
</div>
<button style="position: fixed; top: 0px; right: 0px" onclick="window.socket.emit('reset')" >Reset</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
<script>
var socket = io.connect('http://logs.ayva.io');
const outDiv = document.getElementById('out');
let snap = true;
function scrollToBottom() {
document.body.scrollTop = document.body.scrollHeight;
}
document.onkeypress = (e) => { if (e.code === 'Space') { scrollToBottom(); } }
document.onscroll = (e) => { console.log(e); }
socket.on('log', function (data) {
try {
outDiv.insertAdjacentHTML('beforeend', `<div>${data}</div>`);
} catch (e) {
outDiv.insertAdjacentHTML('beforeend', `(Failed to parse)`);
}
if (outDiv.childElementCount > 500) {
outDiv.firstChild.remove();
}
if (snap) {
scrollToBottom();
}
});
</script>
</body>
</html>