aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramy <[email protected]>2023-02-06 13:55:30 -0600
committeramy <[email protected]>2023-02-06 13:55:30 -0600
commit12123f1aca0b74efdb9b2b36a794d70c9c74b081 (patch)
tree1a2e7cdb951f7b3f82b3b6a9519f8e470ef5b73b
parent66dfe0550c6bc7b3a3dd7ad3c0f002d4ea2c46f6 (diff)
start menu
-rw-r--r--display.html239
-rw-r--r--server.js15
-rw-r--r--src/jssh.js223
-rw-r--r--tty.html194
4 files changed, 431 insertions, 240 deletions
diff --git a/display.html b/display.html
index 2d1b4a1..09ea35a 100644
--- a/display.html
+++ b/display.html
@@ -4,6 +4,7 @@
<!--<script src="https://raw.githubusercontent.com/a-weeb-programmer/libcute/main/src/libcute.h"></script> lol-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+ <script rel="preconnect" src="./src/jssh.js" crossorigin></script>
<link href="https://fonts.googleapis.com/css2?family=Flow+Circular&display=swap" rel="stylesheet">
<style>
@font-face {
@@ -217,48 +218,78 @@
outline-offset: -2px;
cursor: pointer;
-
+
}
+
#bar-menu-root {
padding-top: 2px;
- height:280px;
- width:180px;
+ height: 280px;
+ width: 180px;
background-color: #c7c7c7;
position: absolute;
- border-style:outset;
- bottom:30px;
+ border-style: outset;
+ bottom: 30px;
display: none;
}
- .bar-menu-item{
- padding-left:5px;
+
+ .bar-menu-item {
+ padding-left: 5px;
width: 100%;
- height:25px;
- display:flex;
+ height: 25px;
+ display: flex;
font-size: 14px;
font-weight: bold;
padding-top: 1px;
+ user-select: none;
}
- .bar-menu-image{
+
+ .bar-menu-image {
height: 18px;
- padding-left:5px;
- padding-right:5px;
+ padding-left: 5px;
+ padding-right: 5px;
}
- .bar-menu-text{
+
+ .bar-menu-text {
position: absolute;
- left:30px;
- padding-top:2px;
+ left: 35px;
+ padding-top: 2px;
}
- .bar-menu-separator{
- width:calc(100% - 20px);
+
+ .bar-menu-separator {
+ width: calc(100% - 20px);
height: 3px;
margin-bottom: 5px;
background-color: #a1a1a1;
- border-style:none none solid none;
- border-color:#dddddd;
- border-width:2px;
- left:10px;
+ border-style: none none solid none;
+ border-color: #dddddd;
+ border-width: 2px;
+ left: 10px;
position: relative;
}
+
+ .bar-menu-more {
+ width: 0;
+ height: 0;
+ border-top: 5px solid transparent;
+ border-left: 7px solid #000000;
+ border-bottom: 5px solid transparent;
+ position: absolute;
+ right: 5px;
+ margin-top: 6px;
+
+ }
+
+ .bar-menu-more-root {
+ display: none;
+ width: 120px;
+ height: fit-content;
+ border-style: outset outset outset none;
+ right: -123px;
+ position: absolute;
+ padding-top: 3px;
+ background-color: #c7c7c7;
+
+ }
</style>
<script>
function compare(a, b) {
@@ -325,10 +356,10 @@
})
let px = 0;
document.onmousemove = ((evm) => {
- if((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth/2)))>0){
- if((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft - (elemy.clientWidth/2)))<elemy.parentElement.clientWidth -5){
- elemy.style.left =(elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth /2)))
- }else {
+ if ((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth / 2))) > 0) {
+ if ((elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft - (elemy.clientWidth / 2))) < elemy.parentElement.clientWidth - 5) {
+ elemy.style.left = (elemy.parentElement.clientWidth * (evm.clientX / elemy.parentElement.clientWidth) - (elemy.parentElement.offsetLeft + document.getElementById("root").offsetLeft + (elemy.clientWidth / 2)))
+ } else {
elemy.style.left = elemy.parentElement.clientWidth - elemy.clientWidth - 5
}
} else {
@@ -342,12 +373,14 @@
}
}
}
- function window_create(uid, name, content) {
+ function window_create(uid, name, content, options = {}) {
let lines = content.split("</br>").length
let a = ''
let minx = 150;
let miny = 150;
- a += "<div id='" + uid + "-root' class='window' style=\"width:" + Math.max(document.body.clientWidth * .56, minx) + "px;height:" + Math.max(miny, document.body.clientHeight * .30) + "px;top:0px;left:0px;position:absolute;\" window-name='" + name + "'>"
+ let size = (options.size != undefined) ? ("width:" + options.size.width + "px;height:" + options.size.height + "px;") : ("width:" + Math.max(document.body.clientWidth * .56, minx) + "px;height:" + Math.max(miny, document.body.clientHeight * .30) + "px;");
+
+ a += "<div id='" + uid + "-root' class='window' style=\"" + size + "top:0px;left:0px;position:absolute;\" window-name='" + name + "'>"
//console.log(document.getElementById(uid).attributes["window-name"].value)
a += "<div id='" + uid + "-head' class='head-border' window-name='" + name + "'> <div style='color:fdffff'>" + name + "</div>"
a += "<div id='" + uid + "-close' class='close-button' window-name='" + name + "'>" + `<svg draggable="false" xmlns="http://www.w3.org/2000/svg" style="position:absolute;left:-3px;top:0px;" xmlns:xlink="http://www.w3.org/1999/xlink" width="23px" height="20px" viewBox="0 0 23 20" version="1.1">
@@ -360,8 +393,9 @@
a += "<div id='" + uid + "-resize-e' class='resize-e'></div>"
a += "<div id='" + uid + "-resize-w' class='resize-w'></div>"
a += "<div style='height:25px;'></div>"
- a += "<div id='" + uid + "-content-root' class='content-root' style='overflow:scroll;height:calc(100% - 26px);width:100%'><div id='" + uid + "-content-content' class='content-content'>" + content
- a += "</div><div id='" + uid + "-content-scrollbar' class='scrollbar'><div id='" + uid + "-content-scrollbar-point' class='scrollbar-point'></div>"
+ a += "<div id='" + uid + "-content-root' class='content-root' style='overflow:scroll;height:calc(100% - 26px);width:100%'>"
+ a += "<div id='" + uid + "-content-content' class='content-content'>" + content + "</div>"
+ a += "<div id='" + uid + "-content-scrollbar' class='scrollbar'><div id='" + uid + "-content-scrollbar-point' class='scrollbar-point'></div>"
a += "</div>"
a += "</div>"
@@ -622,25 +656,88 @@
}
- function main(){
- document.getElementById("bar-menu").onclick = ((ev)=>{
- if(document.getElementById("bar-menu-root").style.display=="block")
- document.getElementById("bar-menu-root").style.display = "none"
+ let fs = [{ name: "apps", perms: { r: true }, dir: true, content: [{ name: "notepad", icon: "./src/img/notepad.png", perms: { r: true }, dir: false, content: "window Notepad <input>uwu" }, { name: "cmd", icon: "./src/img/cmd.png", perms: { r: true }, dir: false, content: "window" }] }]
+ function shortcut(i) {
+ let parsed = i.split("\n")
+ for (let line of parsed) {
+ let words = line.split(" ")
+ if (words[0] == "window") {
+ let t = line.split(" ")
+ t.splice(0, 2)
+ window_create(0, words[1], t.join(" "), { size: { width: 500, height: 500 } })
+ load_bar()
+ }
+ }
+ }
+ function close_menu() {
+ let items = document.getElementsByClassName("bar-menu-item")
+ for (let item = 0; item != items.length; item++) {
+ let i_c = items.item(item).children
+ for (let i = 0; i != i_c.length; i++) {
+ let id = i_c.item(i)
+ if (id.className == "bar-menu-more-root") {
+ id.style.display = "none"
+ }
+ }
+ }
+ document.getElementById("bar-menu-root").style.display = "none"
+ main()
+ }
+ function main() {
+ document.getElementById("bar-menu").onclick = ((ev) => {
+ if (document.getElementById("bar-menu-root").style.display == "block")
+ document.getElementById("bar-menu-root").style.display = "none"
else
- document.getElementById("bar-menu-root").style.display = "block"
+ document.getElementById("bar-menu-root").style.display = "block"
})
+ let items = document.getElementsByClassName("bar-menu-item")
+ for (let item = 0; item != items.length; item++) {
+ let i_c = items.item(item).children
+ for (let i = 0; i != i_c.length; i++) {
+ let id = i_c.item(i)
+ if (id.className == "bar-menu-more-root") {
+ let dd = (jssh.set_wd(items.item(item).getAttribute("dir")))
+ /*
+ <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image"
+ src="./src/img/notepad.png">
+ <div class="bar-menu-text">Notepad--</div>
+ </div>
+ */
+ id.innerHTML = ''
+ let ins = ""
+ for (let ite = 0; ite != dd.length; ite++) {
+
+ ins += `<div class="bar-menu-item" onclick="shortcut('${dd[ite].content}');close_menu();" id="bar-menu-${dd[ite].name}">`
+ if (dd[ite].icon)
+ ins += `<img class="bar-menu-image" src="${dd[ite].icon}">`
+ ins += `<div class="bar-menu-text">${dd[ite].name}</div></div>`
+
+
+ //console.log(id.children.item(ite))
+ }
+ id.innerHTML = ins;
+ items.item(item).onmouseover = ((ev) => {
+ id.style.display = "block"
+ items.item(item).onmouseout = ((ev) => {
+ id.style.display = "none"
+ })
+ })
+ break;
+ }
+ }
+ }
}
</script>
</head>
-<body
- onload="window_create(1,'hewwo','hi</br></br></br></br></br></br></br></br></br></br></br></br>hi');window_create(2,'uwu','uwu');load_bar();main()">
+<body onload="main()">
<div id="root">
<div id="bar">
<div id="bar-children">
- <div id="bar-menu" ><img src="./src/img/windows.png"><pre> </pre>Start
-
+ <div id="bar-menu"><img src="./src/img/windows.png">
+ <pre> </pre>Start
+
</div>
<div id="bar-items">
</div>
@@ -649,20 +746,64 @@
</div>
</div>
<div id="bar-menu-root">
- <div class="bar-menu-item" id="bar-menu-windows-update"><img class="bar-menu-image" src="./src/img/update.png"><div class="bar-menu-text">Windows Update</div></div>
+ <div class="bar-menu-item" id="bar-menu-windows-update"><img class="bar-menu-image"
+ src="./src/img/update.png">
+ <div class="bar-menu-text">Windows Update</div>
+
+ </div>
<div class="bar-menu-separator"></div>
- <div class="bar-menu-item" id="bar-menu-programs"><img class="bar-menu-image" src="./src/img/programs.png"><div class="bar-menu-text">Programs</div></div>
- <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image" src="./src/img/favorites.png"><div class="bar-menu-text">Favorites</div></div>
- <div class="bar-menu-item" id="bar-menu-docs"><img class="bar-menu-image" src="./src/img/docs.png"><div class="bar-menu-text">Documents</div></div>
- <div class="bar-menu-item" id="bar-menu-settings"><img class="bar-menu-image" style="height:25px" src="./src/img/settings.png"><div class="bar-menu-text">Settings</div></div>
- <div class="bar-menu-item" id="bar-menu-find"><img class="bar-menu-image" style="height:25px" src="./src/img/find.png"><div class="bar-menu-text">Find</div></div>
- <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" src="./src/img/help.png"><div class="bar-menu-text">Help</div></div>
- <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" src="./src/img/run.png"><div class="bar-menu-text">Run</div></div>
+ <div class="bar-menu-item" id="bar-menu-programs" dir="/apps/"><img class="bar-menu-image"
+ src="./src/img/programs.png">
+ <div class="bar-menu-text">Programs</div>
+ <div class="bar-menu-more"></div>
+ <div class="bar-menu-more-root">
+ <!--
+ <div class="bar-menu-item" id="bar-menu-favorites" shortcut-path=""><img class="bar-menu-image"
+ src="./src/img/notepad.png">
+ <div class="bar-menu-text">Notepad</div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image"
+ src="./src/img/notepad.png">
+ <div class="bar-menu-text">Notepad--</div>
+ </div>-->
+ </div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image"
+ src="./src/img/favorites.png">
+ <div class="bar-menu-text">Favorites</div>
+ <div class="bar-menu-more"></div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-docs"><img class="bar-menu-image" src="./src/img/docs.png">
+ <div class="bar-menu-text">Documents</div>
+ <div class="bar-menu-more"></div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-settings"><img class="bar-menu-image"
+ style="height:27px;padding-left:2px" src="./src/img/settings.png">
+ <div class="bar-menu-text">Settings</div>
+ <div class="bar-menu-more"></div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-find"><img class="bar-menu-image"
+ style="height:27px;padding-left:2px" src="./src/img/find.png">
+ <div class="bar-menu-text">Find</div>
+ <div class="bar-menu-more"></div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" src="./src/img/help.png">
+ <div class="bar-menu-text">Help</div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" src="./src/img/run.png">
+ <div class="bar-menu-text">Run</div>
+ </div>
<div class="bar-menu-separator"></div>
- <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" style="height:24px" src="./src/img/log-off.png"><div class="bar-menu-text">Log Off...</div></div>
- <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" style="height:24px" src="./src/img/shut-down.png"><div class="bar-menu-text">Shut Down...</div></div>
+ <div class="bar-menu-item" id="bar-menu-help"><img class="bar-menu-image" style="height:24px"
+ src="./src/img/log-off.png">
+ <div class="bar-menu-text">Log Off...</div>
+ </div>
+ <div class="bar-menu-item" id="bar-menu-run"><img class="bar-menu-image" style="height:24px"
+ src="./src/img/shut-down.png">
+ <div class="bar-menu-text">Shut Down...</div>
+ </div>
</div>
</div>
</body>
-</html>
+</html> \ 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..64e81df
--- /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 + "</br>";
+ let com = document.getElementById("line").value;
+ let stripped = com.split(" ");
+ switch (stripped[0]) {
+ case "jssh":
+ jssh.main();
+ break;
+ case "neofetch":
+ let add = "";
+ add +=
+ "<table style='padding:5px;'><tr style='padding:5px;'><td style='padding:5px;'><pre id='txt'>\
+,-. _,---._ __ / \\ \n \
+/ ) .-' `./ / \\ \n \
+( ( ,' `/ /| \n \
+\\ `-\" '\\ / | \n \
+`. , \\ / | \n \
+/`. ,'-`----Y | \n \
+( ; | ' \n \
+| ,-. ,-' | / \n \
+| | ( | | / \n \
+) | \\ `.___________|/ \n \
+`--' `--' </pre>"; //position this plz:)
+ add +=
+ "</td><td style='padding:5px;'>hello, i am grant, they/them</br>i am mostly a typescript and c++ dev, but</br>i can work in most languages</br>--</br>i enjoy manga, and coding in free time</br>contact me at [email protected]</br></br>";
+ colors = ["#cdb4db", "#ffc8dd", "#ffafcc", "#bde0fe", "#a2d2ff"];
+ for (let co of colors) {
+ add +=
+ "<pre style='margin-bottom:-2px;display:inline-block;height:25px;width:30px;background-color:" +
+ co +
+ ";'></pre>";
+ }
+ add += "</br>";
+ colors = ["#a81d61", "#ff218e", "#fcd800", "#0194fc", "#007cd5"];
+ for (let co of colors) {
+ add +=
+ "<pre style='display:inline-block;height:25px;width:30px;background-color:" +
+ co +
+ ";'></pre>";
+ }
+
+ add += "</td></tr></table></br></br>";
+ document.getElementById("history").innerHTML += add;
+ break;
+ case "clear":
+ document.getElementById("history").innerHTML = "";
+ break;
+ case "echo":
+ document.getElementById("history").innerHTML += com.substr(4) + "</br>";
+ break;
+ case "help":
+ document.getElementById("history").innerHTML +=
+ "jssh -- version 1.0.0 (dev)</br></br>commands: neofetch, help,</br> cat [path],pwd,</br>ls [path] [-a], cd [path],</br>clear, echo [str],jssh</br>";
+ 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 + "</br>";
+ document.getElementById("line").value = "";
+ return;
+ }
+ }
+ document.getElementById("history").innerHTML +=
+ "jssh: " +
+ jssh.clean_path(temp_working_dir) +
+ " file or dir not found</br>";
+ break;
+ case "pwd":
+ document.getElementById("history").innerHTML +=
+ jssh.clean_path(temp_working_dir) + "</br>";
+ 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</br>";
+ 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</br>";
+ return;
+ }
+ if (stripped.includes("-a")) {
+ document.getElementById("history").innerHTML +=
+ "<font style='opacity:.3'>[</font>.<font style='opacity:.3'>]</font></br>";
+ document.getElementById("history").innerHTML +=
+ "<font style='opacity:.3'>[</font>..<font style='opacity:.3'>]</font></br>";
+ }
+
+ for (let i of wd) {
+ if (
+ (i.name[0] == "." && stripped.includes("-a")) ||
+ i.name[0] != "."
+ ) {
+ if (i.dir)
+ document.getElementById("history").innerHTML +=
+ "<font style='opacity:.3'>[</font>" +
+ i.name +
+ "<font style='opacity:.3'>]</font></br>";
+ else
+ document.getElementById("history").innerHTML += i.name + "</br>";
+ }
+ }
+ break;
+ default:
+ document.getElementById("history").innerHTML +=
+ "jssh: " +
+ stripped[0] +
+ ": command not found or not implemented</br>";
+ break;
+ }
+
+ document.getElementById("line").value = "";
+ },
+};
diff --git a/tty.html b/tty.html
index 2f2b737..34b6be7 100644
--- a/tty.html
+++ b/tty.html
@@ -5,6 +5,7 @@
<title>nya~</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+ <script rel="preconnect" src="./src/jssh.js" crossorigin></script>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
@@ -62,205 +63,16 @@
, { name: ".secret", perms: { r: true }, dir: true, content: [{ name: "readme", perms: { r: true }, dir: false, content: "still working on things:) nothing here is final\n or even close" }] }
]
- function 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;
-
- }
- function 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("/")
- }
- function main() {
- for (let d of fs) {
- if (d.name == '.bashrc') {
- for (let line of d.content.split("\n")) {
- document.getElementById("line").value = line
- ex()
- }
- break
- }
- }
- setInterval(() => {
- document.getElementById("line").focus()
- }, 10)
- }
- function ex() {
- let temp_working_dir = working_dir
- document.getElementById("history").innerHTML += "λ " + document.getElementById("line").value + "</br>"
- let com = document.getElementById("line").value;
- let stripped = com.split(" ")
- switch (stripped[0]) {
- case 'jssh':
- main()
- break;
- case 'neofetch':
- let add = ''
- add += "<table style='padding:5px;'><tr style='padding:5px;'><td style='padding:5px;'><pre id='txt'>\
- ,-. _,---._ __ / \\ \n \
- / ) .-' `./ / \\ \n \
-( ( ,' `/ /| \n \
- \\ `-\" \'\\ / | \n \
- `. , \\ / | \n \
- /`. ,'-`----Y | \n \
- ( ; | ' \n \
- | ,-. ,-' | / \n \
- | | ( | | / \n \
- ) | \\ `.___________|/ \n \
- `--' `--' </pre>" //position this plz:)
- add += "</td><td style='padding:5px;'>hello, i am grant, they/them</br>i am mostly a typescript and c++ dev, but</br>i can work in most languages</br>--</br>i enjoy manga, and coding in free time</br>contact me at [email protected]</br></br>"
- colors = ['#cdb4db', '#ffc8dd', '#ffafcc', '#bde0fe', '#a2d2ff']
- for (let co of colors) {
- add += "<pre style='margin-bottom:-2px;display:inline-block;height:25px;width:30px;background-color:" + co + ";'></pre>"
- }
- add += "</br>"
- colors = ['#a81d61', '#ff218e', '#fcd800', '#0194fc', '#007cd5']
- for (let co of colors) {
- add += "<pre style='display:inline-block;height:25px;width:30px;background-color:" + co + ";'></pre>"
- }
-
- add += "</td></tr></table></br></br>"
- document.getElementById("history").innerHTML += add
- break;
- case 'clear':
- document.getElementById("history").innerHTML = '';
- break;
- case 'echo':
- document.getElementById("history").innerHTML += com.substr(4) + "</br>";
- break;
- case 'help':
- document.getElementById("history").innerHTML += "jssh -- version 1.0.0 (dev)</br></br>commands: neofetch, help,</br> cat [path],pwd,</br>ls [path] [-a], cd [path],</br>clear, echo [str],jssh</br>"
- 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 = set_wd(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 + "</br>"
- document.getElementById("line").value = ""
- return
- }
- }
- document.getElementById("history").innerHTML += "jssh: " + clean_path(temp_working_dir) + " file or dir not found</br>"
- break;
- case 'pwd':
- document.getElementById("history").innerHTML += clean_path(temp_working_dir) + "</br>"
- 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 = set_wd(temp_working_dir)
- if (ww == 1) {
- document.getElementById("history").innerHTML += "jssh: `" + temp_working_dir + "` directory not found</br>"
- return
- }
- working_dir = 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 = set_wd(clean_path(temp_working_dir))
- if (wd == 1) {
- document.getElementById("history").innerHTML += "jssh: `" + temp_working_dir + "` directory not found</br>"
- return
- }
- if (stripped.includes("-a")) {
- document.getElementById("history").innerHTML += "<font style='opacity:.3'>[</font>.<font style='opacity:.3'>]</font></br>"
- document.getElementById("history").innerHTML += "<font style='opacity:.3'>[</font>..<font style='opacity:.3'>]</font></br>"
- }
-
- for (let i of wd) {
- if (i.name[0] == '.' && stripped.includes("-a") || i.name[0] != '.') {
- if (i.dir)
- document.getElementById("history").innerHTML += "<font style='opacity:.3'>[</font>" + i.name + "<font style='opacity:.3'>]</font></br>"
- else
- document.getElementById("history").innerHTML += i.name + "</br>"
- }
- }
- break;
- default:
- document.getElementById("history").innerHTML += "jssh: " + stripped[0] + ": command not found or not implemented</br>"
- break;
- }
-
- document.getElementById("line").value = ""
- }
</script>
</head>
-<body onload="main()">
+<body onload="jssh.main()">
<div id="history">
</div>
- <form autocomplete="off" onsubmit="ex();return false;">
+ <form autocomplete="off" onsubmit="jssh.ex();return false;">
λ <input id="line" style="width:95%;" onblur="this.focus()" autofocus>
<input type="submit" style="display: none" />
</form>