diff options
author | amy <[email protected]> | 2023-02-07 10:29:53 -0600 |
---|---|---|
committer | amy <[email protected]> | 2023-02-07 10:29:53 -0600 |
commit | bd02efca2061364fde845e6c9b2748496558f745 (patch) | |
tree | ee3aa4782752ea3df0da4b93899df7230e6fb8b7 | |
parent | 66ce636d79268272bead830af642c75f09f9906e (diff) |
updates i think
-rw-r--r-- | html/display.html | 55 | ||||
-rw-r--r-- | html/tty.html | 8 | ||||
-rw-r--r-- | src/jssh.js | 37 | ||||
-rw-r--r-- | src/server.js | 6 |
4 files changed, 63 insertions, 43 deletions
diff --git a/html/display.html b/html/display.html index 718a018..ee90429 100644 --- a/html/display.html +++ b/html/display.html @@ -52,6 +52,15 @@ #root { position: relative; background-color: cornsilk; + background-image: url("src/img/wallpaper.png"); + background-repeat: no-repeat; + background-origin: content-box; + background-attachment: fixed; + background-position: center top; + -webkit-background-size: cover; + -moz-background-size: cover; + -o-background-size: cover; + background-size: cover; width: 90%; height: 90%; margin-left: 5%; @@ -291,15 +300,16 @@ background-color: #c7c7c7; } - textarea{ - resize:none; - background-color: rgba(0,0,0,0); - border:none; + + textarea { + resize: none; + background-color: rgba(0, 0, 0, 0); + border: none; outline: none; - overflow:scroll; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; + overflow: scroll; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; } </style> <script> @@ -385,11 +395,11 @@ } } let minx = 150; - let miny = 150; + let miny = 150; function window_create(uid, name, content, options = {}) { let lines = content.split("</br>").length let a = '' - + 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 + "'>" @@ -417,19 +427,19 @@ a += "<div id='" + uid + "-resize-es' class='resize-es'></div>" document.getElementById("root").innerHTML += a //console.log(document.getElementById(uid + "-content-root").clientHeight / (document.getElementById(uid + "-content-content").clientHeight / document.getElementById(uid + "-content-root").clientHeight)) - + //console.log(document.getElementById(uid + "-content-scrollbar-point")) refresh_windows() } - function refresh_windows(){ + function refresh_windows() { let elems = document.getElementsByClassName("window") 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) - document.getElementById(uid + "-content-scrollbar").style.display = 'none' - else - document.getElementById(uid + "-content-scrollbar").style.display = 'block' + 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' //let elem = elems.item(i).children[0] let elec = elems.item(i).children let elem @@ -672,12 +682,12 @@ } - + } - function auto_resize(i){ - - i.style.height = i.value.split("\n").length * 30 + function auto_resize(i) { + + 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" }] }] @@ -688,7 +698,7 @@ if (words[0] == "window") { let t = line.split(" ") t.splice(0, 2) - window_create(0, words[1], t.join(" "), { size: { width: 500, height: 500 } }) + window_create(document.getElementsByClassName("window").length, words[1], t.join(" "), { size: { width: 500, height: 500 } }) load_bar() } } @@ -720,7 +730,8 @@ 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"))) + let t_s = new jssh(fs, '/', document.getElementsByClassName('window').length) + 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" src="./src/img/notepad.png"> diff --git a/html/tty.html b/html/tty.html index 34b6be7..59ed435 100644 --- a/html/tty.html +++ b/html/tty.html @@ -63,16 +63,20 @@ , { 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) + function main() { + aaa.main() + } </script> </head> -<body onload="jssh.main()"> +<body onload="main()"> <div id="history"> </div> - <form autocomplete="off" onsubmit="jssh.ex();return false;"> + <form autocomplete="off" onsubmit="aaa.ex();return false;"> λ <input id="line" style="width:95%;" onblur="this.focus()" autofocus> <input type="submit" style="display: none" /> </form> diff --git a/src/jssh.js b/src/jssh.js index 64e81df..e07e387 100644 --- a/src/jssh.js +++ b/src/jssh.js @@ -1,4 +1,9 @@ -let jssh = { +class jssh { + constructor(fs, working_dir, uid) { + this.fs = fs; + this.working_dir = working_dir; + this.uid = uid; + } set_wd(dir) { //let lwd = fs let wd = fs; @@ -34,7 +39,7 @@ let jssh = { } return wd; //return 1; - }, + } clean_path(path) { path = path .split("/") @@ -50,13 +55,13 @@ let jssh = { } } 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(); + this.ex(); } break; } @@ -64,16 +69,16 @@ let jssh = { setInterval(() => { document.getElementById("line").focus(); }, 10); - }, + } ex() { - let temp_working_dir = working_dir; + let temp_working_dir = this.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(); + this.main(); break; case "neofetch": let add = ""; @@ -92,7 +97,7 @@ let jssh = { `--' `--' </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"]; + let 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:" + @@ -132,7 +137,7 @@ let jssh = { } let tt = temp_working_dir.split("/"); tt.splice(tt.length - 1, 1); - let wa = jssh.set_wd(jssh.clean_path(tt.join("/"))); + let wa = this.set_wd(this.clean_path(tt.join("/"))); for (let a of wa) { if ( a.name == @@ -148,12 +153,12 @@ let jssh = { } document.getElementById("history").innerHTML += "jssh: " + - jssh.clean_path(temp_working_dir) + + this.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>"; + this.clean_path(temp_working_dir) + "</br>"; break; case "cd": if (temp_working_dir != "/") temp_working_dir += "/"; @@ -164,13 +169,13 @@ let jssh = { break; } } - let ww = jssh.set_wd(temp_working_dir); + let ww = this.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); + this.working_dir = this.clean_path(temp_working_dir); break; case "ls": @@ -182,7 +187,7 @@ let jssh = { break; } } - let wd = jssh.set_wd(jssh.clean_path(temp_working_dir)); + let wd = this.set_wd(this.clean_path(temp_working_dir)); if (wd == 1) { document.getElementById("history").innerHTML += "jssh: `" + temp_working_dir + "` directory not found</br>"; @@ -219,5 +224,5 @@ let jssh = { } document.getElementById("line").value = ""; - }, -}; + } +} diff --git a/src/server.js b/src/server.js index 9a6713f..e9f022e 100644 --- a/src/server.js +++ b/src/server.js @@ -4,12 +4,12 @@ const app = express(); const port = 8008; app.get("/tty", (req, res) => { - res.sendFile(__dirname + "/html/tty.html"); + res.sendFile("html/tty.html",{'root': './'}); }); app.get("/display", (req, res) => { - res.sendFile(__dirname + "/html/display.html"); + res.sendFile("html/display.html",{'root': './'}); }); -app.use("/src", express.static("src")); +app.use("/src", express.static("src",{'root': './'})); app.listen(port, () => { console.log(`http://localhost:${port}`); }); |