added some more commands, chnaged filesystem layout, and added a help command :)
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user