diff --git a/assets/js/app.js b/assets/js/app.js index 3d380a4f..7afaf312 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -31,11 +31,27 @@ import topbar from "../vendor/topbar" import {PropagationMap} from "./propagation_map_hook" +const UtcClock = { + mounted() { + this.tick() + this.timer = setInterval(() => this.tick(), 10_000) + }, + tick() { + const now = new Date() + const h = now.getUTCHours().toString().padStart(2, "0") + const m = now.getUTCMinutes().toString().padStart(2, "0") + this.el.textContent = `${h}:${m} UTC` + }, + destroyed() { + clearInterval(this.timer) + } +} + const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") const liveSocket = new LiveSocket("/live", Socket, { longPollFallbackMs: 2500, params: {_csrf_token: csrfToken}, - hooks: {...colocatedHooks, PropagationMap}, + hooks: {...colocatedHooks, PropagationMap, UtcClock}, }) // Show progress bar on live navigation and form submits diff --git a/lib/microwaveprop_web/live/map_live.ex b/lib/microwaveprop_web/live/map_live.ex index 9e6df334..8e32d205 100644 --- a/lib/microwaveprop_web/live/map_live.ex +++ b/lib/microwaveprop_web/live/map_live.ex @@ -271,9 +271,13 @@ defmodule MicrowavepropWeb.MapLive do <%!-- Top-left control panel --%>