1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
<html>
<head>
<meta charset="UTF-8">
<title>nya~</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
:root {
--primary: #ee2757;
--complement: #eb586f;
--contrast: #8144e9;
--white: #f0fcfb;
--black: #212121;
--font-size: 17px;
}
* {
margin: 0;
}
body {
background-color: var(--black);
font-family: 'Press Start 2P';
color: var(--white);
font-size: var(--font-size);
text-shadow: 0 0 10px var(--white);
}
input {
background-color: rgba(0, 0, 0, 0);
font-family: 'Press Start 2P';
color: var(--white);
font-size: var(--font-size);
text-shadow: 0 0 10px var(--white);
border: none;
}
input {
border: 0;
outline: 0;
}
input:focus {
outline: none !important;
}
input:hover {
cursor: text;
}
</style>
<script>
let working_dir = "/"
let fs = [
{ name: ".bashrc", perms: { r: true }, dir: false, content: "neofetch" },
{ name: "readme", perms: { r: true }, dir: false, content: "i dont really know what to put here:(" }
, { name: "more-aboutme", perms: { r: true }, dir: false, content: "experienced development in ts/js and c/c++\nless experience but still some in\nclojure, java, python, and probably some more.\n\ni like manga and anime, favorites are something like\n(not ordered) mushoku tensei, pet girl of sakurasou\noverlord, rising of shield here\nand that time i got reincarnated as a slime.\n\ni also play some games n stuff,\nlove terraria, and some other similar games\ni also lovelove visual novels\nusually romance/horror ones" }
, { name: "test", perms: { r: true }, dir: true, content: [{ name: "aaa", perms: { r: true }, dir: false, content: "test test test" }] }
, { 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 amelia, 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()">
<div id="history">
</div>
<form autocomplete="off" onsubmit="ex();return false;">
λ <input id="line" style="width:95%;" onblur="this.focus()" autofocus>
<input type="submit" style="display: none" />
</form>
</body>
</html>
|