From dc512ab07603ab464b711184cdbf1c64e193d151 Mon Sep 17 00:00:00 2001 From: amy Date: Mon, 6 Feb 2023 13:55:30 -0600 Subject: start menu --- display.html | 239 +++++++++++++++++++++++++++++++++++++++++++++++------------ server.js | 15 ++++ src/jssh.js | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tty.html | 194 +----------------------------------------------- 4 files changed, 431 insertions(+), 240 deletions(-) create mode 100644 server.js create mode 100644 src/jssh.js diff --git a/display.html b/display.html index 2d1b4a1..09ea35a 100644 --- a/display.html +++ b/display.html @@ -4,6 +4,7 @@ + - +
-
 
Start - +
+
 
Start +
@@ -649,20 +746,64 @@
-
Windows Update
+
+
Windows Update
+ +
-
Programs
-
Favorites
-
Documents
-
Settings
-
Find
-
Help
-
Run
+
+
Programs
+
+
+ +
+
+
+
Favorites
+
+
+
+
Documents
+
+
+
+
Settings
+
+
+
+
Find
+
+
+
+
Help
+
+
+
Run
+
-
Log Off...
-
Shut Down...
+
+
Log Off...
+
+
+
Shut Down...
+
- + \ No newline at end of file diff --git a/server.js b/server.js new file mode 100644 index 0000000..574916b --- /dev/null +++ b/server.js @@ -0,0 +1,15 @@ +//temp server +const express = require("express"); +const app = express(); +const port = 8008; + +app.get("/tty", (req, res) => { + res.sendFile(__dirname + "/tty.html"); +}); +app.get("/display", (req, res) => { + res.sendFile(__dirname + "/display.html"); +}); +app.use("/src", express.static("src")); +app.listen(port, () => { + console.log(`${port}`); +}); diff --git a/src/jssh.js b/src/jssh.js new file mode 100644 index 0000000..c78ca6d --- /dev/null +++ b/src/jssh.js @@ -0,0 +1,223 @@ +let jssh = { + set_wd(dir) { + //let lwd = fs + let wd = fs; + let path = dir + .split("/") + .filter(function (e) { + return e !== ""; + }) + .filter(function (e) { + return e !== "."; + }); + for (let i in path) { + if (path[i] == "..") { + path.splice(i - 1, 2); + } + } + + for (let dir of path) { + let found = false; + //lwd = wd; + if (dir != ".") { + for (let i of wd) { + if (i.name == dir && i.dir) { + wd = i.content; + found = true; + break; + } + } + if (!found) { + return 1; + } + } + } + return wd; + //return 1; + }, + clean_path(path) { + path = path + .split("/") + .filter(function (e) { + return e !== ""; + }) + .filter(function (e) { + return e.replace(" ", "") !== "."; + }); + for (let i = path.length; i != 0; i--) { + if (path[i] == "..") { + path.splice(i - 1, 2); + } + } + return "/" + path.join("/"); + }, + main() { + for (let d of fs) { + if (d.name == ".bashrc") { + for (let line of d.content.split("\n")) { + document.getElementById("line").value = line; + jssh.ex(); + } + break; + } + } + setInterval(() => { + document.getElementById("line").focus(); + }, 10); + }, + ex() { + let temp_working_dir = working_dir; + document.getElementById("history").innerHTML += + "λ " + document.getElementById("line").value + "
"; + let com = document.getElementById("line").value; + let stripped = com.split(" "); + switch (stripped[0]) { + case "jssh": + jssh.main(); + break; + case "neofetch": + let add = ""; + add += + "
\
+,-.       _,---._ __   / \\ \n \
+/  )    .-'       `./ /   \\ \n \
+(  (   ,'            `/    /| \n \
+\\  `-\"             '\\    / | \n \
+`.              ,   \\ /   | \n \
+/`.          ,'-`----Y   | \n \
+(            ;        |   ' \n \
+|  ,-.    ,-'         |  / \n \
+|  | (   |            | / \n \
+)  |  \\  `.___________|/ \n \
+`--'   `--' 
"; //position this plz:) + add += + "
hello, i am amelia, they/them
i am mostly a typescript and c++ dev, but
i can work in most languages
--
i enjoy manga, and coding in free time
contact me at ameliasquires@disroot.org

