File size: 1,085 Bytes
98f318f |
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>Web-based Terminal</title>
</head>
<body>
<h1>Web-based Terminal</h1>
<div id="terminal-output"></div>
<input type="text" id="command-input" autofocus>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
<script>
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
console.log('Connected to server');
});
socket.on('output', function(data) {
var outputDiv = document.getElementById('terminal-output');
outputDiv.innerHTML += '<pre>' + data + '</pre>';
outputDiv.scrollTop = outputDiv.scrollHeight;
});
document.getElementById('command-input').addEventListener('keypress', function(event) {
if (event.key === 'Enter') {
var command = event.target.value;
socket.emit('command', command);
event.target.value = '';
}
});
</script>
</body>
</html>
|