manual submission redesign phase F

This commit is contained in:
Joren de Graaf
2026-10-06 19:57:14 +02:00
parent 5820ea850a
commit d112028eb1
7 changed files with 73 additions and 13 deletions
+18 -1
View File
@@ -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);