"; + colors = ["#cdb4db", "#ffc8dd", "#ffafcc", "#bde0fe", "#a2d2ff"]; + for (let co of colors) { + add += + "
";
+        }
+        add += "
"; + colors = ["#a81d61", "#ff218e", "#fcd800", "#0194fc", "#007cd5"]; + for (let co of colors) { + add += + "
";
+        }
+
+        add += "


"; + document.getElementById("history").innerHTML += add; + break; + case "clear": + document.getElementById("history").innerHTML = ""; + break; + case "echo": + document.getElementById("history").innerHTML += com.substr(4) + "
"; + break; + case "help": + document.getElementById("history").innerHTML += + "jssh -- version 1.0.0 (dev)

commands: neofetch, help,
cat [path],pwd,
ls [path] [-a], cd [path],
clear, echo [str],jssh
"; + break; + case "cat": + temp_working_dir += "/"; + for (let i of stripped) { + if (i != stripped[0] && i[0] != "-") { + if (i[0] == "/") temp_working_dir = i; + else temp_working_dir += i; + break; + } + } + let tt = temp_working_dir.split("/"); + tt.splice(tt.length - 1, 1); + let wa = jssh.set_wd(jssh.clean_path(tt.join("/"))); + for (let a of wa) { + if ( + a.name == + temp_working_dir.split("/")[ + temp_working_dir.split("/").length - 1 + ] && + !a.dir + ) { + document.getElementById("history").innerHTML += a.content + "
"; + document.getElementById("line").value = ""; + return; + } + } + document.getElementById("history").innerHTML += + "jssh: " + + jssh.clean_path(temp_working_dir) + + " file or dir not found
"; + break; + case "pwd": + document.getElementById("history").innerHTML += + jssh.clean_path(temp_working_dir) + "
"; + break; + case "cd": + if (temp_working_dir != "/") temp_working_dir += "/"; + for (let i of stripped) { + if (i != stripped[0] && i[0] != "-") { + if (i[0] == "/") temp_working_dir = i + "/"; + else temp_working_dir += i + "/"; + break; + } + } + let ww = jssh.set_wd(temp_working_dir); + if (ww == 1) { + document.getElementById("history").innerHTML += + "jssh: `" + temp_working_dir + "` directory not found
"; + return; + } + working_dir = jssh.clean_path(temp_working_dir); + + break; + case "ls": + if (temp_working_dir != "/") temp_working_dir += "/"; + for (let i of stripped) { + if (i != stripped[0] && i[0] != "-") { + if (i[0] == "/") temp_working_dir = i + "/"; + else temp_working_dir += i + "/"; + break; + } + } + let wd = jssh.set_wd(jssh.clean_path(temp_working_dir)); + if (wd == 1) { + document.getElementById("history").innerHTML += + "jssh: `" + temp_working_dir + "` directory not found
"; + return; + } + if (stripped.includes("-a")) { + document.getElementById("history").innerHTML += + "[.]
"; + document.getElementById("history").innerHTML += + "[..]
"; + } + + for (let i of wd) { + if ( + (i.name[0] == "." && stripped.includes("-a")) || + i.name[0] != "." + ) { + if (i.dir) + document.getElementById("history").innerHTML += + "[" + + i.name + + "]
"; + else + document.getElementById("history").innerHTML += i.name + "
"; + } + } + break; + default: + document.getElementById("history").innerHTML += + "jssh: " + + stripped[0] + + ": command not found or not implemented
"; + break; + } + + document.getElementById("line").value = ""; + }, +}; diff --git a/tty.html b/tty.html index 859d3a8..34b6be7 100644 --- a/tty.html +++ b/tty.html @@ -5,6 +5,7 @@ nya~ +