changing the commands to ostly run server-side (NOT DONE))

a
This commit is contained in:
valentijn
2024-01-19 19:16:30 +01:00
parent 33db47102c
commit d0fb604680
4 changed files with 59 additions and 89 deletions

View File

@@ -1,54 +1,17 @@
const terminalContainer = document.getElementById("terminal");
const hostname = `192.168.${Math.floor(Math.random() * 100)}.${Math.floor(Math.random() * 255)}`;
let currentFolder = "/";
document.addEventListener("DOMContentLoaded", function () {
document.querySelector(".pathText").innerHTML = `guest@${hostname}`;
addInputEventListeners();
});
async function sendCommand(e){
const command = e.target.value;
deactivateAllStuff();
if (command.startsWith("cd")){
let commandSplit = command.split(" ");
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();
return;
} catch {
handleExecutionResponse({"response": "Invalid Argument"})
return;
}
}
if (command.startsWith("clear")){
if (command == "clear"){
lines = document.querySelectorAll(".terminalLine").forEach((line)=>{
line.remove();
})