aboutsummaryrefslogtreecommitdiff
path: root/vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala
diff options
context:
space:
mode:
Diffstat (limited to 'vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala')
-rw-r--r--vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala30
1 files changed, 21 insertions, 9 deletions
diff --git a/vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala b/vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala
index 2818bfb..e1715d7 100644
--- a/vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala
+++ b/vfd-frontend/src/main/scala/vfd/frontend/Launcher.scala
@@ -4,21 +4,33 @@ import scala.scalajs.js.annotation.JSExport
import org.scalajs.dom
-import vfd.frontend.util.Application
+import vfd.frontend.util.Environment
@JSExport
-class Launcher {
+class Launcher(rootId: String, assetsBase: String) {
- @JSExport
- def launch(rootId: String, assetsBase: String, mavlinkSocketUrl: String) = {
+ lazy val env = new Environment {
val root = dom.document.getElementById(rootId)
- val app = new Application(root, assetsBase)
- val frontend = new Main(mavlinkSocketUrl)(app)
+ def asset(file: String) = assetsBase + "/" + file
+ }
+
+ @JSExport
+ def main() = {
+ import env._
+
+ val args: Seq[(String, String)] = for (
+ i <- 0 until root.attributes.length;
+ attr = root.attributes.item(i);
+ if attr.name.startsWith("data-")
+ ) yield {
+ attr.name.drop(5) -> attr.value
+ }
- while (root.hasChildNodes) {
- root.removeChild(root.firstChild)
+ while (env.root.hasChildNodes) {
+ env.root.removeChild(env.root.firstChild)
}
- frontend.main()
+
+ Main.main(args.toMap)(env)
}
} \ No newline at end of file