blob: 8844336b08bb31e31c1b15589f0a582782da7c73 (
plain)
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
|
{{define "body"}}
<style>
div#app {
font-family: monospace;
}
</style>
<div id="app"></div>
<script>
window.addEventListener("load", () => {
setInterval(fetchStats, 100);
});
async function fetchStats() {
let stats = await fetch("/api/stats");
stats = await stats.json();
document.getElementById("app").innerHTML = jsonToHtml(stats);
}
function jsonToHtml(json) {
if (json === null || typeof json !== "object") {
return String(json);
}
let html = "<ul>";
for (const [key, value] of Object.entries(json)) {
html += `<li>${key}: ${typeof value === "object" && value !== null ? jsonToHtml(value) : String(value)}</li>`;
}
html += "</ul>";
return html;
}
</script>
{{end}}
|