-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
68 lines (55 loc) · 2.2 KB
/
index.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>PteroConsole</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com?plugins=forms"></script>
</head>
<body class="bg-slate-900 px-2 py-2 relative h-screen">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@400;500;700&display=swap');
body {
color: #f5f5f5;
font-family: 'Inconsolata', monospace;
font-size: 15px;
text-align: left;
position: static;
scroll-behavior: smooth;
}
form {
padding-bottom: 10vh;
}
</style>
<div id="console"></div>
<form id="commandForm" class="container">
<div class="flex fixed bottom-4 left-2 right-2">
<input type="text" id="commandInput" placeholder="Type a command.."
class="py-3 px-4 flex-grow rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 bg-slate-800/60">
<button type="submit" class="rounded-full bg-blue-500 hover:bg-blue-500/60 px-4 py-4 mx-4"><svg xmlns="http://www.w3.org/2000/svg"
width="21" height="21" fill="currentColor" class="bi bi-send" viewBox="0 0 16 16">
<path
d="M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z" />
</svg></button>
</div>
</form>
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
// Show messages from `console.log` on the page
socket.on('consoleLog', (data) => {
const consoleDiv = document.getElementById('console');
consoleDiv.innerHTML += `${data}`;
window.scrollTo(0, document.body.scrollHeight);
});
// Commands form processing
const commandForm = document.getElementById('commandForm');
const commandInput = document.getElementById('commandInput');
commandForm.addEventListener('submit', (e) => {
e.preventDefault();
const command = commandInput.value.trim();
socket.emit('command', command);
commandInput.value = ''; // Clear the input
});
</script>
</body>
</html>