From 484bc7c89948d4c52a1f04fa97a06016fa0b5b4a Mon Sep 17 00:00:00 2001 From: nea Date: Sun, 28 Aug 2022 16:08:50 +0200 Subject: add mobile support --- .../main/kotlin/moe/nea89/website/test/index.kt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'example') diff --git a/example/src/main/kotlin/moe/nea89/website/test/index.kt b/example/src/main/kotlin/moe/nea89/website/test/index.kt index 846b0db..a613a94 100644 --- a/example/src/main/kotlin/moe/nea89/website/test/index.kt +++ b/example/src/main/kotlin/moe/nea89/website/test/index.kt @@ -2,6 +2,7 @@ package moe.nea89.website.test import kotlinext.js.require import kotlinx.browser.document +import kotlinx.browser.window import kotlinx.css.* import kotlinx.html.dom.append import kotlinx.html.js.div @@ -30,6 +31,25 @@ fun main() { val root = document.body!!.append.div() val console = KConsole.createFor(root, fileSystem = defaultFileSystem) console.text.id = "myconsole" + + val mobileNavigators = listOf( + "webos", + "android", + "iphone", + "ipad", + "ipod", + "blackberry", + "iemobile", + "opera mini" + ) + + fun isMobileBrowser() : Boolean{ + return js("'ontouchstart' in document.documentElement") as Boolean + } + + if (window.location.search == "mobile" || (window.location.search != "desktop" && isMobileBrowser())) { + console.openMobileKeyboardOnTap() + } console.fileAccessor!!.cd("home/nea") injectGlobal { body { @@ -37,6 +57,7 @@ fun main() { } ".${Styles.consoleClass}" { margin(LinearDimension.auto) + fontFamily = "\"Comic Mono\", monospace" width = 50.vw height = 50.vh marginTop = 25.vh @@ -44,7 +65,6 @@ fun main() { backgroundClip = BackgroundClip.contentBox overflowY = Overflow.scroll } - } console.addLine("Starting up terminal.") console.PS1 = { "${this.fileAccessor?.currentDir?.joinToString("/", "/") ?: ""} >" } -- cgit