Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +19 -17
templates/index.html
CHANGED
@@ -3,28 +3,30 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.
|
|
|
|
|
|
|
|
|
8 |
</head>
|
9 |
<body>
|
10 |
-
<
|
11 |
-
<input
|
12 |
-
<button onclick="executeCommand()">Execute</button>
|
13 |
-
<h2>Output:</h2>
|
14 |
-
<pre id="output"></pre>
|
15 |
-
|
16 |
<script>
|
17 |
-
|
18 |
|
19 |
-
function
|
20 |
-
|
21 |
-
|
22 |
-
}
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
});
|
28 |
</script>
|
29 |
</body>
|
30 |
-
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Bash Shell</title>
|
7 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script>
|
8 |
+
<style>
|
9 |
+
body { font-family: monospace; }
|
10 |
+
#output { white-space: pre; }
|
11 |
+
</style>
|
12 |
</head>
|
13 |
<body>
|
14 |
+
<div id="output"></div>
|
15 |
+
<input id="input" autofocus />
|
|
|
|
|
|
|
|
|
16 |
<script>
|
17 |
+
const socket = io();
|
18 |
|
19 |
+
socket.on('output', function(data) {
|
20 |
+
document.getElementById('output').innerText += data;
|
21 |
+
});
|
|
|
22 |
|
23 |
+
document.getElementById('input').addEventListener('keydown', function(event) {
|
24 |
+
if (event.key === 'Enter') {
|
25 |
+
const input = this.value;
|
26 |
+
socket.emit('input', input);
|
27 |
+
this.value = '';
|
28 |
+
}
|
29 |
});
|
30 |
</script>
|
31 |
</body>
|
32 |
+
</html>
|