manual submission redesign phase F
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
const directionStatus = () => document.querySelector("#manual-direction-status");
|
||||
const directionPanel = () => document.querySelector("#manual-direction-panel");
|
||||
const compass = document.querySelector("#manual-compass");
|
||||
const compassHome = document.querySelector("#manual-compass-home");
|
||||
const compassRose = document.querySelector("#manual-compass-rose");
|
||||
const compassHeading = document.querySelector("#manual-compass-heading");
|
||||
const reportTime = document.querySelector("#manual-report-time");
|
||||
let orientationListener;
|
||||
let compassUnavailableTimeout;
|
||||
let compassRotation = null;
|
||||
@@ -25,6 +27,14 @@
|
||||
const isUsableNumber = (value) => Number.isFinite(value);
|
||||
const cardinalDirection = (heading) => ["N", "NE", "E", "SE", "S", "SW", "W", "NW"][Math.floor(((heading + 22.5) % 360) / 45)];
|
||||
const displayDegrees = (value) => Number(value.toFixed(1)).toString();
|
||||
const updateReportTime = () => {
|
||||
if (!reportTime) return;
|
||||
const now = new Date();
|
||||
reportTime.dateTime = now.toISOString();
|
||||
reportTime.textContent = now.toLocaleTimeString(document.documentElement.lang || undefined, { hour: "2-digit", minute: "2-digit" });
|
||||
};
|
||||
updateReportTime();
|
||||
if (reportTime) window.setInterval(updateReportTime, 60000);
|
||||
const idleSubmitLabel = submitLabel?.textContent || "I heard fireworks";
|
||||
|
||||
const setSubmissionState = (next, message = "") => {
|
||||
@@ -198,10 +208,17 @@
|
||||
|
||||
manualForm.addEventListener("click", (event) => {
|
||||
if (event.target.closest("#manual-capture-direction")) captureDirection();
|
||||
if (event.target.closest(".manual-direction-panel__close")) stopCompassReading();
|
||||
if (event.target.closest(".manual-direction-panel__close")) {
|
||||
stopCompassReading();
|
||||
if (compassHome) compassHome.append(compass);
|
||||
}
|
||||
});
|
||||
document.body.addEventListener("htmx:beforeSwap", (event) => {
|
||||
if (event.detail.target?.id === "manual-direction-panel" && compassHome) compassHome.append(compass);
|
||||
});
|
||||
document.body.addEventListener("htmx:afterSwap", (event) => {
|
||||
if (event.detail.target?.id !== "manual-direction-panel") return;
|
||||
if (captureDirectionButton()) directionPanel().querySelector(".manual-direction-panel__copy")?.after(compass);
|
||||
const summary = document.querySelector("#manual-direction-summary");
|
||||
if (summary && directionDegrees.value !== "") {
|
||||
const heading = Number(directionDegrees.value);
|
||||
|
||||
Reference in New Issue
Block a user