-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.html
44 lines (44 loc) · 1.1 KB
/
logs.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="referrer" content="no-referrer">
<title>Jasper Logs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: monospace;
white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #242424;
color: #c9c9c9;
color-scheme: dark;
}
}
</style>
<script>
let followLogs = true;
function div(text) {
const div = document.createElement('div');
div.setHTMLUnsafe(text);
return div;
}
window.electronAPI.streamLogs((event, data) => {
followLogs = window.scrollY >= (document.body.scrollHeight - window.innerHeight - 20);
const lines = data.split(/[\r\n]+/);
for (let line of lines) {
line = line.trim();
if (!line) continue;
document.getElementById('logs').appendChild(div(line));
}
if (followLogs) {
window.scrollTo(0, document.body.scrollHeight);
}
});
</script>
</head>
<body id="logs">
</body>
</html>