Add beforeunload interaction
authorTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 14 Feb 2022 00:35:01 +0000 (19:35 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 14 Feb 2022 00:35:01 +0000 (19:35 -0500)
src/jsMain/kotlin/starshipfights/game/client.kt

index 5cbb870b80ac7392a6070f76c7d5b2b82e94b288..f949f37fba23dbd90ba63aba6b4413ab8c4d715e 100644 (file)
@@ -37,6 +37,11 @@ fun main() {
                        RenderResources.load(clientMode !is ClientMode.InGame)
                }.display()
                
+               window.addEventListener("beforeunload", {e ->
+                       e.preventDefault()
+                       e.asDynamic().returnValue = ""
+               })
+               
                when (clientMode) {
                        is ClientMode.MatchmakingMenu -> matchmakingMain(clientMode.admirals)
                        is ClientMode.InGame -> gameMain(clientMode.playerSide, clientMode.connectToken, clientMode.initialState)