diff options
Diffstat (limited to 'vfd-dashboard/src')
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/Launcher.scala | 35 | ||||
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/Main.scala | 16 |
2 files changed, 14 insertions, 37 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/Launcher.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/Launcher.scala deleted file mode 100644 index d091911..0000000 --- a/vfd-dashboard/src/main/scala/vfd/dashboard/Launcher.scala +++ /dev/null @@ -1,35 +0,0 @@ -package vfd.dashboard - -import scala.scalajs.js.annotation.JSExport - -import org.scalajs.dom -import org.scalajs.dom.html - -@JSExport("Launcher") -class Launcher(rootId: String, assetsBase: String) { - - lazy val env = new Environment { - val root = dom.document.getElementById(rootId).asInstanceOf[html.Element] - 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 (env.root.hasChildNodes) { - env.root.removeChild(env.root.firstChild) - } - - Main.main(args.toMap)(env) - } - -}
\ No newline at end of file diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/Main.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/Main.scala index 36ca2db..71c5378 100644 --- a/vfd-dashboard/src/main/scala/vfd/dashboard/Main.scala +++ b/vfd-dashboard/src/main/scala/vfd/dashboard/Main.scala @@ -1,11 +1,23 @@ package vfd.dashboard +import scala.scalajs.js +import scala.scalajs.js.annotation.JSExport + +import org.scalajs.dom.html + import vfd.dashboard.ui.Layout +@JSExport("Main") object Main { - def main(args: Map[String, String])(implicit env: Environment) = { - val socket = new MavlinkSocket(args("socketurl"), args("remotesystemid").toInt) + @JSExport + def main(rootElement: html.Element, assetsBase: String, args: js.Dictionary[String]) = { + implicit val env = new Environment { + def root = rootElement + def asset(file: String) = assetsBase + "/" + file + } + + val socket = new MavlinkSocket(args("socketUrl"), args("remoteSystemId").toInt) val layout = new Layout(socket) env.root.appendChild(layout.element) |