added some more commands

This commit is contained in:
valentijn
2024-01-25 14:22:59 +01:00
parent d0fb604680
commit f6e8eda33c
4 changed files with 153 additions and 13 deletions

View File

@@ -11,17 +11,20 @@ async function sendCommand(e){
const command = e.target.value;
deactivateAllStuff();
if (command == "clear"){
if (command.trim() == "clear"){
lines = document.querySelectorAll(".terminalLine").forEach((line)=>{
line.remove();
})
createNewTerminalLine();
return;
}
else if (command.trim() == "logout" || command.trim() == "exit"){
window.location.href = "https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwj2jve6z_iDAxWb9rsIHflPD_sQwqsBegQIDxAF&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ&usg=AOvVaw0aHtehaphMhOCAkCydRLZU&opi=89978449"
}
try {
// Construct the URL with the command parameter in the query string
const url = "/execute?command=" + encodeURIComponent(command) + "&currentDir=" + encodeURIComponent(currentFolder);
const url = "/execute?command=" + encodeURIComponent(command);
// Make a GET request using the fetch API
const response = await fetch(url);
@@ -96,11 +99,14 @@ function createNewTerminalLine(){
pathColon.innerHTML = ":";
pathColon.classList.add("pathColon");
let pathPath = document.createElement("h4");
pathPath.innerHTML = "~"+currentFolder;
pathPath.classList.add("pathPath");
fetch('/currentDir')
.then(response => response.text())
.then(data => {
pathPath.innerHTML = "~"+data;
pathPath.classList.add("pathPath");
})
.catch(error => console.error('Error:', error));
let pathDollar = document.createElement("h4");
pathDollar.innerHTML = "$";