aboutsummaryrefslogtreecommitdiff
path: root/console/src/jsMain/kotlin/main.kt
blob: a607e69ba71d0c9575ad256fc8a7a5b3fe9fba0d (plain)
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
import kotlinx.browser.document
import kotlinx.css.*
import kotlinx.html.dom.append
import kotlinx.html.js.div
import moe.nea89.website.*
import styled.injectGlobal
import kotlin.time.Duration.Companion.milliseconds


val defaultFileSystem = fileSystem {
    "etc" {
        "passwd" text "hunter2"
    }
    "home/exhq" {
        "todo" text """
                | - git gud
                | - finish this website
                | - convince the general public that comic sans is a viable font
            """.trimMargin()
    }
    "flag" text "CTF{12345abcdefghijklmonp3.1.4.1.5.9.2.8}"
}

fun main() {

    val root = document.body!!.append.div()
    val console = KConsole.createFor(root, fileSystem = defaultFileSystem)
    injectGlobal {
        ".${Styles.consoleClass}" {
            minHeight = 100.vh
            backgroundColor = Color("#282a39C6")
        }
        body {
            backgroundImage = Image("url(weebshit1.jpg)")
            backgroundSize = "cover"
        }

    }
    console.addLine("Starting stfff")
    console.PS1 = { "${console.fileAccessor!!.currentDir.joinToString("/", "/")} > " }
    console.fileAccessor!!.cd("/home/exhq")
    console.rerender()
    console.registerCommand(defaultLsCommand("ls", delayBetweenLines = 0.milliseconds))
    console.registerCommand(defaultCdCommand("cd"))
    console.registerCommand(defaultCatCommand("cat"))
    console.registerCommand(defaultCwdCommand("cwd", "pwd"))

}