mapcomplete/index.ts

54 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-09-08 21:40:48 +02:00
import { FixedUiElement } from "./UI/Base/FixedUiElement"
import Combine from "./UI/Base/Combine"
import { Utils } from "./Utils"
import AllThemesGui from "./UI/AllThemesGui"
import DetermineLayout from "./Logic/DetermineLayout"
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig"
import ShowOverlayLayerImplementation from "./UI/ShowDataLayer/ShowOverlayLayerImplementation"
import { DefaultGuiState } from "./UI/DefaultGuiState"
2022-09-08 21:40:48 +02:00
ShowOverlayLayerImplementation.Implement()
2021-10-15 14:52:11 +02:00
// Miscelleanous
Utils.DisableLongPresses()
class Init {
2021-12-21 19:56:04 +01:00
public static Init(layoutToUse: LayoutConfig) {
2021-11-07 16:34:51 +01:00
if (layoutToUse === null) {
// Something went wrong, error message is already on screen
2022-09-08 21:40:48 +02:00
return
}
2021-11-07 16:34:51 +01:00
if (layoutToUse === undefined) {
// No layout found
2022-04-08 04:36:00 +02:00
new AllThemesGui().setup()
2022-09-08 21:40:48 +02:00
return
}
2020-06-24 00:35:19 +02:00
const guiState = new DefaultGuiState()
2022-09-08 21:40:48 +02:00
DefaultGuiState.state = guiState
}
}
2022-09-08 21:40:48 +02:00
document.getElementById("decoration-desktop").remove()
new Combine([
"Initializing... <br/>",
new FixedUiElement(
"<a>If this message persist, something went wrong - click here to try again</a>"
)
.SetClass("link-underline small")
.onClick(() => {
2022-09-08 21:40:48 +02:00
localStorage.clear()
window.location.reload()
2022-09-08 21:40:48 +02:00
}),
]).AttachTo("centermessage") // Add an initialization and reset button if something goes wrong
2021-12-21 18:35:31 +01:00
// @ts-ignore
2022-09-08 21:40:48 +02:00
DetermineLayout.GetLayout()
.then((value) => {
console.log("Got ", value)
Init.Init(value)
})
.catch((err) => {
console.error("Error while initializing: ", err, err.stack)
})