forked from pietwauters/ImprovedTesterAfterGenova
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
35 lines (30 loc) · 1.04 KB
/
index.html
File metadata and controls
35 lines (30 loc) · 1.04 KB
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
<!DOCTYPE html>
<html>
<head>
<title>ESP32 Web Terminal</title>
<style>
body { font-family: monospace; background: #000; color: #0f0; margin: 0; }
#terminal { height: 80vh; overflow-y: scroll; padding: 10px; border-bottom: 1px solid #0f0; }
#input { width: 100%; padding: 10px; background: #111; border: none; color: #0f0; font-family: monospace; }
</style>
</head>
<body>
<div id="terminal"></div>
<input type="text" id="input" placeholder="Type command and press Enter" autofocus />
<script>
const terminal = document.getElementById('terminal');
const input = document.getElementById('input');
const socket = new WebSocket('ws://' + location.hostname + ':81');
socket.onmessage = function(event) {
terminal.innerHTML += event.data + '<br>';
terminal.scrollTop = terminal.scrollHeight; // Auto scroll
};
input.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
socket.send(input.value);
input.value = '';
}
});
</script>
</body>
</html>