-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (35 loc) · 1.18 KB
/
script.js
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
document.addEventListener("DOMContentLoaded", () => {
const inputField = document.getElementById("commandInput");
inputField.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
const command = inputField.value.trim();
handleCommand(command);
inputField.value = ""; // Clear the input
}
});
});
// Function to handle commands
function handleCommand(command) {
switch (command.toLowerCase()) {
case "cd home":
window.location.href = "index.html";
break;
case "cd about":
window.location.href = "about.html";
break;
case "cd projects":
window.location.href = "projects.html";
break;
case "cd blog":
window.location.href = "blog.html";
break;
case "ls":
alert("Available commands: cd about, cd projects, cd blog");
break;
case "help":
alert("Use 'cd <tab_name>' to navigate between sections. Use 'ls' to list options.");
break;
default:
alert("Command not recognized. Type 'help' for a list of commands.");
}
}