manual submission redesign phase G

This commit is contained in:
Joren de Graaf
2026-10-06 20:04:21 +02:00
parent d112028eb1
commit c0c0bd7db8
11 changed files with 206 additions and 15 deletions
+8 -7
View File
@@ -1,4 +1,5 @@
const form = document.querySelector("#manual-report-form");
const form = document.querySelector("#manual-report-form");
const t = window.BOOMCAST_I18N || {};
export function createBurstListener() {
if (!form) return null;
@@ -47,12 +48,12 @@ export function createBurstListener() {
state = next;
if (container) container.dataset.state = next;
if (section) section.dataset.state = next;
if (stateLabel) stateLabel.textContent = next === "listening" ? "Listening for the next bang" : next === "tail" ? "Sound detected" : next === "captured" ? "Sound captured" : "Not listening";
if (stateLabel) stateLabel.textContent = next === "listening" ? (t.listeningNextBang || "Listening for the next bang") : next === "tail" ? (t.soundDetected || "Sound detected") : next === "captured" ? (t.soundCaptured || "Sound captured") : (t.notListening || "Not listening");
start.hidden = next !== "off";
panel.hidden = next === "off";
resume.hidden = discard.hidden = next !== "captured";
heading.textContent = next === "captured" ? "Sound captured" : next === "tail" ? "Sound detected — finishing clip…" : "Listening for the next sound…";
detail.textContent = next === "listening" ? "Keeping the most recent ~10 seconds" : next === "captured" ? "Preview the clip or send your report." : "";
heading.textContent = next === "captured" ? (t.soundCaptured || "Sound captured") : next === "tail" ? (t.soundDetectedFinishing || "Sound detected — finishing clip…") : (t.listeningNextSound || "Listening for the next sound…");
detail.textContent = next === "listening" ? (t.keepingRecentAudio || "Keeping the most recent ~10 seconds") : next === "captured" ? (t.previewClipOrSend || "Preview the clip or send your report.") : "";
}
function wav(samples, rate) {
@@ -81,7 +82,7 @@ export function createBurstListener() {
start.disabled = true;
if (container) container.dataset.state = "starting";
if (section) section.dataset.state = "starting";
if (stateLabel) stateLabel.textContent = "Starting microphone…";
if (stateLabel) stateLabel.textContent = t.startingMicrophone || "Starting microphone…";
try {
if (!navigator.mediaDevices?.getUserMedia || !window.AudioWorkletNode) throw new Error("Microphone listening is unavailable in this browser or connection.");
stream = await navigator.mediaDevices.getUserMedia({ audio: { channelCount: 1 }, video: false });
@@ -122,8 +123,8 @@ export function createBurstListener() {
await end();
if (container) container.dataset.state = "error";
if (section) section.dataset.state = "error";
if (stateLabel) stateLabel.textContent = "Microphone unavailable";
error.textContent = cause.name === "NotAllowedError" ? "Microphone permission was denied. Manual reporting is still available." : (cause.message || "Microphone capture failed.");
if (stateLabel) stateLabel.textContent = t.microphoneUnavailable || "Microphone unavailable";
error.textContent = cause.name === "NotAllowedError" ? (t.microphoneDenied || "Microphone permission was denied. Manual reporting is still available.") : (t.microphoneFailed || "Microphone capture failed.");
error.hidden = false;
} finally {
start.disabled = false;
+4 -1
View File
@@ -25,7 +25,10 @@
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)];
const cardinalDirection = (heading) => [
t.north || "North", t.northeast || "Northeast", t.east || "East", t.southeast || "Southeast",
t.south || "South", t.southwest || "Southwest", t.west || "West", t.northwest || "Northwest",
][Math.floor(((heading + 22.5) % 360) / 45)];
const displayDegrees = (value) => Number(value.toFixed(1)).toString();
const updateReportTime = () => {
if (!reportTime) return;