diff options
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Clock.scala')
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Clock.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Clock.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Clock.scala new file mode 100644 index 0000000..b456765 --- /dev/null +++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Clock.scala @@ -0,0 +1,22 @@ +package vfd.dashboard.ui.instruments + +import org.scalajs.dom +import scala.scalajs.js.Date +import scalatags.JsDom.all._ + +class Clock extends Instrument[Date] { + + def format(date: Date) = date.toLocaleTimeString() + + val initial = new Date + + val element = span(format(initial)).render + + protected def update(value: Date) = { + element.innerHTML = format(value) + } + + dom.setInterval(() => {value() = new Date}, 1000) + ready() + +}
\ No newline at end of file |