added some more commands, chnaged filesystem layout, and added a help command :)

This commit is contained in:
valentijn
2024-01-19 11:48:07 +01:00
parent e4be64245b
commit 73d455d4bd
3 changed files with 81 additions and 20 deletions

View File

@@ -15,10 +15,51 @@ document.addEventListener("DOMContentLoaded", function () {
async function sendCommand(e){
const command = e.target.value;
// e.target.value = "";
// resizeInput();
deactivateAllStuff();
if (command.startsWith("cd")){
let commandSplit = command.split(" ");
console.log(commandSplit)
try {
if (commandSplit[1].startsWith("/")){
currentFolder = commandSplit[1];
if (!commandSplit[1].endsWith("/")){
currentFolder += "/"
}
}
else if (commandSplit[1].startsWith("~")){
currentFolder = "/";
}
else if (commandSplit[1].startsWith("./")) {
currentFolder += commandSplit[1].slice(2);
if (!commandSplit[1].endsWith("/")){
currentFolder += "/"
}
} else {
currentFolder += commandSplit[1];
if (!commandSplit[1].endsWith("/")){
currentFolder += "/"
}
}
createNewTerminalLine();
addInputEventListeners();
return;
} catch {
handleExecutionResponse({"response": "Invalid Argument"})
return;
}
}
if (command.startsWith("clear")){
lines = document.querySelectorAll(".terminalLine").forEach((line)=>{
line.remove();
})
createNewTerminalLine();
addInputEventListeners();
return;
}
console.log("COMMAND SENT: "+command);
try {
@@ -65,11 +106,6 @@ function deactivateAllStuff() {
function handleExecutionResponse(response) {
if (response.command === "cd"){
currentFolder = response.directory
}
//Show Response
let commandResponse = document.createElement("div")
commandResponse.classList.add("terminalLine");