-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (60 loc) · 1.61 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
<!DOCTYPE html>
<html>
<head>
<title>Simulated Terminal</title>
<style>
body {
background-color: black;
color: white;
font-family: monospace;
}
#terminal {
border: 1px solid white;
padding: 10px;
height: 400px;
overflow-y: scroll;
}
#input {
color: white;
background-color: black;
border: none;
outline: none;
width: 90%;
font-size: 1.2em;
}
#prompt {
color: green;
}
</style>
</head>
<body>
<div id="terminal">
<p>Welcome to the simulated terminal.</p>
<p>Type "help" to see a list of available commands.</p>
</div>
<div>
<span id="prompt">$</span>
<input type="text" id="input" autofocus>
</div>
<script>
const terminal = document.getElementById("terminal");
const input = document.getElementById("input");
const prompt = document.getElementById("prompt");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
const command = input.value;
input.value = "";
terminal.innerHTML += `<p>${prompt.textContent} ${command}</p>`;
if (command === "help") {
terminal.innerHTML += "<p>Available commands: help, clear.</p>";
} else if (command === "clear") {
terminal.innerHTML = "";
} else {
terminal.innerHTML += `<p>"${command}" is not a recognized command.</p>`;
}
terminal.scrollTop = terminal.scrollHeight;
}
});
</script>
</body>
</html>