-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (54 loc) · 2.41 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terminal</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" type="text/css" href="inc/css/index.css">
</head>
<body>
<div id='terminal' class="w-full min-h-screen max-h-screen bg-black text-gray-300 py-4 px-6 font-['Courier_New'] overflow-auto no-scrollbar">
<div id="static_output" class="mb-8">
<div>Welcome to <span class="text-green-500">Fr34k.ch</span>!</div>
<div>Type '<span class="text-pink-500">help</span>' for available commands.</div>
</div>
<div id="output" class="text-wrap whitespace-pre"></div>
<div class="flex">
<div class="mr-2" id="prefix"><span class="text-pink-500">visitor</span>@<span class="text-green-500">fr34k.ch</span>$</div>
<input id="commandInput" type="text" class="bg-transparent border-none outline-none text-gray-300 flex-grow" autofocus>
</div>
</div>
<script src="commands.js"></script>
<script>
const prefix = document.getElementById('prefix').innerHTML;
const body = document.body;
const terminalDiv = document.getElementById('terminal');
const outputDiv = document.getElementById('output');
const commandInput = document.getElementById('commandInput');
commandInput.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
const command = commandInput.value.trim();
if (command in commands) {
if (command === 'clear') {
outputDiv.innerHTML = '';
} else {
const output = document.createElement('div');
output.innerHTML = `<div>${prefix} ${command}\n${commands[command]}\n</div>\n`;
outputDiv.appendChild(output);
}
} else {
const output = document.createElement('div');
output.innerHTML = `<div>${prefix} ${command}</div><div>Command not found. Type 'help' for available commands.\n</div>\n`;
outputDiv.appendChild(output);
}
commandInput.value = '';
terminal.scrollTop = terminalDiv.scrollHeight;
}
});
terminalDiv.addEventListener('click', () => {
commandInput.focus();
});
</script>
</body>
</html>