mobile menu added

This commit is contained in:
Joren de Graaf
2026-10-02 13:13:38 +02:00
parent 5410fec8f2
commit 428caef29d
51 changed files with 780 additions and 18 deletions
+20 -2
View File
@@ -1,3 +1,4 @@
import { createBurstListener } from "./burst-listener.js";
const t = window.BOOMCAST_I18N || {};
const manualForm = document.querySelector("#manual-report-form");
@@ -15,6 +16,7 @@
if (isMobileDevice) directionPanel.hidden = false;
let orientationListener;
let compassUnavailableTimeout;
const burstListener = createBurstListener();
const isUsableNumber = (value) => Number.isFinite(value);
const cardinalDirection = (heading) => ["N", "NE", "E", "SE", "S", "SW", "W", "NW"][Math.floor(((heading + 22.5) % 360) / 45)];
@@ -90,9 +92,25 @@
listenForCompassReading();
};
const submitManualReport = () => {
const submitManualReport = async () => {
stopCompassReading();
manualSubmit.disabled = true;
if (burstListener?.active) {
try {
const audio = await burstListener.clipForSubmission();
const data = new FormData(manualForm);
if (audio) data.append("audio", audio);
const response = await fetch(manualForm.action, { method: "POST", body: data, credentials: "same-origin" });
const html = await response.text();
document.querySelector("#manual-submission").outerHTML = html;
if (response.ok) burstListener.submissionSucceeded();
} catch (error) {
document.querySelector("#manual-submission").textContent = "Could not send the report. Please try again.";
} finally {
manualSubmit.disabled = false;
}
return;
}
if (window.htmx) {
htmx.ajax("POST", manualForm.action, {
source: manualForm,
@@ -124,4 +142,4 @@
document.body.addEventListener("htmx:afterRequest", (event) => {
if (event.detail.elt === manualForm) manualSubmit.disabled = false;
});