47 lines
1.2 KiB
HTML
47 lines
1.2 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Serial Stream</title>
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
</head>
|
|
<body>
|
|
<main class="container">
|
|
<h1>ESP32 Serial Live</h1>
|
|
<p><a href="/">Zurueck zum WLAN-Portal</a> | <a href="/timeline">Zur Timeline</a></p>
|
|
<pre id="terminal" class="terminal"></pre>
|
|
</main>
|
|
|
|
<script>
|
|
const term = document.getElementById('terminal');
|
|
const maxLines = 500;
|
|
const lines = [];
|
|
|
|
function appendLine(text) {
|
|
lines.push(text);
|
|
if (lines.length > maxLines) {
|
|
lines.shift();
|
|
}
|
|
term.textContent = lines.join('\n');
|
|
term.scrollTop = term.scrollHeight;
|
|
}
|
|
|
|
const events = new EventSource('/events/serial');
|
|
events.onmessage = (evt) => {
|
|
try {
|
|
const payload = JSON.parse(evt.data);
|
|
const ts = payload.ts_hms ? `[${payload.ts_hms}] ` : '';
|
|
appendLine(`${ts}${payload.line || ''}`);
|
|
} catch (e) {
|
|
appendLine(evt.data || '');
|
|
}
|
|
};
|
|
|
|
events.onerror = () => {
|
|
appendLine('[sse] reconnecting...');
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|