2022-04-30 21:18:10 +03:00
"use strict" ;
2021-09-05 02:21:11 +03:00
var root = false ;
2021-10-09 03:22:48 +03:00
var not _return = false ;
2021-09-05 02:21:11 +03:00
2022-04-30 21:18:10 +03:00
add _boot _entry ( boot _message ) ;
2021-09-05 02:21:11 +03:00
async function main ( ) {
2022-04-30 21:18:10 +03:00
let is _logged _in =
localStorage . getItem ( "username" ) && localStorage . getItem ( "password" ) ;
2021-09-05 02:21:11 +03:00
let tmp _boot _entries = {
0 : {
2022-04-30 21:18:10 +03:00
type : "error" ,
text : "No user account found" ,
2021-09-05 02:21:11 +03:00
} ,
1 : {
2022-04-30 21:18:10 +03:00
type : "warning" ,
text : "Creating account" ,
sleep _time : 500 ,
2021-09-05 02:21:11 +03:00
} ,
3 : {
2022-04-30 21:18:10 +03:00
type : "ok" ,
text : ` Found user account: <b> ${
localStorage . getItem ( "username" )
? escape _HTML ( localStorage . getItem ( "username" ) )
: ""
} < / b > ` ,
2021-09-05 02:21:11 +03:00
} ,
4 : {
2022-04-30 21:18:10 +03:00
type : "ok" ,
text : "Loading HTML" ,
2021-09-05 02:21:11 +03:00
} ,
5 : {
2022-04-30 21:18:10 +03:00
type : "ok" ,
text : "Loading a basic shell" ,
2021-09-05 02:21:11 +03:00
} ,
6 : {
2022-04-30 21:18:10 +03:00
type : "ok" ,
text : ` ' ${ site _name } ' has been booted! Type <b>help</b> for help. ` ,
2021-10-09 03:22:48 +03:00
} ,
7 : {
2022-04-30 21:18:10 +03:00
type : "error" ,
text : 'A fatal error has occured, report it <a href="/git">here</a>' ,
sleep _time : 0 ,
} ,
2022-06-08 22:32:29 +03:00
8 : {
type : "warning" ,
2022-06-10 22:41:47 +03:00
text : '<a href="https://blog.ari-web.xyz/b/important--impersonation-of-me-on-the-internet/">Currently there has been a lot of impersonating happening! Be careful!</a>' ,
2022-06-08 22:32:29 +03:00
sleep _time : 1000 ,
} ,
2022-04-30 21:18:10 +03:00
} ;
2021-09-05 02:21:11 +03:00
2022-06-08 22:32:29 +03:00
await add _boot _entry ( { 0 : tmp _boot _entries [ 8 ] } ) ;
2021-09-05 02:21:11 +03:00
if ( ! is _logged _in ) {
2022-04-30 21:18:10 +03:00
await add _boot _entry ( {
0 : tmp _boot _entries [ 0 ] ,
1 : tmp _boot _entries [ 1 ] ,
} ) ;
2021-09-05 02:21:11 +03:00
await sleep ( 500 ) ;
2022-04-30 21:18:10 +03:00
await user _account _create ( ) . catch ( async ( e ) => {
window . localStorage . clear ( ) ;
let boot _error = {
type : "error" ,
text : e ,
sleep _time : 0 ,
} ;
2021-10-09 03:22:48 +03:00
2022-04-30 21:18:10 +03:00
await add _boot _entry ( { 0 : boot _error , 1 : tmp _boot _entries [ 7 ] } ) ;
not _return = true ;
} ) ;
2021-09-05 02:21:11 +03:00
2021-10-09 03:22:48 +03:00
if ( ! not _return ) window . location . reload ( ) ;
2021-09-05 02:21:11 +03:00
} else {
await add _boot _entry ( {
2022-04-30 21:18:10 +03:00
0 : tmp _boot _entries [ 3 ] ,
2021-09-05 02:21:11 +03:00
} ) ;
await add _boot _entry ( {
0 : tmp _boot _entries [ 4 ] ,
1 : tmp _boot _entries [ 5 ] ,
2022-04-30 21:18:10 +03:00
2 : tmp _boot _entries [ 6 ] ,
2021-09-05 02:21:11 +03:00
} ) ;
2022-04-30 21:18:10 +03:00
document . getElementById ( "shell" ) . style . display = "block" ;
document . getElementById ( "prompt" ) . focus ( ) ;
2021-09-05 02:21:11 +03:00
}
}
2022-04-30 21:18:10 +03:00
document . addEventListener ( "DOMContentLoaded" , main ) ;