changing the commands to ostly run server-side (NOT DONE))
a
This commit is contained in:
@@ -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();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user