mobile menu added
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user