diff options
-rw-r--r-- | html/display.html | 59 | ||||
-rw-r--r-- | html/tty.html | 2 | ||||
-rw-r--r-- | justfile | 6 | ||||
-rw-r--r-- | src/badge-gen.lua | 2 | ||||
-rw-r--r-- | src/img/wallpaper.jpg | bin | 0 -> 1395169 bytes | |||
-rw-r--r-- | src/img/wallpaper.webp | bin | 45798 -> 0 bytes | |||
-rw-r--r-- | src/jssh.js | 50 |
7 files changed, 86 insertions, 33 deletions
diff --git a/html/display.html b/html/display.html index ee90429..ff8e3a8 100644 --- a/html/display.html +++ b/html/display.html @@ -6,6 +6,7 @@ <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"> + <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet"> <style> @font-face { font-family: f98; @@ -15,7 +16,7 @@ * { margin: 0; font-family: f98; - + font-size: 15px; scrollbar-width: none; } @@ -52,11 +53,11 @@ #root { position: relative; background-color: cornsilk; - background-image: url("src/img/wallpaper.png"); + background-image: url("src/img/wallpaper.jpg"); background-repeat: no-repeat; background-origin: content-box; background-attachment: fixed; - background-position: center top; + background-position: center center; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; @@ -311,6 +312,25 @@ -moz-box-shadow: none; box-shadow: none; } + + input { + background-color: rgba(0, 0, 0, 0); + text-shadow: 0 0 10px white; + border: none; + } + + input { + border: 0; + outline: 0; + } + + input:focus { + outline: none !important; + } + + input:hover { + cursor: text; + } </style> <script> function compare(a, b) { @@ -436,7 +456,7 @@ for (let i = 0; i != elems.length; i++) { let uid = elems.item(i).id.split("-")[0] document.getElementById(uid + "-content-scrollbar-point").style.height = (document.getElementById(uid + "-content-root").clientHeight / (document.getElementById(uid + "-content-content").clientHeight / document.getElementById(uid + "-content-root").clientHeight)) + "px" - if (document.getElementById(uid + "-content-scrollbar-point").clientHeight > document.getElementById(uid + "-content-root").clientHeight) + if (document.getElementById(uid + "-content-scrollbar-point").clientHeight >= document.getElementById(uid + "-content-root").clientHeight) document.getElementById(uid + "-content-scrollbar").style.display = 'none' else document.getElementById(uid + "-content-scrollbar").style.display = 'block' @@ -690,7 +710,32 @@ i.style.height = (i.value.split("\n").length + 1) * 25 refresh_windows() } - 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 <textarea onkeypress=\\'auto_resize(this)\\' style=\\'width:100%;overflow:visible;display:block;\\'>uwu</textarea>" }, { name: "cmd", icon: "./src/img/cmd.png", perms: { r: true }, dir: false, content: "window" }] }] + let procs = {} + function exe_com(a) { + let exe; + let id = a.parentElement.id.split("-")[0] + + let a_c = a.children; + for (let i = 0; i != a_c.length; i++) { + if (a_c.item(i).id == id + "-line") { + let inp = a_c.item(i).id + let a_p_c = a.parentElement.children + for (let ii = 0; ii != a_p_c.length; ii++) { + if (a_p_c.item(ii).id == id + "-history") { + let his = a_p_c.item(ii).id + if (procs[id] == undefined) + procs[id] = new jssh(fs, "/", id, inp, his) + procs[id].ex() + refresh_windows() + a.parentElement.parentElement.scrollTop = a.parentElement.parentElement.scrollHeight + break + } + } + break + } + } + } + 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 <textarea onkeypress=\\'auto_resize(this)\\' style=\\'width:100%;overflow:visible;display:block;\\'></textarea>" }, { name: "cmd", icon: "./src/img/cmd.png", perms: { r: true }, dir: false, content: "window cmd <div class=\\'history\\' id=\\'#_ID-history\\'></div><form autocomplete=\\'off\\' onsubmit=\\'exe_com(this);return false;\\'>λ <input id=\\'#_ID-line\\' class=\\'line\\' style=\\'width:95%;\\' autofocus><input type=\\'submit\\' style=\\'display: none\\' /></form>" }] }] function shortcut(i) { let parsed = i.split("\n") for (let line of parsed) { @@ -698,7 +743,7 @@ if (words[0] == "window") { let t = line.split(" ") t.splice(0, 2) - window_create(document.getElementsByClassName("window").length, words[1], t.join(" "), { size: { width: 500, height: 500 } }) + window_create(document.getElementsByClassName("window").length, words[1], t.join(" ").replace(/#_ID/g, document.getElementsByClassName("window").length), { size: { width: 500, height: 500 } }) load_bar() } } @@ -730,7 +775,7 @@ for (let i = 0; i != i_c.length; i++) { let id = i_c.item(i) if (id.className == "bar-menu-more-root") { - let t_s = new jssh(fs, '/', document.getElementsByClassName('window').length) + let t_s = new jssh(fs, '/', document.getElementsByClassName('window').length, 'null', 'null') let dd = (t_s.set_wd(items.item(item).getAttribute("dir"))) /* <div class="bar-menu-item" id="bar-menu-favorites"><img class="bar-menu-image" diff --git a/html/tty.html b/html/tty.html index 59ed435..171277d 100644 --- a/html/tty.html +++ b/html/tty.html @@ -63,7 +63,7 @@ , { 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" }] } ] - let aaa = new jssh(fs, working_dir, 0) + let aaa = new jssh(fs, working_dir, 0, "line", "history") function main() { aaa.main() } @@ -1,6 +1,8 @@ -default: - node src/server.js +alias default := server +alias cloc := loc server: node src/server.js badge-gen: lua src/badge-gen.lua +loc: + cloc . diff --git a/src/badge-gen.lua b/src/badge-gen.lua index e2be96d..3cda339 100644 --- a/src/badge-gen.lua +++ b/src/badge-gen.lua @@ -1,5 +1,5 @@ local path = "./badges/" -local badges = io.popen("ls "..path) +local badges = io.popen("dir "..path) if badges then for i in string.gmatch(badges:read("*a"), "(.-)\n") do io.write("<img alt=\""..path..i.."\" src=\""..path..i.."\">"); diff --git a/src/img/wallpaper.jpg b/src/img/wallpaper.jpg Binary files differnew file mode 100644 index 0000000..dbbee16 --- /dev/null +++ b/src/img/wallpaper.jpg diff --git a/src/img/wallpaper.webp b/src/img/wallpaper.webp Binary files differdeleted file mode 100644 index fe0a2c5..0000000 --- a/src/img/wallpaper.webp +++ /dev/null diff --git a/src/jssh.js b/src/jssh.js index e07e387..5eac0a2 100644 --- a/src/jssh.js +++ b/src/jssh.js @@ -1,7 +1,9 @@ class jssh { - constructor(fs, working_dir, uid) { + constructor(fs, working_dir, uid, input, h) { this.fs = fs; this.working_dir = working_dir; + this.input = input; + this.history = h; this.uid = uid; } set_wd(dir) { @@ -54,27 +56,28 @@ class jssh { path.splice(i - 1, 2); } } + if (path.includes("..")) path = []; 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; + document.getElementById(this.input).value = line; this.ex(); } break; } } setInterval(() => { - document.getElementById("line").focus(); + document.getElementById(this.input).focus(); }, 10); } ex() { let temp_working_dir = this.working_dir; - document.getElementById("history").innerHTML += - "λ " + document.getElementById("line").value + "</br>"; - let com = document.getElementById("line").value; + document.getElementById(this.history).innerHTML += + "λ " + document.getElementById(this.input).value + "</br>"; + let com = document.getElementById(this.input).value; let stripped = com.split(" "); switch (stripped[0]) { case "jssh": @@ -114,16 +117,17 @@ class jssh { } add += "</td></tr></table></br></br>"; - document.getElementById("history").innerHTML += add; + document.getElementById(this.history).innerHTML += add; break; case "clear": - document.getElementById("history").innerHTML = ""; + document.getElementById(this.history).innerHTML = ""; break; case "echo": - document.getElementById("history").innerHTML += com.substr(4) + "</br>"; + document.getElementById(this.history).innerHTML += + com.substr(4) + "</br>"; break; case "help": - document.getElementById("history").innerHTML += + document.getElementById(this.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": @@ -146,18 +150,19 @@ class jssh { ] && !a.dir ) { - document.getElementById("history").innerHTML += a.content + "</br>"; - document.getElementById("line").value = ""; + document.getElementById(this.history).innerHTML += + a.content + "</br>"; + document.getElementById(this.input).value = ""; return; } } - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "jssh: " + this.clean_path(temp_working_dir) + " file or dir not found</br>"; break; case "pwd": - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += this.clean_path(temp_working_dir) + "</br>"; break; case "cd": @@ -171,7 +176,7 @@ class jssh { } let ww = this.set_wd(temp_working_dir); if (ww == 1) { - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "jssh: `" + temp_working_dir + "` directory not found</br>"; return; } @@ -189,14 +194,14 @@ class jssh { } let wd = this.set_wd(this.clean_path(temp_working_dir)); if (wd == 1) { - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "jssh: `" + temp_working_dir + "` directory not found</br>"; return; } if (stripped.includes("-a")) { - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "<font style='opacity:.3'>[</font>.<font style='opacity:.3'>]</font></br>"; - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "<font style='opacity:.3'>[</font>..<font style='opacity:.3'>]</font></br>"; } @@ -206,23 +211,24 @@ class jssh { i.name[0] != "." ) { if (i.dir) - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "<font style='opacity:.3'>[</font>" + i.name + "<font style='opacity:.3'>]</font></br>"; else - document.getElementById("history").innerHTML += i.name + "</br>"; + document.getElementById(this.history).innerHTML += + i.name + "</br>"; } } break; default: - document.getElementById("history").innerHTML += + document.getElementById(this.history).innerHTML += "jssh: " + stripped[0] + ": command not found or not implemented</br>"; break; } - document.getElementById("line").value = ""; + document.getElementById(this.input).value = ""; } } |