first commit

This commit is contained in:
Joren de Graaf
2026-10-04 17:09:22 +02:00
commit 1d4407462a
140 changed files with 7893 additions and 0 deletions
@@ -0,0 +1,2 @@
import "../styles/pages/admin-audio-preview.css";
import "../scripts/admin-audio-preview.js";
+2
View File
@@ -0,0 +1,2 @@
import "../scripts/boomcast-page.js";
import "../scripts/audio-upload.js";
+1
View File
@@ -0,0 +1 @@
// Replace this optional entry point with your project's client-side code.
@@ -0,0 +1,2 @@
const t = window.BOOMCAST_I18N || {};
document.querySelectorAll('.audio-preview').forEach(function(box){var button=box.querySelector('.audio-play'),audio=box.querySelector('audio'),label=box.querySelector('.audio-play__label'),status=box.querySelector('.audio-status');button.addEventListener('click',function(){if(!audio.src){audio.src=button.dataset.audioUrl;button.classList.add('is-loading');status.textContent=(t.loadingRecording || 'Loading recording…');}if(audio.paused){audio.play().catch(function(){button.classList.remove('is-loading');status.textContent=(t.couldNotPlay || 'Could not play this recording.');});}else{audio.pause();}});audio.addEventListener('playing',function(){button.classList.remove('is-loading');label.textContent=(t.pauseRecording || 'Pause recording');status.textContent=(t.playingNow || 'Playing now');});audio.addEventListener('pause',function(){if(!audio.ended){label.textContent=(t.resumeRecording || 'Resume recording');status.textContent=(t.paused || 'Paused');}});audio.addEventListener('ended',function(){label.textContent=(t.replayRecording || 'Replay recording');status.textContent=(t.finished || 'Finished');});audio.addEventListener('waiting',function(){button.classList.add('is-loading');status.textContent=(t.buffering || 'Buffering…');});audio.addEventListener('canplay',function(){button.classList.remove('is-loading');});audio.addEventListener('error',function(){button.classList.remove('is-loading');status.textContent=(t.couldNotLoad || 'Could not load this recording.');});});
@@ -0,0 +1,31 @@
const RATE = 16000;
export class AudioPreprocessor {
static async prepare(file, { signal } = {}) {
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
console.log("[BoomCast][YAMNet] Preparing local classification.");
const AudioContextClass = window.AudioContext || window.webkitAudioContext;
if (!AudioContextClass || !(window.OfflineAudioContext || window.webkitOfflineAudioContext)) throw new Error("Browser audio decoding unavailable");
const context = new AudioContextClass();
try {
const decoded = await context.decodeAudioData(await file.arrayBuffer());
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
if (!decoded.duration || !Number.isFinite(decoded.duration)) throw new Error("Invalid audio duration");
const OfflineContextClass = window.OfflineAudioContext || window.webkitOfflineAudioContext;
const offline = new OfflineContextClass(1, Math.ceil(decoded.duration * RATE), RATE);
const source = offline.createBufferSource();
source.buffer = decoded;
source.connect(offline.destination);
source.start();
const rendered = await offline.startRendering();
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
const waveform = rendered.getChannelData(0).slice();
console.log("[BoomCast][YAMNet] Waveform prepared.", {
sampleRate: RATE, samples: waveform.length, durationSeconds: waveform.length / RATE,
});
return waveform;
} finally {
await context.close().catch(() => {});
}
}
}
+409
View File
@@ -0,0 +1,409 @@
const form = document.querySelector(".upload-form");
if (form) {
const t = window.BOOMCAST_I18N || {};
const dropZone = form.querySelector("#drop-zone");
const fileInput = form.querySelector("#audio-file");
const fileName = form.querySelector("#file-name");
const circle = form.querySelector("#upload-progress-circle");
const iconContent = form.querySelector("#upload-icon-content");
const submit = form.querySelector('button[type="submit"]');
const cancel = form.querySelector(".upload-cancel");
const results = form.querySelector("#classification-results");
const gatePanel = form.querySelector("#browser-gate");
const gateTitle = form.querySelector("#browser-gate-title");
const gateMessage = form.querySelector("#browser-gate-message");
const gateChoose = form.querySelector("#browser-gate-choose");
const gateOverride = form.querySelector("#browser-gate-override");
const status = document.querySelector("#upload-status");
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
const browserToggle = form.querySelector("#browser-processing-toggle");
const configElement = document.querySelector("#boomcast-browser-config");
let browserConfig = { browserProcessingBeta: false };
try { browserConfig = JSON.parse(configElement?.textContent || "{}"); }
catch (error) { console.error("[BoomCast][BrowserBeta] Configuration unavailable:", error); }
const browserAvailable = browserConfig.browserProcessingBeta === true && Boolean(browserToggle);
if (browserToggle) browserToggle.checked = false;
const audioAccept = fileInput.accept;
const videoAccept = ",video/*,.mp4,.mov,.m4v,.webm,.mkv,.avi";
const browserModeEnabled = () => browserAvailable && browserToggle.checked;
const isVideoFile = (file) => Boolean(file) &&
(file.type.startsWith("video/") || (!file.type && /\.(mp4|mov|m4v|webm|mkv|avi)$/i.test(file.name || "")));
let browserProcessor = null;
let browserProcessorPromise = null;
let sourceFile = null;
async function getBrowserProcessor() {
if (browserProcessor) return browserProcessor;
browserProcessorPromise ||= import("./browser-submission-processor.js").then(({ BrowserSubmissionProcessor }) => {
browserProcessor = new BrowserSubmissionProcessor(browserConfig);
console.log("[BoomCast][BrowserBeta] Coordinator initialised.");
return browserProcessor;
}).catch((error) => {
browserProcessorPromise = null;
throw error;
});
return browserProcessorPromise;
}
const states = ["idle", "file-selected", "uploading", "processing", "success", "error", "cancelled"];
let request = null;
let busy = false;
let uploadComplete = false;
let processingTimer = null;
let selectionId = 0;
let selectionController = null;
let selectedResult = null;
let preparationPending = false;
let preparationFailed = false;
let gateBlocked = false;
if (!browserAvailable) {
console.log("[BoomCast][BrowserBeta] Feature disabled globally; using existing server flow.");
} else {
console.log("[BoomCast][BrowserBeta] Browser processing disabled by user; using existing server flow.");
}
function setUploadState(state, { progress = null, message = "" } = {}) {
for (const name of states) form.classList.toggle(`audio-upload--${name}`, name === state);
const active = state === "uploading" || state === "processing";
busy = active;
submit.disabled = active;
fileInput.disabled = active;
if (browserToggle) browserToggle.disabled = active;
cancel.hidden = !active;
if (active) form.setAttribute("aria-busy", "true");
else form.removeAttribute("aria-busy");
if (state === "uploading") {
circle.setAttribute("role", "progressbar");
circle.setAttribute("aria-label", t.uploadingAudio || "Uploading audio");
circle.setAttribute("aria-valuemin", "0");
circle.setAttribute("aria-valuemax", "100");
if (progress === null) {
circle.removeAttribute("aria-valuenow");
circle.setAttribute("aria-valuetext", t.uploadingAudio || "Uploading audio");
iconContent.textContent = "↑";
} else {
circle.setAttribute("aria-valuenow", String(progress));
circle.setAttribute("aria-valuetext", `${t.uploadingAudio || "Uploading audio"}: ${progress}%`);
circle.style.setProperty("--upload-progress", `${progress}%`);
iconContent.textContent = `${progress}%`;
}
status.textContent = progress === null ? (t.uploadingAudio || "Uploading audio…") : "";
} else {
circle.removeAttribute("role");
circle.removeAttribute("aria-label");
circle.removeAttribute("aria-valuemin");
circle.removeAttribute("aria-valuemax");
circle.removeAttribute("aria-valuenow");
circle.removeAttribute("aria-valuetext");
iconContent.textContent = state === "processing" ? "◉" : state === "success" ? "✓" : state === "error" ? "!" : "↑";
status.textContent = message || ({
processing: t.uploadCompleteAnalysing || "Upload complete. Analysing audio…",
success: t.analysisComplete || "Analysis complete.",
cancelled: t.uploadCancelled || "Upload cancelled.",
}[state] || "");
}
}
function showFile(file) {
fileName.textContent = file ? file.name : (t.noFile || "No file selected");
if (!busy) setUploadState(file ? "file-selected" : "idle");
if (file) console.log("[boomcast-upload] file selected", { size: file.size, type: file.type });
}
function fail(message, detail) {
clearTimeout(processingTimer);
console.error("[boomcast-upload] upload failed", detail);
setUploadState("error", { message });
request = null;
}
function finishUpload(xhr) {
if (uploadComplete) return;
uploadComplete = true;
console.log("[boomcast-upload] upload complete, awaiting classifier");
// Give a real 100% progress event one paint before showing the separate server state.
processingTimer = window.setTimeout(() => {
if (request === xhr && busy) setUploadState("processing");
}, 120);
}
function handleResponse(xhr) {
clearTimeout(processingTimer);
request = null;
let fragment;
try {
fragment = new DOMParser().parseFromString(xhr.responseText, "text/html");
} catch (error) {
fail(t.analysisFailed || "Analysis could not be completed.", error);
return;
}
const card = fragment.querySelector(".results-card");
if (!card) {
fail(t.analysisFailed || "Analysis could not be completed.", `Unexpected response (HTTP ${xhr.status})`);
return;
}
results.replaceChildren(document.importNode(card, true));
window.htmx?.process(results);
if (xhr.status >= 400 || card.classList.contains("error-card")) {
const message = card.querySelector("p")?.textContent || (t.analysisFailed || "Analysis could not be completed.");
console.error("[boomcast-upload] classification failed", { status: xhr.status, message });
setUploadState("error", { message });
return;
}
console.log("[boomcast-upload] classification response received", xhr.status);
setUploadState("success");
if (form.dataset.scrollToResults === "true") {
results.scrollIntoView({ behavior: reducedMotion.matches ? "instant" : "smooth", block: "start" });
}
}
function selectFile(file) {
selectionId += 1;
selectionController?.abort();
browserProcessor?.cancel();
selectionController = null;
selectedResult = null;
preparationPending = false;
preparationFailed = false;
gateBlocked = false;
gatePanel.hidden = true;
if (!busy) results.replaceChildren();
showFile(file);
if (!busy) { submit.disabled = false; cancel.hidden = true; }
if (!file) return;
console.log("[BoomCast][BrowserBeta] File selected.", { mimeType: file.type, sizeBytes: file.size });
if (!browserModeEnabled()) {
console.log("[BoomCast][BrowserBeta] Server mode selected.");
if (isVideoFile(file)) {
preparationFailed = true;
submit.disabled = true;
status.textContent = t.serverAudioOnly || "Server processing currently accepts audio recordings. Choose an audio file or enable browser processing.";
}
return;
}
console.log("[BoomCast][BrowserBeta] Browser mode selected.");
const id = selectionId;
const controller = new AbortController();
selectionController = controller;
preparationPending = true;
submit.disabled = true;
cancel.hidden = false;
status.textContent = isVideoFile(file)
? (t.extractingAudio || "Extracting audio from video…")
: (t.preparingRecording || "Preparing recording…");
getBrowserProcessor().then((processor) => {
if (id !== selectionId || controller.signal.aborted || !browserModeEnabled()) return null;
processor.setEnabled(true);
return processor.process(file, { signal: controller.signal, onState: (state) => {
if (id !== selectionId) return;
status.textContent = state === "checking" ? (t.checkingRecording || "Checking recording…")
: (t.extractingAudio || "Extracting audio from video…");
} });
}).then((result) => {
if (!result || id !== selectionId || controller.signal.aborted || !browserModeEnabled()) return;
preparationPending = false;
cancel.hidden = true;
if (isVideoFile(file) && result.file === file) {
preparationFailed = true;
submit.disabled = true;
status.textContent = t.videoExtractionFailed || "Could not extract audio from this video. Please choose an audio recording.";
return;
}
selectedResult = result;
gateBlocked = result.gate === "speech_only" || result.gate === "no_match";
if (gateBlocked) {
gateTitle.textContent = result.gate === "speech_only"
? (t.speechGateTitle || "This recording appears to contain speech, but no relevant sound was detected.")
: (t.irrelevantGateTitle || "No relevant sound was detected.");
gateMessage.textContent = result.gate === "speech_only"
? (t.speechGateMessage || "To protect people’s privacy, this recording will not be uploaded automatically. You can still submit it for manual review.")
: (t.irrelevantGateMessage || "BoomCast could not identify a sound this service currently looks for. You can still submit it for manual review.");
gatePanel.hidden = false;
submit.disabled = true;
status.textContent = t.gateChooseMessage || "Recording checked. Choose another recording or submit for manual review.";
} else {
submit.disabled = false;
status.textContent = result.gate === "unavailable"
? (t.localUnavailable || "Local checking was unavailable. BoomCast will use normal server processing.")
: isVideoFile(file)
? (t.videoAudioOnly || "Video processed on this device. Only extracted audio will be sent if you submit.")
: (t.readyToSubmit || "Ready to submit.");
}
}).catch((error) => {
if (id !== selectionId || !browserModeEnabled()) return;
console.error("[BoomCast][BrowserBeta] Unexpected browser pipeline error:", error);
preparationPending = false;
cancel.hidden = true;
if (isVideoFile(file)) {
preparationFailed = true;
submit.disabled = true;
status.textContent = t.videoExtractionFailed || "Could not extract audio from this video. Please choose an audio recording.";
} else {
console.warn("[BoomCast][BrowserBeta] Browser pipeline unavailable; falling back to server.");
selectedResult = { file, metadata: null, gate: "unavailable" };
submit.disabled = false;
status.textContent = t.localUnavailable || "Local checking was unavailable. BoomCast will use normal server processing.";
}
});
}
function restoreOriginalFile() {
if (!sourceFile || fileInput.files[0] === sourceFile) return;
try {
const transfer = new DataTransfer();
transfer.items.add(sourceFile);
fileInput.files = transfer.files;
} catch (error) {
console.error("[BoomCast][Cleanup] Could not restore original selection:", error);
fileInput.value = "";
sourceFile = null;
}
}
browserToggle?.addEventListener("change", () => {
if (browserModeEnabled()) {
console.log("[BoomCast][BrowserBeta] Browser processing enabled by user.");
fileInput.accept = audioAccept + videoAccept;
selectFile(sourceFile || fileInput.files[0]);
} else {
console.log("[BoomCast][BrowserBeta] Switching to server processing.");
console.log("[BoomCast][Cleanup] Cancelling active browser processing job.");
selectionController?.abort();
browserProcessor?.setEnabled(false);
browserProcessor?.cleanup();
fileInput.accept = audioAccept;
restoreOriginalFile();
selectFile(sourceFile || fileInput.files[0]);
}
});
fileInput.addEventListener("change", () => { sourceFile = fileInput.files[0] || null; selectFile(sourceFile); });
["dragenter", "dragover"].forEach((name) => dropZone.addEventListener(name, (event) => {
event.preventDefault();
if (!busy) dropZone.classList.add("dragging");
}));
["dragleave", "drop"].forEach((name) => dropZone.addEventListener(name, (event) => {
event.preventDefault();
dropZone.classList.remove("dragging");
}));
dropZone.addEventListener("drop", (event) => {
if (busy || !event.dataTransfer.files.length) return;
fileInput.files = event.dataTransfer.files;
sourceFile = fileInput.files[0] || null;
selectFile(sourceFile);
});
function startUpload(file, metadata = null) {
// HTMX's later Pending action also reads the native file input. Replace a
// video with its extracted WAV so no subsequent form action can send video.
if (fileInput.files[0] !== file) {
try {
const transfer = new DataTransfer();
transfer.items.add(file);
fileInput.files = transfer.files;
if (fileInput.files[0] !== file) throw new Error("Prepared audio could not replace video in form");
} catch (error) {
console.error("[BoomCast][BrowserBeta] Could not secure native form upload:", error);
preparationFailed = true;
submit.disabled = true;
status.textContent = (t.secureVideoFailed || "Could not prepare this video for upload. Please choose an audio recording.");
return;
}
}
const formData = new FormData(form);
formData.set("audio", file);
if (metadata) formData.set("browser_processing_metadata", JSON.stringify(metadata));
const xhr = new XMLHttpRequest();
request = xhr;
uploadComplete = false;
results.replaceChildren();
setUploadState("uploading");
console.log("[boomcast-upload] upload started", { size: file.size, type: file.type });
xhr.open("POST", form.action);
xhr.upload.addEventListener("progress", (progressEvent) => {
if (uploadComplete) return;
if (!progressEvent.lengthComputable || progressEvent.total <= 0) return;
const percent = Math.min(100, Math.round(progressEvent.loaded / progressEvent.total * 100));
if (percent !== Number(circle.getAttribute("aria-valuenow"))) {
setUploadState("uploading", { progress: percent });
console.log("[boomcast-upload] upload progress", percent);
}
if (progressEvent.loaded >= progressEvent.total && !uploadComplete) {
finishUpload(xhr);
}
});
xhr.upload.addEventListener("load", () => {
finishUpload(xhr);
});
xhr.addEventListener("load", () => handleResponse(xhr));
xhr.addEventListener("error", () => fail(t.uploadFailed || "Upload failed. Check your connection and try again.", "Network error"));
xhr.addEventListener("timeout", () => fail(t.uploadFailed || "Upload failed. Check your connection and try again.", "Request timed out"));
xhr.addEventListener("abort", () => {
clearTimeout(processingTimer);
request = null;
setUploadState("cancelled");
console.log("[boomcast-upload] upload cancelled");
});
xhr.send(formData);
}
// Capture before HTMX's bubbling submit listener; the hx-* attributes remain a fallback.
form.addEventListener("submit", (event) => {
event.preventDefault();
event.stopImmediatePropagation();
if (busy || preparationPending || preparationFailed || gateBlocked) return;
if (!form.reportValidity()) return;
const file = fileInput.files[0];
if (!file) return;
if (!browserModeEnabled()) { startUpload(file); return; }
if (selectedResult) { startUpload(selectedResult.file, selectedResult.metadata); return; }
// Unknown audio types retain the existing server flow.
startUpload(file);
}, true);
gateChoose.addEventListener("click", () => fileInput.click());
gateOverride.addEventListener("click", () => {
if (!browserModeEnabled() || !gateBlocked || !selectedResult || busy || preparationPending) return;
console.warn("[BoomCast][Gate] User explicitly overrode local gate.");
console.log("[BoomCast][Gate] Submission will enter manual review.");
const metadata = { ...selectedResult.metadata, browser_override: true };
selectedResult.metadata = metadata;
gateBlocked = false;
gatePanel.hidden = true;
startUpload(selectedResult.file, metadata);
});
cancel.addEventListener("click", () => {
if (preparationPending) {
selectionController?.abort();
browserProcessor?.cancel();
selectionId += 1;
preparationPending = false;
preparationFailed = true;
submit.disabled = true;
cancel.hidden = true;
status.textContent = t.extractionCancelled || (t.preparationCancelled || "Preparation cancelled. Choose a recording to continue.");
} else request?.abort();
});
window.addEventListener("pageshow", (event) => {
if (event.persisted) {
request?.abort();
selectionController?.abort();
browserProcessor?.cancel();
selectionId += 1;
selectedResult = null;
sourceFile = null;
if (browserToggle) { browserToggle.checked = false; fileInput.accept = audioAccept; }
browserProcessor?.setEnabled(false);
preparationPending = false;
preparationFailed = false;
gateBlocked = false;
gatePanel.hidden = true;
submit.disabled = false;
fileInput.value = "";
results.replaceChildren();
showFile();
}
});
}
+79
View File
@@ -0,0 +1,79 @@
import { createBurstListener } from "./burst-listener.js";
const locationButton = document.querySelector('#capture-location');
locationButton?.addEventListener('click', () => {
const status = document.querySelector('#location-status');
if (!navigator.geolocation) { status.textContent = 'Location unavailable'; return; }
status.textContent = 'Finding location…';
navigator.geolocation.getCurrentPosition(({coords}) => {
document.querySelector('#id_latitude').value = coords.latitude;
document.querySelector('#id_longitude').value = coords.longitude;
status.textContent = 'Coarse area will be saved';
}, () => { status.textContent = 'Location unavailable; you can still report'; });
});
const directionButton = document.querySelector('#capture-direction');
let listening = false;
const onDirection = event => {
const heading = Number.isFinite(event.webkitCompassHeading) ? event.webkitCompassHeading : event.absolute && Number.isFinite(event.alpha) ? (360 - event.alpha) % 360 : null;
if (heading === null) return;
document.querySelector('#id_direction_degrees').value = heading;
document.querySelector('#id_direction_accuracy_degrees').value = Number.isFinite(event.webkitCompassAccuracy) && event.webkitCompassAccuracy >= 0 ? event.webkitCompassAccuracy : '';
document.querySelector('#id_direction_source').value = 'device';
document.querySelector('#direction-status').textContent = `${heading.toFixed(0)}° captured`;
};
directionButton?.addEventListener('click', async () => {
if (listening) { window.removeEventListener('deviceorientation', onDirection); listening = false; directionButton.textContent = 'Capture direction'; return; }
if (!('DeviceOrientationEvent' in window)) { document.querySelector('#direction-status').textContent = 'Compass unavailable'; return; }
if (typeof DeviceOrientationEvent.requestPermission === 'function' && await DeviceOrientationEvent.requestPermission() !== 'granted') return;
window.addEventListener('deviceorientation', onDirection); listening = true; directionButton.textContent = 'Stop capturing';
});
const mapElement = document.querySelector('#map');
if (mapElement && window.L) {
const map = L.map(mapElement).setView([52.1326, 5.2913], 7);
L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '&copy; OpenStreetMap contributors' }).addTo(map);
const layer = L.layerGroup().addTo(map);
const loadMap = async () => {
const query = new URLSearchParams(new FormData(document.querySelector('#map-filters')));
const response = await fetch(`/api/v1/map/?${query}`);
const { cells } = await response.json();
layer.clearLayers();
const bounds = [];
for (const cell of cells) {
L.polygon(cell.boundary, {color:'#f9b35b'}).addTo(layer).bindPopup(`${cell.events} reports · ${cell.occurrences} occurrences`);
for (const direction of cell.directions || []) {
const angle = direction.degrees * Math.PI / 180;
const length = 0.0015;
const from = cell.center;
const to = [from[0] + Math.cos(angle) * length, from[1] + Math.sin(angle) * length / Math.max(0.2, Math.cos(from[0] * Math.PI / 180))];
L.polyline([from, to], { color: '#f9b35b', weight: 3 }).addTo(layer).bindTooltip(`Direction ${direction.degrees.toFixed(0)}°${direction.accuracy_degrees === null ? '' : ` ±${direction.accuracy_degrees.toFixed(0)}°`}`);
}
bounds.push(...cell.boundary);
}
if (bounds.length) map.fitBounds(bounds);
};
document.querySelector('#map-filters').addEventListener('submit', event => { event.preventDefault(); loadMap(); });
loadMap();
}
const reportForm = document.querySelector('#manual-report-form');
if (reportForm) {
const listener = createBurstListener();
reportForm.addEventListener('submit', async event => {
if (!listener?.active || reportForm.dataset.burstReady) return;
event.preventDefault();
event.stopImmediatePropagation();
const clip = await listener.clipForSubmission();
if (clip) {
const transfer = new DataTransfer(); transfer.items.add(clip);
reportForm.querySelector('#id_audio_file').files = transfer.files;
}
reportForm.dataset.burstReady = '1';
reportForm.requestSubmit();
}, true);
}
document.body.addEventListener('htmx:beforeRequest', event => {
const link = event.detail.elt;
if (link?.matches?.('a[data-detail]') && window.innerWidth < 900) {
event.preventDefault();
window.location.href = link.href;
}
});
@@ -0,0 +1,17 @@
export class BrowserSubmissionGate {
static evaluate(predictions, policy) {
console.log("[BoomCast][Gate] Evaluating browser classification.");
const relevant = new Set((policy.whitelist || []).map((name) => name.toLowerCase()));
const speechNames = new Set((policy.privacy_sensitive_speech || []).map((name) => name.toLowerCase()));
const matchThreshold = Number(policy.thresholds?.relevance ?? 0.5);
const speechThreshold = Number(policy.thresholds?.speech ?? 0.5);
const matches = predictions.filter((item) => relevant.has(item.class.toLowerCase()) && item.score >= matchThreshold);
const speechDetected = predictions.some((item) => speechNames.has(item.class.toLowerCase()) && item.score >= speechThreshold);
console.log("[BoomCast][Gate] Relevant whitelist matches:", matches);
console.log("[BoomCast][Gate] Speech detected:", speechDetected);
const result = matches.length ? "whitelist_match" : speechDetected ? "speech_only" : "no_match";
console.log(`[BoomCast][Gate] Decision: ${result.toUpperCase()}`);
if (result !== "whitelist_match") console.log("[BoomCast][Gate] Automatic upload suppressed.");
return { result, speechDetected, matches };
}
}
@@ -0,0 +1,139 @@
const PREFIX = "[BoomCast][BrowserBeta]";
export function readBrowserProcessingConfig() {
const element = document.querySelector("#boomcast-browser-config");
if (!element) return { browserProcessingBeta: false };
try { return JSON.parse(element.textContent); }
catch (error) {
console.error(`${PREFIX} Configuration unavailable:`, error);
return { browserProcessingBeta: false };
}
}
export class BrowserSubmissionProcessor {
constructor(config = readBrowserProcessingConfig(), extractVideo = null, dependencies = {}) {
this.config = config;
this.extractVideo = extractVideo;
this.dependencies = dependencies;
this.userEnabled = false;
this.activeController = null;
}
isAvailable() { return this.config.browserProcessingBeta === true; }
isEnabled() { return this.isAvailable() && this.userEnabled; }
setEnabled(enabled) {
if (!enabled) this.cancel();
this.userEnabled = this.isAvailable() && enabled === true;
console.log(`${PREFIX} ${this.userEnabled ? "Browser processing enabled by user." : "Browser processing disabled by user; using existing server flow."}`);
}
cancel() {
this.activeController?.abort();
this.activeController = null;
}
async process(file, { signal, onState } = {}) {
this.cancel();
const controller = new AbortController();
this.activeController = controller;
const abort = () => controller.abort();
signal?.addEventListener("abort", abort, { once: true });
if (signal?.aborted) controller.abort();
try {
return await this.prepare(file, { signal: controller.signal, onState });
} finally {
signal?.removeEventListener("abort", abort);
if (this.activeController === controller) this.activeController = null;
}
}
canProcess(file) {
return this.isEnabled() && Boolean(file) && (BrowserSubmissionProcessor.isAudio(file) || BrowserSubmissionProcessor.isVideo(file));
}
static isAudio(file) {
return Boolean(file) && (file.type.startsWith("audio/") || (!file.type && /\.(aac|aif|aiff|flac|m4a|mp3|ogg|opus|wav|weba)$/i.test(file.name || "")));
}
static isVideo(file) {
return Boolean(file) && (file.type.startsWith("video/") || (!file.type && /\.(mp4|mov|m4v|webm|mkv|avi)$/i.test(file.name || "")));
}
async prepare(file, { signal, onState = () => {} } = {}) {
if (!this.canProcess(file)) return { file, metadata: null, gate: "unavailable" };
console.log(`${PREFIX} Initialising beta submission pipeline.`);
console.log(`${PREFIX} File selected:`, { type: file?.type || "", size: file?.size || 0 });
const video = BrowserSubmissionProcessor.isVideo(file);
const controller = new AbortController();
const abort = () => controller.abort();
signal?.addEventListener("abort", abort, { once: true });
const timeout = setTimeout(() => controller.abort(), 5000);
let policy;
try {
const response = await fetch(this.config.policyUrl, {
cache: "no-store", credentials: "same-origin", signal: controller.signal,
});
if (!response.ok) throw new Error(`Policy HTTP ${response.status}`);
policy = await response.json();
if (!policy.browser_processing_beta_enabled || policy.version !== this.config.policyVersion) {
console.log(`${PREFIX} Browser beta disabled or policy changed; using legacy submission flow.`);
return { file, metadata: null, gate: "unavailable" };
}
} catch (error) {
if (signal?.aborted) throw error;
console.error(`${PREFIX} Policy unavailable:`, error);
if (video) throw error;
return { file, metadata: null, gate: "unavailable" };
} finally {
clearTimeout(timeout);
signal?.removeEventListener("abort", abort);
}
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
let preparedFile = file;
if (video) {
const extract = this.extractVideo || (await import("./ffmpeg-video-extractor.js")).extractVideoAudio;
preparedFile = await extract(file, { signal, onState });
}
const metadata = {
browser_processing_used: video,
browser_processing_version: policy.version,
browser_gate_result: "unavailable",
browser_override: false,
};
try {
onState("checking");
const prepareAudio = this.dependencies.prepareAudio || (await import("./audio-preprocessor.js")).AudioPreprocessor.prepare;
let waveform = await prepareAudio(preparedFile, { signal });
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
try {
const classify = this.dependencies.classify || (await import("./browser-yamnet-classifier.js")).BrowserYamnetClassifier.classify;
const predictions = await classify(waveform, {
modelUrl: policy.model_url, classMapUrl: policy.class_map_url, signal,
});
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
const evaluate = this.dependencies.evaluate || (await import("./browser-submission-gate.js")).BrowserSubmissionGate.evaluate;
const decision = evaluate(predictions, policy);
metadata.browser_processing_used = true;
metadata.browser_gate_result = decision.result;
metadata.browser_speech_detected = decision.speechDetected;
return { file: preparedFile, metadata, gate: decision.result, predictions: predictions.slice(0, 5) };
} finally {
waveform = null;
console.log("[BoomCast][Cleanup] Releasing waveform buffers.");
}
} catch (error) {
if (signal?.aborted) throw error;
console.error("[BoomCast][YAMNet] Local classification unavailable:", error);
console.log("[BoomCast][Gate] Falling back to server classification.");
metadata.browser_gate_result = "unavailable";
return { file: preparedFile, metadata, gate: "unavailable" };
}
}
cleanup() {
this.cancel();
console.log("[BoomCast][Cleanup] Browser beta resources released.");
}
}
@@ -0,0 +1,70 @@
const PREFIX = "[BoomCast][YAMNet]";
export class BrowserYamnetClassifier {
static async classify(waveform, { modelUrl, classMapUrl, signal, loadTensorFlow } = {}) {
let tf;
let model;
let input;
let output;
const started = performance.now();
try {
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
console.log(`${PREFIX} Lazy-loading TensorFlow.js.`);
tf = loadTensorFlow ? await loadTensorFlow() : await import("@tensorflow/tfjs");
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
console.log(`${PREFIX} TensorFlow.js loaded.`);
await tf.ready();
console.log(`${PREFIX} Backend:`, tf.getBackend());
console.log(`${PREFIX} Loading model.`);
const [loaded, mappingResponse] = await Promise.all([
tf.loadGraphModel(modelUrl),
fetch(classMapUrl, { cache: "force-cache", signal }),
]);
model = loaded;
if (!mappingResponse.ok) throw new Error("YAMNet class map unavailable");
const classMap = await mappingResponse.json();
if (!Array.isArray(classMap) || classMap.length !== 521) throw new Error("Invalid YAMNet class map");
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
console.log(`${PREFIX} Model ready.`);
// YAMNet needs at least one 0.96 s patch, including STFT padding.
const samples = waveform.length < 15600 ? Float32Array.from({ length: 15600 }, (_, i) => waveform[i] || 0) : waveform;
input = tf.tensor1d(samples, "float32");
console.log(`${PREFIX} Starting inference.`);
const result = await model.executeAsync(input);
output = Array.isArray(result) ? result : [result];
const scores = output.find((tensor) => tensor.shape.length === 2 && tensor.shape[1] === classMap.length);
if (!scores) throw new Error("YAMNet score output unavailable");
const values = await scores.data();
if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
const frames = scores.shape[0];
const predictions = classMap.map((name, index) => {
let score = -1;
let frame = 0;
for (let row = 0; row < frames; row += 1) {
const value = values[row * classMap.length + index];
if (value > score) { score = value; frame = row; }
}
return { class: name, score, frame, timeSeconds: Number((frame * 0.48).toFixed(2)) };
});
predictions.sort((a, b) => b.score - a.score);
console.log(`${PREFIX} Inference completed in`, Math.round(performance.now() - started), "ms.");
console.groupCollapsed(`${PREFIX} Top local predictions`);
console.table(predictions.slice(0, 10));
console.groupEnd();
return predictions;
} catch (error) {
console.error(`${PREFIX} Local inference failed:`, error);
throw error;
} finally {
if (tf) console.log(`${PREFIX} TensorFlow memory before cleanup:`, tf.memory());
console.log("[BoomCast][Cleanup] Disposing YAMNet tensors.");
input?.dispose();
output?.forEach((tensor) => tensor?.dispose());
console.log("[BoomCast][Cleanup] Disposing browser YAMNet model.");
model?.dispose();
console.log("[BoomCast][Cleanup] Releasing waveform buffers.");
if (tf) console.log(`${PREFIX} TensorFlow memory after cleanup:`, tf.memory());
console.log("[BoomCast][Cleanup] Browser classification cleanup complete.");
}
}
}
@@ -0,0 +1,83 @@
class BurstListenerProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.samples = new Float32Array(Math.ceil(sampleRate * 10));
this.position = 0;
this.count = 0;
this.interval = 0;
this.energy = 0;
this.peak = 0;
this.baseline = 0.01;
this.lastTrigger = -sampleRate * 10;
this.postRoll = 0;
this.eventPosition = 0;
this.eventCount = 0;
this.frame = 0;
this.mode = "listening";
this.port.onmessage = ({ data }) => {
if (data === "snapshot") this.sendClip(this.count);
if (data === "reset") this.reset();
};
}
reset() {
this.samples.fill(0);
this.position = 0;
this.count = 0;
this.interval = 0;
this.energy = 0;
this.peak = 0;
this.baseline = 0.01;
this.lastTrigger = this.frame;
this.postRoll = 0;
this.mode = "listening";
}
sendClip(length) {
const clip = new Float32Array(length);
let start = (this.position - length + this.samples.length) % this.samples.length;
for (let i = 0; i < length; i++) clip[i] = this.samples[(start + i) % this.samples.length];
this.port.postMessage({ type: "clip", samples: clip, sampleRate }, [clip.buffer]);
}
process(inputs) {
const channel = inputs[0]?.[0];
if (!channel || this.mode === "captured") return true;
for (let i = 0; i < channel.length; i++) {
const value = channel[i];
this.samples[this.position] = value;
this.position = (this.position + 1) % this.samples.length;
this.count = Math.min(this.count + 1, this.samples.length);
this.energy += value * value;
this.peak = Math.max(this.peak, Math.abs(value));
this.interval++;
this.frame++;
if (this.mode === "tail") {
if (--this.postRoll === 0) {
this.mode = "captured";
this.sendClip(Math.min(this.count, Math.round(sampleRate * 10)));
break;
}
}
if (this.interval >= Math.round(sampleRate / 30)) {
const rms = Math.sqrt(this.energy / this.interval);
this.port.postMessage({ type: "level", value: Math.max(rms, this.peak * 0.5) });
if (this.mode === "listening" && this.frame > sampleRate && this.frame - this.lastTrigger > sampleRate * 3
&& rms > Math.max(0.075, this.baseline * 5) && this.peak > 0.16) {
this.mode = "tail";
this.postRoll = Math.round(sampleRate * 2);
this.lastTrigger = this.frame;
this.port.postMessage({ type: "trigger" });
} else if (this.mode === "listening") {
this.baseline = this.baseline * 0.98 + Math.min(rms, this.baseline * 2) * 0.02;
}
this.interval = 0;
this.energy = 0;
this.peak = 0;
}
}
return true;
}
}
registerProcessor("burst-listener", BurstListenerProcessor);
+157
View File
@@ -0,0 +1,157 @@
const form = document.querySelector("#manual-report-form");
export function createBurstListener() {
if (!form) return null;
const start = document.querySelector("#burst-start");
const panel = document.querySelector("#burst-panel");
const heading = document.querySelector("#burst-heading");
const detail = document.querySelector("#burst-detail");
const canvas = document.querySelector("#burst-waveform");
const preview = document.querySelector("#burst-preview");
const resume = document.querySelector("#burst-resume");
const discard = document.querySelector("#burst-discard");
const stop = document.querySelector("#burst-stop");
const error = document.querySelector("#burst-error");
const levels = new Float32Array(300);
let levelPosition = 0;
let state = "off";
let stream, context, source, node, silentOutput, previewUrl, captured, pendingSnapshot;
function draw() {
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#ffbd62";
const width = canvas.width / levels.length;
const scale = Math.max(0.003, ...levels);
for (let i = 0; i < levels.length; i++) {
const value = levels[(levelPosition + i) % levels.length];
const height = Math.max(2, Math.min(canvas.height, (value / scale) * canvas.height * 0.8));
ctx.fillRect(i * width, (canvas.height - height) / 2, Math.max(1, width - 1), height);
}
}
function clearClip() {
captured = null;
preview.pause();
preview.removeAttribute("src");
preview.load();
preview.hidden = true;
if (previewUrl) URL.revokeObjectURL(previewUrl);
previewUrl = null;
}
function setState(next) {
state = next;
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." : "";
}
function wav(samples, rate) {
const bytes = new ArrayBuffer(44 + samples.length * 2);
const view = new DataView(bytes);
const write = (offset, value) => { for (let i = 0; i < value.length; i++) view.setUint8(offset + i, value.charCodeAt(i)); };
write(0, "RIFF"); view.setUint32(4, bytes.byteLength - 8, true);
write(8, "WAVEfmt "); view.setUint32(16, 16, true);
view.setUint16(20, 1, true); view.setUint16(22, 1, true);
view.setUint32(24, rate, true); view.setUint32(28, rate * 2, true);
view.setUint16(32, 2, true); view.setUint16(34, 16, true);
write(36, "data"); view.setUint32(40, samples.length * 2, true);
for (let i = 0; i < samples.length; i++) {
const sample = Math.max(-1, Math.min(1, samples[i]));
view.setInt16(44 + i * 2, sample < 0 ? sample * 32768 : sample * 32767, true);
}
return new Blob([bytes], { type: "audio/wav" });
}
function filename() {
return `sound-signal-manual-${new Date().toISOString().replace(/[-:]/g, "").slice(0, 15)}.wav`;
}
async function begin() {
error.hidden = true;
start.disabled = true;
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 });
context = new AudioContext();
await context.audioWorklet.addModule(new URL("./burst-listener-worklet.js", import.meta.url));
source = context.createMediaStreamSource(stream);
node = new AudioWorkletNode(context, "burst-listener");
silentOutput = context.createGain();
silentOutput.gain.value = 0;
node.port.onmessage = ({ data }) => {
if (data.type === "level" && (state === "listening" || state === "tail")) {
levels[levelPosition] = data.value;
levelPosition = (levelPosition + 1) % levels.length;
draw();
} else if (data.type === "trigger" && state === "listening") {
setState("tail");
} else if (data.type === "clip") {
const file = new File([wav(data.samples, data.sampleRate)], filename(), { type: "audio/wav" });
if (pendingSnapshot) {
pendingSnapshot(file);
pendingSnapshot = null;
} else if (state === "tail") {
clearClip();
captured = file;
previewUrl = URL.createObjectURL(file);
preview.src = previewUrl;
preview.hidden = false;
setState("captured");
}
}
};
source.connect(node);
node.connect(silentOutput).connect(context.destination);
await context.resume();
levels.fill(0); levelPosition = 0; draw();
setState("listening");
} catch (cause) {
await end();
error.textContent = cause.name === "NotAllowedError" ? "Microphone permission was denied. Manual reporting is still available." : (cause.message || "Microphone capture failed.");
error.hidden = false;
} finally {
start.disabled = false;
}
}
async function end() {
if (pendingSnapshot) { pendingSnapshot(null); pendingSnapshot = null; }
clearClip();
node?.disconnect(); source?.disconnect(); silentOutput?.disconnect();
stream?.getTracks().forEach((track) => track.stop());
await context?.close();
stream = context = source = node = silentOutput = null;
levels.fill(0); levelPosition = 0;
setState("off");
}
function reset() {
clearClip();
levels.fill(0); levelPosition = 0; draw();
node?.port.postMessage("reset");
if (node) setState("listening");
}
start.addEventListener("click", begin);
stop.addEventListener("click", end);
discard.addEventListener("click", reset);
resume.addEventListener("click", reset);
window.addEventListener("pagehide", end);
document.addEventListener("visibilitychange", () => { if (document.hidden) end(); });
return {
get active() { return state !== "off"; },
async clipForSubmission() {
if (captured) return captured;
if (state === "off" || !node) return null;
return new Promise((resolve) => {
pendingSnapshot = resolve;
node.port.postMessage("snapshot");
});
},
submissionSucceeded: reset,
};
}
+101
View File
@@ -0,0 +1,101 @@
const t = window.BOOMCAST_I18N || {};
const mapElement = document.getElementById("event-map");
const h3Resolution = mapElement.dataset.h3Resolution;
const map = L.map(mapElement, { zoomControl: false, scrollWheelZoom: false }).setView([52.1326, 5.2913], 7);
L.control.zoom({ position: "bottomleft" }).addTo(map);
const compassControl = L.control({ position: "topright" });
compassControl.onAdd = () => {
const compass = L.DomUtil.create("div", "map-compass");
compass.setAttribute("role", "img");
compass.setAttribute("aria-label", (t.mapCompass || "Map compass: north is up"));
compass.innerHTML = "<span class=\"compass-n\">N</span><span class=\"compass-e\">E</span><span class=\"compass-s\">S</span><span class=\"compass-w\">W</span><span class=\"compass-needle\">↑</span>";
L.DomEvent.disableClickPropagation(compass);
return compass;
};
compassControl.addTo(map);
L.tileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png", {
maxZoom: 18,
attribution: "&copy; OpenStreetMap contributors",
}).addTo(map);
const h3Cells = JSON.parse(document.getElementById("h3-cells-data").textContent);
const reports = JSON.parse(document.getElementById("map-events-data").textContent);
const bounds = L.latLngBounds([]);
h3Cells.forEach((cell) => {
const polygon = L.polygon(cell.boundary, {
color: "#f59e0b", weight: 2, fillColor: "#f59e0b", fillOpacity: 0.25,
}).addTo(map);
polygon.bindPopup(
"<span class=\"popup-title\">H3 " + cell.cell + "</span>" +
"<span class=\"popup-meta\">" + cell.reports + " " + (cell.reports === 1 ? (t.report || "report") : (t.reports || "reports")) + " · " + cell.occurrences +
" " + (cell.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) + " · " + (t.resolution || "resolution") + " " + h3Resolution + "</span>"
);
bounds.extend(L.latLngBounds(cell.boundary));
});
function cardinalDirection(degrees) {
const directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
return directions[Math.floor(((degrees + 22.5) % 360) / 45)];
}
function destinationPoint(origin, bearingDegrees, distanceMetres) {
const earthRadius = 6378137;
const bearing = bearingDegrees * Math.PI / 180;
const latitude = origin[0] * Math.PI / 180;
const longitude = origin[1] * Math.PI / 180;
const angularDistance = distanceMetres / earthRadius;
const targetLatitude = Math.asin(
Math.sin(latitude) * Math.cos(angularDistance) +
Math.cos(latitude) * Math.sin(angularDistance) * Math.cos(bearing)
);
const targetLongitude = longitude + Math.atan2(
Math.sin(bearing) * Math.sin(angularDistance) * Math.cos(latitude),
Math.cos(angularDistance) - Math.sin(latitude) * Math.sin(targetLatitude)
);
return [targetLatitude * 180 / Math.PI, targetLongitude * 180 / Math.PI];
}
const reportIcon = L.divIcon({
className: "", html: "<div class=\"report-icon\">✦</div>", iconSize: [37, 37], iconAnchor: [19, 19],
});
reports.forEach((report) => {
const visualStatus = report.visually_confirmed ? (t.visuallyConfirmed || "Visually confirmed") : (t.notVisuallyConfirmed || "Not visually confirmed");
let detail = report.occurrences + " " + (report.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) +
" · " + visualStatus + "<br>" + (t.reported || "Reported") + " " + report.reported_on;
if (report.direction_degrees !== null) {
detail += "<br>" + (t.compassDirection || "Compass direction") + " " + Math.round(report.direction_degrees) + "° (" + cardinalDirection(report.direction_degrees) + ")";
if (report.direction_accuracy_degrees !== null) {
detail += " (±" + Math.round(report.direction_accuracy_degrees) + "°)";
}
}
L.marker(report.center, { icon: reportIcon }).addTo(map).bindPopup(
"<span class=\"popup-title\">" + (t.manualReport || "Manual report") + " · H3 " + report.cell + "</span>" +
"<span class=\"popup-meta\">" + detail + "</span>"
);
if (report.direction_degrees !== null) {
const arrowEnd = destinationPoint(report.center, report.direction_degrees, 900);
L.polyline([report.center, arrowEnd], { color: "#fff7e6", weight: 9, opacity: 0.8 }).addTo(map);
L.polyline([report.center, arrowEnd], { color: "#6d45a0", weight: 5, opacity: 1 }).addTo(map);
const arrowIcon = L.divIcon({
className: "",
html: "<div class=\"direction-marker\"><span style=\"transform:rotate(" + report.direction_degrees + "deg)\">↑</span></div>",
iconSize: [56, 56], iconAnchor: [28, 28],
});
L.marker(arrowEnd, { icon: arrowIcon, interactive: false }).addTo(map);
}
});
if (bounds.isValid()) {
map.fitBounds(bounds.pad(0.18));
}
const range = document.getElementById("range");
if (range) {
document.querySelectorAll("#from-date, #to-date").forEach((input) => {
input.addEventListener("change", () => { range.value = "custom"; });
});
}
@@ -0,0 +1,82 @@
const PREFIX = "[BoomCast][FFmpeg]";
export class VideoExtractionError extends Error {
constructor(code, cause) {
super(code, { cause });
this.name = "VideoExtractionError";
this.code = code;
}
}
export async function extractVideoAudio(file, { signal, onState = () => {}, createFFmpeg } = {}) {
let ffmpeg;
let inputWritten = false;
let outputWritten = false;
let stage = "module_load_failed";
const started = performance.now();
const inputName = "input";
const outputName = "audio.wav";
const abort = () => ffmpeg?.terminate();
signal?.addEventListener("abort", abort, { once: true });
console.log(`${PREFIX} Video input detected.`, { mimeType: file.type, sizeBytes: file.size });
try {
if (signal?.aborted) throw new VideoExtractionError("cancelled");
onState("loading_ffmpeg");
console.log(`${PREFIX} Starting lazy import.`);
const factory = createFFmpeg || (async () => {
const [{ FFmpeg }, { default: coreURL }, { default: wasmURL }] = await Promise.all([
import("@ffmpeg/ffmpeg"),
import("@ffmpeg/core?url"),
import("@ffmpeg/core/wasm?url"),
]);
console.log(`${PREFIX} ffmpeg.wasm module imported.`);
return { ffmpeg: new FFmpeg(), coreURL, wasmURL };
});
const runtime = await factory();
ffmpeg = runtime.ffmpeg;
if (signal?.aborted) throw new VideoExtractionError("cancelled");
ffmpeg.on?.("log", ({ message }) => console.log(`${PREFIX}[core]`, message));
stage = "core_load_failed";
console.log(`${PREFIX} Loading FFmpeg core.`);
await ffmpeg.load({ coreURL: runtime.coreURL, wasmURL: runtime.wasmURL });
console.log(`${PREFIX} FFmpeg core ready.`);
if (signal?.aborted) throw new VideoExtractionError("cancelled");
onState("extracting_audio");
stage = "resource_failed";
console.log(`${PREFIX} Writing input to virtual filesystem.`);
// One input ArrayBuffer is unavoidable for the FFmpeg virtual filesystem.
inputWritten = true;
await ffmpeg.writeFile(inputName, new Uint8Array(await file.arrayBuffer()));
if (signal?.aborted) throw new VideoExtractionError("cancelled");
stage = "extraction_failed";
console.log(`${PREFIX} Starting audio extraction: mono / 16kHz WAV.`);
outputWritten = true;
const exitCode = await ffmpeg.exec(["-i", inputName, "-vn", "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", outputName]);
if (exitCode !== 0) throw new VideoExtractionError("invalid_media");
if (signal?.aborted) throw new VideoExtractionError("cancelled");
const data = await ffmpeg.readFile(outputName);
if (!data?.byteLength) throw new VideoExtractionError("invalid_media");
if (data.byteLength > 25 * 1024 * 1024) throw new VideoExtractionError("output_too_large");
const wav = new File([data], `${file.name.replace(/\.[^.]+$/, "") || "recording"}.wav`, { type: "audio/wav" });
console.log(`${PREFIX} Audio extraction completed.`, { outputSizeBytes: wav.size });
console.log(`${PREFIX} Extraction finished in ${Math.round(performance.now() - started)} ms.`);
return wav;
} catch (error) {
const code = signal?.aborted ? "cancelled" : error instanceof VideoExtractionError ? error.code
: error instanceof RangeError ? "resource_failed" : stage;
if (code === "invalid_media") console.warn(`${PREFIX} Unsupported or undecodable video.`);
console.error(`${PREFIX} Audio extraction failed:`, error);
throw new VideoExtractionError(code, error);
} finally {
console.log(`${PREFIX} Removing temporary files.`);
if (ffmpeg?.loaded) {
if (inputWritten) await ffmpeg.deleteFile(inputName).catch(() => {});
if (outputWritten) await ffmpeg.deleteFile(outputName).catch(() => {});
}
console.log(`${PREFIX} Terminating worker.`);
ffmpeg?.terminate();
ffmpeg = null;
signal?.removeEventListener("abort", abort);
console.log(`${PREFIX} Cleanup complete.`);
}
}
@@ -0,0 +1,16 @@
const form = document.querySelector('.upload-form');
const dropZone = document.querySelector('#drop-zone');
const fileInput = document.querySelector('#audio-file');
const fileName = document.querySelector('#file-name');
const status = document.querySelector('#upload-status');
const showFile = (file) => { fileName.textContent = file ? file.name : 'No file selected'; };
fileInput.addEventListener('change', () => showFile(fileInput.files[0]));
['dragenter', 'dragover'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.add('dragging'); }));
['dragleave', 'drop'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.remove('dragging'); }));
dropZone.addEventListener('drop', (event) => { const [file] = event.dataTransfer.files; if (!file) return; fileInput.files = event.dataTransfer.files; showFile(file); });
form.addEventListener('htmx:beforeRequest', () => { status.textContent = 'Analysing your recording…'; form.setAttribute('aria-busy', 'true'); });
form.addEventListener('htmx:afterRequest', () => { status.textContent = ''; form.removeAttribute('aria-busy'); });
form.addEventListener('htmx:responseError', () => { status.textContent = 'Analysis could not be completed.'; });
+171
View File
@@ -0,0 +1,171 @@
import { createBurstListener } from "./burst-listener.js";
const t = window.BOOMCAST_I18N || {};
const manualForm = document.querySelector("#manual-report-form");
const manualSubmit = document.querySelector("#manual-submit");
const manualStatus = document.querySelector("#manual-submission");
const latitude = document.querySelector("#manual-latitude");
const longitude = document.querySelector("#manual-longitude");
const directionDegrees = document.querySelector("#manual-direction-degrees");
const directionAccuracy = document.querySelector("#manual-direction-accuracy");
const captureDirectionButton = document.querySelector("#manual-capture-direction");
const directionStatus = document.querySelector("#manual-direction-status");
const directionPanel = document.querySelector("#manual-direction-panel");
const compass = document.querySelector("#manual-compass");
const compassRose = document.querySelector("#manual-compass-rose");
const compassHeading = document.querySelector("#manual-compass-heading");
const isMobileDevice = /Android|iPhone|iPad|iPod|IEMobile|Opera Mini/.test(navigator.userAgent)
|| (navigator.userAgent.includes("Macintosh") && navigator.maxTouchPoints > 1);
if (isMobileDevice) directionPanel.hidden = false;
let orientationListener;
let compassUnavailableTimeout;
let compassRotation = null;
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 displayDegrees = (value) => Number(value.toFixed(1)).toString();
const stopCompassReading = () => {
if (orientationListener) window.removeEventListener("deviceorientation", orientationListener);
window.clearTimeout(compassUnavailableTimeout);
orientationListener = null;
compassUnavailableTimeout = null;
compass.hidden = true;
compassRotation = null;
};
const updateCompass = (heading) => {
const targetRotation = -heading;
if (compassRotation === null) {
compassRotation = targetRotation;
compassRose.style.transition = "none";
compassRose.style.transform = `rotate(${compassRotation}deg)`;
// Restore the short rotation animation after the initial reading.
compassRose.offsetWidth;
compassRose.style.transition = "";
} else {
const change = ((targetRotation - compassRotation + 540) % 360) - 180;
compassRotation += change;
compassRose.style.transform = `rotate(${compassRotation}deg)`;
}
compassHeading.textContent = `${displayDegrees(heading)}° · ${cardinalDirection(heading)}`;
compass.setAttribute("aria-label", `${t.compassDirection || "Compass direction"} ${displayDegrees(heading)}° ${cardinalDirection(heading)}`);
compass.hidden = false;
};
const showCapturedDirection = (heading, accuracy) => {
const accuracyText = accuracy === null ? (t.accuracyUnavailable || "Accuracy unavailable") : (t.accuracy || "Accuracy") + ": ±" + displayDegrees(accuracy) + "°";
directionStatus.innerHTML = "<strong>" + displayDegrees(heading) + "° · " + cardinalDirection(heading) + "</strong><br>" + accuracyText;
captureDirectionButton.textContent = (t.stopCapture || "Stop direction capture");
};
const listenForCompassReading = () => {
stopCompassReading();
directionStatus.textContent = (t.pointPhone || "Point the top of your phone toward the sound — direction will update live.");
orientationListener = (event) => {
const isWebKitCompass = "webkitCompassHeading" in event;
const heading = isUsableNumber(event.webkitCompassHeading)
? event.webkitCompassHeading
: !isWebKitCompass && event.absolute && isUsableNumber(event.alpha)
? (360 - event.alpha) % 360
: null;
if (heading === null || heading < 0 || heading >= 360) return;
const accuracy = isUsableNumber(event.webkitCompassAccuracy) && event.webkitCompassAccuracy >= 0
? event.webkitCompassAccuracy
: null;
directionDegrees.value = heading;
directionAccuracy.value = accuracy === null ? "" : accuracy;
showCapturedDirection(heading, accuracy);
updateCompass(heading);
window.clearTimeout(compassUnavailableTimeout);
};
window.addEventListener("deviceorientation", orientationListener);
compassUnavailableTimeout = window.setTimeout(() => {
stopCompassReading();
captureDirectionButton.textContent = (t.captureDirection || "Capture direction");
directionStatus.textContent = (t.compassUnavailable || "Compass unavailable on this device.");
}, 15000);
};
const captureDirection = async () => {
if (orientationListener) {
stopCompassReading();
captureDirectionButton.textContent = (t.captureAgain || "Capture again");
return;
}
if (!window.isSecureContext) {
directionStatus.textContent = (t.secureCompass || "Compass capture requires a secure HTTPS connection.");
return;
}
if (typeof window.DeviceOrientationEvent === "undefined") {
directionStatus.textContent = (t.compassUnavailable || "Compass unavailable on this device.");
return;
}
if (typeof DeviceOrientationEvent.requestPermission === "function") {
directionStatus.textContent = (t.compassPermission || "Requesting compass permission…");
try {
if (await DeviceOrientationEvent.requestPermission(true) !== "granted") {
directionStatus.textContent = (t.compassDenied || "Compass permission denied.");
return;
}
} catch (error) {
directionStatus.textContent = (t.compassDenied || "Compass permission denied.");
return;
}
}
listenForCompassReading();
};
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,
target: "#manual-submission",
swap: "outerHTML",
});
} else {
manualForm.submit();
}
};
captureDirectionButton.addEventListener("click", captureDirection);
manualSubmit.addEventListener("click", () => {
if (!navigator.geolocation) {
submitManualReport();
return;
}
manualStatus.textContent = (t.requestingLocation || "Requesting your optional location…");
navigator.geolocation.getCurrentPosition(
(position) => {
latitude.value = position.coords.latitude;
longitude.value = position.coords.longitude;
submitManualReport();
},
() => submitManualReport(),
{ enableHighAccuracy: false, maximumAge: 300000, timeout: 10000 },
);
});
document.body.addEventListener("htmx:afterRequest", (event) => {
if (event.detail.elt === manualForm) manualSubmit.disabled = false;
});
+65
View File
@@ -0,0 +1,65 @@
const storageKey = "sound-signal-theme";
const themes = new Set(["dark", "light"]);
function savedTheme() {
try {
const value = window.localStorage.getItem(storageKey);
return themes.has(value) ? value : "dark";
} catch {
return "dark";
}
}
function applyTheme(theme, button) {
document.documentElement.dataset.theme = theme;
if (!button) return;
const nextTheme = theme === "dark" ? "light" : "dark";
const t = window.BOOMCAST_I18N || {};
button.textContent = nextTheme === "light" ? "☀ " + (t.lightMode || "Light mode") : "☾ " + (t.darkMode || "Dark mode");
button.setAttribute("aria-label", nextTheme === "light" ? (t.switchToLight || "Switch to light mode") : (t.switchToDark || "Switch to dark mode"));
button.setAttribute("aria-pressed", String(theme === "light"));
}
function installThemeToggle() {
const button = document.querySelector(".theme-toggle") ?? document.createElement("button");
if (!button.isConnected) {
button.className = "theme-toggle";
button.type = "button";
document.body.append(button);
}
applyTheme(savedTheme(), button);
button.addEventListener("click", () => {
const nextTheme = document.documentElement.dataset.theme === "dark" ? "light" : "dark";
try { window.localStorage.setItem(storageKey, nextTheme); } catch {}
applyTheme(nextTheme, button);
});
}
function installMobileMenu() {
const button = document.querySelector(".fireworks-menu-toggle");
if (!button) return;
const close = () => {
button.setAttribute("aria-expanded", "false");
button.setAttribute("aria-label", button.dataset.openLabel);
};
button.addEventListener("click", () => {
const expanded = button.getAttribute("aria-expanded") !== "true";
button.setAttribute("aria-expanded", String(expanded));
button.setAttribute("aria-label", expanded ? button.dataset.closeLabel : button.dataset.openLabel);
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape" && button.getAttribute("aria-expanded") === "true") {
close();
button.focus();
}
});
window.matchMedia("(min-width: 44.001rem)").addEventListener("change", close);
}
applyTheme(savedTheme());
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => { installThemeToggle(); installMobileMenu(); }, { once: true });
} else {
installThemeToggle();
installMobileMenu();
}
+10
View File
@@ -0,0 +1,10 @@
document.querySelector("#ntfy-url")?.addEventListener("input", () => {
document.querySelector("#ntfy-test-result")?.replaceChildren();
});
document.addEventListener("click", async (event) => {
const button = event.target.closest("[data-copy-sensor-token]");
if (!button) return;
const token = document.querySelector("#sensor-token")?.textContent;
if (token) await navigator.clipboard.writeText(token);
});
@@ -0,0 +1,9 @@
.burst-listener { width:min(100%,36rem); margin-top:1rem; }
.burst-listener__button,.burst-listener__actions button { min-height:2.75rem; padding:.65rem 1rem; border:1px solid #ffd18c; border-radius:.7rem; color:#fff2df; font:inherit; font-weight:750; background:#39243a; cursor:pointer; }
.burst-listener__panel { margin-top:.8rem; padding:1rem; border:1px solid #aa7294; border-radius:.8rem; background:#1b1730; color:#fff2df; }
.burst-listener__panel canvas { display:block; width:100%; height:90px; margin:.8rem 0; background:#171225; border-radius:.4rem; }
.burst-listener__panel p { margin:.5rem 0 1rem; color:#efc9dc; }
.burst-listener__panel audio { width:100%; margin-bottom:1rem; }
.burst-listener__actions { display:flex; flex-wrap:wrap; gap:.5rem; }
.burst-listener [hidden] { display:none !important; }
.burst-listener [role="alert"] { color:#ffd18c; }
@@ -0,0 +1,104 @@
.fireworks-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 3.5rem;
}
.fireworks-brand {
display: flex;
align-items: center;
gap: .7rem;
color: var(--ink, var(--i, #eef3ff));
font-size: .9rem;
font-weight: 800;
letter-spacing: .1em;
text-decoration: none;
text-transform: uppercase;
}
.fireworks-header .brand-mark {
display: grid;
width: 2.25rem;
aspect-ratio: 1;
place-items: center;
border-radius: .75rem;
color: #141022;
background: linear-gradient(135deg, #fcd34d, #fb7185);
box-shadow: 0 .5rem 1.5rem #fb718550;
}
.fireworks-header__controls { display: flex; align-items: center; gap: .65rem; }
.fireworks-menu-toggle { display: none; }
.fireworks-nav {
display: flex;
gap: .3rem;
padding: .25rem;
border: 1px solid var(--line, var(--l, #2b3d68));
border-radius: .75rem;
background: #111a31d9;
box-shadow: 0 .5rem 1.5rem #03071440;
}
.fireworks-nav a,
.fireworks-nav button {
padding: .5rem .75rem;
border-radius: .5rem;
color: var(--muted, var(--m, #aab9d8));
font-size: .86rem;
font-weight: 750;
text-decoration: none;
}
.fireworks-nav form { display: flex; margin: 0; }
.fireworks-nav button { border: 0; background: transparent; font: inherit; cursor: pointer; }
.fireworks-nav a:hover,
.fireworks-nav button:hover { color: var(--ink, var(--i, #eef3ff)); background: #20345f; }
.fireworks-nav a[aria-current="page"] { color: var(--ink, var(--i, #eef3ff)); background: #2a3b67; }
.theme-toggle--inline {
position: static;
flex: 0 0 auto;
min-height: 2.35rem;
padding: .45rem .7rem;
white-space: nowrap;
}
:root[data-theme="light"] .fireworks-nav {
border-color: #cbd9ed;
background: #edf4ff;
box-shadow: 0 .45rem 1.25rem rgba(34, 68, 117, .12);
}
:root[data-theme="light"] .fireworks-nav a,
:root[data-theme="light"] .fireworks-nav button { color: #47617f; }
:root[data-theme="light"] .fireworks-nav a:hover,
:root[data-theme="light"] .fireworks-nav button:hover { color: #234a7b; background: #dceaff; }
:root[data-theme="light"] .fireworks-nav a[aria-current="page"] {
color: #173d6a;
background: #cfe3ff;
box-shadow: inset 0 0 0 1px #9cc0ed;
}
@media (max-width: 44rem) {
.fireworks-header { flex-wrap: wrap; justify-content: flex-start; margin-bottom: 2.5rem; }
.fireworks-menu-toggle {
display: flex;
flex: 0 0 auto;
flex-direction: column;
align-items: center;
justify-content: center;
gap: .3rem;
width: 2.75rem;
height: 2.75rem;
padding: 0;
border: 1px solid var(--theme-line);
border-radius: .7rem;
color: var(--theme-ink);
background: var(--theme-surface-raised);
cursor: pointer;
}
.fireworks-menu-toggle span { width: 1.2rem; height: 2px; border-radius: 2px; background: currentColor; }
.fireworks-menu-toggle:focus-visible { outline: 3px solid #8abaff; outline-offset: 3px; }
.fireworks-header__controls { display: none; flex-basis: 100%; width: 100%; flex-direction: column; align-items: stretch; }
.fireworks-menu-toggle[aria-expanded="true"] ~ .fireworks-header__controls { display: flex; }
.fireworks-nav { flex-direction: column; }
.fireworks-nav a,
.fireworks-nav button { padding: .75rem; }
.fireworks-nav form,
.fireworks-nav button { width: 100%; }
.fireworks-nav button { text-align: left; }
.theme-toggle--inline { width: 100%; }
}
@@ -0,0 +1,55 @@
.manual-compass {
display: grid;
justify-items: center;
width: 7rem;
margin: .6rem 0 0 auto;
color: #fff3d7;
font-size: .78rem;
font-weight: 850;
font-variant-numeric: tabular-nums;
}
.manual-compass[hidden] { display: none; }
.manual-compass__dial {
position: relative;
width: 5.75rem;
aspect-ratio: 1;
border: 2px solid #f2d7a8;
border-radius: 50%;
background: radial-gradient(circle, #342441 0 28%, #211a32 75%);
box-shadow: 0 .35rem 1rem #09061566, inset 0 0 0 .25rem #ffffff12;
}
.manual-compass__rose { position: absolute; inset: 0; transition: transform 120ms ease-out; }
.manual-compass__rose span { position: absolute; line-height: 1; }
.manual-compass__north { top: .38rem; left: 50%; color: #ff9e78; transform: translateX(-50%); }
.manual-compass__east { right: .47rem; top: 50%; transform: translateY(-50%); }
.manual-compass__south { bottom: .38rem; left: 50%; transform: translateX(-50%); }
.manual-compass__west { left: .47rem; top: 50%; transform: translateY(-50%); }
.manual-compass__pointer {
position: absolute;
top: -.55rem;
left: 50%;
width: 0;
height: 0;
border-right: .37rem solid transparent;
border-bottom: .65rem solid #ffbd62;
border-left: .37rem solid transparent;
transform: translateX(-50%);
filter: drop-shadow(0 .1rem .15rem #160d1b);
}
.manual-compass__center {
position: absolute;
top: 50%;
left: 50%;
width: .5rem;
aspect-ratio: 1;
border-radius: 50%;
background: #ffbd62;
transform: translate(-50%, -50%);
}
.manual-compass__heading { margin-top: .5rem; white-space: nowrap; }
:root[data-theme="light"] .manual-compass { color: #43243d; }
:root[data-theme="light"] .manual-compass__dial { border-color: #996a9b; background: radial-gradient(circle, #f8ebf8 0 28%, #e8d7e9 75%); }
:root[data-theme="light"] .manual-compass__east,
:root[data-theme="light"] .manual-compass__south,
:root[data-theme="light"] .manual-compass__west { color: #43243d; }
@media (prefers-reduced-motion: reduce) { .manual-compass__rose { transition: none; } }
@@ -0,0 +1 @@
.audio-preview{display:flex;align-items:center;gap:12px;margin:18px 0;padding:14px;border:1px solid #2b3d68;border-radius:10px;background:#14203a}.audio-play{display:inline-flex;align-items:center;gap:9px;border:0;border-radius:999px;padding:10px 15px!important;color:#121a34;font-weight:850;background:linear-gradient(135deg,#99c8ff,#c6adff);cursor:pointer}.audio-play__icon{display:grid;width:22px;height:22px;place-items:center;border-radius:50%;color:#fff;background:#172443}.audio-play.is-loading .audio-play__icon{color:transparent;border:2px solid #263a76;border-top-color:#fff;animation:audio-spin .7s linear infinite}.audio-status{color:#aab9d8;font-size:.85rem}@keyframes audio-spin{to{transform:rotate(360deg)}}
@@ -0,0 +1 @@
:root{--ink:#edf3ff;--muted:#aab9d8;--line:#2b3d68;--danger:#ff9ea8}*{box-sizing:border-box}body{min-width:320px;min-height:100vh;display:grid;place-items:center;margin:0;padding:1.5rem;color:var(--ink);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:radial-gradient(circle at 8% 0,#263a76,transparent 31rem),radial-gradient(circle at 96% 100%,#512363,transparent 29rem),#090e1d}.card{width:min(100%,27rem);position:relative;overflow:hidden;padding:clamp(2rem,7vw,3.5rem);border:1px solid var(--line);border-radius:1.4rem;background:linear-gradient(145deg,#172443e8,#10182ddd);box-shadow:0 1.75rem 5rem #01030c99;backdrop-filter:blur(16px)}.card:before{content:"";width:12rem;height:12rem;position:absolute;top:-7rem;right:-5rem;border-radius:50%;background:#78a8ef45}.brand{display:flex;align-items:center;gap:.65rem;margin-bottom:2.7rem;font-size:.78rem;font-weight:900;letter-spacing:.14em;text-transform:uppercase}.mark{display:grid;width:2.25rem;aspect-ratio:1;place-items:center;border-radius:.72rem;color:#17132b;font-size:1.1rem;background:linear-gradient(135deg,#fcd34d,#fb7185);box-shadow:0 .5rem 1.5rem #fb718550}.eyebrow{margin:0;color:#bcd4ff;font-size:.75rem;font-weight:800;letter-spacing:.14em;text-transform:uppercase}h1{margin:.55rem 0 .75rem;font-size:clamp(2rem,7vw,3.2rem);line-height:1;letter-spacing:-.06em}.intro{margin:0 0 1.8rem;color:var(--muted);line-height:1.55}.error{margin:0 0 1rem;padding:.75rem;border:1px solid #994957;border-radius:.7rem;color:#ffd6da;font-size:.88rem;background:#551d2b70}label{display:block;margin:1rem 0 .4rem;color:#c7d6f4;font-size:.82rem;font-weight:800}input{width:100%;min-height:2.85rem;padding:.7rem .8rem;border:1px solid #3d5487;border-radius:.7rem;color:var(--ink);font:inherit;background:#0a1123}input:focus{outline:2px solid #9bc8ff;outline-offset:2px}button{width:100%;min-height:2.9rem;margin-top:1.5rem;border:1px solid #b3c9ff;border-radius:.75rem;color:#121a34;font:inherit;font-weight:850;background:linear-gradient(135deg,#99c8ff,#c6adff);box-shadow:0 .65rem 1.75rem #7058dd50;cursor:pointer;transition:transform .2s}button:hover{transform:translateY(-2px)}.foot{margin:1.5rem 0 0;color:#8498c1;font-size:.78rem;text-align:center}@media(prefers-reduced-motion:reduce){button{transition:none}}
+52
View File
@@ -0,0 +1,52 @@
:root {
--dashboard-ink: #edf3ff;
--dashboard-muted: #aab9d8;
--dashboard-line: #2b3d68;
--dashboard-surface: #111a31;
--dashboard-surface-raised: #172443;
}
body.dashboard-page {
display: block;
min-width: 320px;
min-height: 100vh;
margin: 0;
color: var(--dashboard-ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: radial-gradient(circle at 8% 0%, #263a76 0, transparent 31rem), radial-gradient(circle at 96% 100%, #512363 0, transparent 29rem), #090e1d;
}
.dashboard-shell { width: min(100% - 2.5rem, 70rem); margin: 0 auto; padding: clamp(2rem, 6vw, 5rem) 0; }
.dashboard-intro { max-width: 44rem; margin-bottom: 2rem; }
.dashboard-kicker { margin: 0 0 .8rem; color: #bfdbfe; font-size: .76rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.dashboard-intro h1 { max-width: 11ch; margin: 0; color: var(--dashboard-ink); font-size: clamp(2.8rem, 7vw, 5.5rem); line-height: .94; letter-spacing: -.065em; }
.dashboard-intro p:last-child { max-width: 42rem; margin: 1.25rem 0 0; color: var(--dashboard-muted); font-size: clamp(1rem, 2vw, 1.16rem); line-height: 1.65; }
.dashboard-section { margin-top: 2.25rem; }
.dashboard-section__header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.dashboard-section__header h2 { margin: .25rem 0 0; color: var(--dashboard-ink); font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.045em; }
.dashboard-section__header .dashboard-kicker { margin-bottom: .3rem; }
.dashboard-link { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .7rem 1rem; border: 1px solid #789ed7; border-radius: .7rem; color: #dceaff; font-size: .9rem; font-weight: 800; text-decoration: none; background: #1b2e52; transition: transform .2s ease, background .2s ease; }
.dashboard-link:hover { transform: translateY(-1px); background: #274574; }
.dashboard-report { position: relative; overflow: hidden; padding: clamp(1.35rem, 4vw, 2.4rem); border: 1px solid #b86c2a; border-radius: 1.35rem; background: linear-gradient(135deg, #4a2b16e8, #171225dd); box-shadow: 0 1.5rem 4rem #02061680; }
.dashboard-report::after { content: ""; position: absolute; width: 17rem; height: 17rem; right: -9rem; top: -10rem; border-radius: 50%; background: #ffb4541f; pointer-events: none; }
.dashboard-report > * { position: relative; }
.dashboard-report .eyebrow { margin: 0 0 .7rem; color: #ffd08a; font-size: .76rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.dashboard-report .eyebrow::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-right: .45rem; border-radius: 50%; background: #ffbd62; box-shadow: 0 0 0 .25rem #fbbf2430; }
.dashboard-report .manual-report__title { max-width: 14ch; margin: 0 0 .6rem; color: #fff6e7; font-size: clamp(2rem, 5vw, 3.4rem); line-height: .98; letter-spacing: -.06em; }
.dashboard-report .manual-report__intro { max-width: 42rem; margin: 0 0 1.35rem; color: #f3c8a3; line-height: 1.55; }
.dashboard-report .manual-report__label { display: block; margin-bottom: .5rem; color: #fff2df; font-weight: 800; }
.dashboard-report #manual-occurrences { width: min(100%, 36rem); min-height: 3.25rem; display: block; margin-bottom: 1rem; padding: .75rem .9rem; border: 1px solid #e2934a; border-radius: .75rem; color: #edf3ff; font: inherit; font-weight: 800; background: #151b31; }
.dashboard-report .manual-direction-panel { width: min(100%, 36rem); margin: 0 0 1rem; padding: 1rem; border: 1px solid #8d5bb5; border-radius: .75rem; background: #241b38; }
.dashboard-report .manual-direction-panel__heading { display: block; margin-bottom: .35rem; }.dashboard-report .manual-direction-panel__heading span { color: #c7b5eb; font-weight: 600; }.dashboard-report .manual-direction-panel__copy { margin: 0 0 .75rem; color: #d4c6ef; font-size: .88rem; line-height: 1.45; }.dashboard-report .manual-direction-panel__button { min-height: 2.75rem; padding: .65rem .9rem; border: 1px solid #c3a5eb; border-radius: .65rem; color: #211234; font: inherit; font-weight: 850; background: #d8c1fb; cursor: pointer; }.dashboard-report .manual-direction-panel__status { min-height: 1.4rem; margin-top: .7rem; color: #e5dcf7; font-size: .9rem; }
.dashboard-report .manual-report__submit { width: min(100%, 36rem); min-height: 4.5rem; border: 0; border-radius: 1rem; color: #281306; font: inherit; font-size: clamp(1.05rem, 2vw, 1.3rem); font-weight: 900; background: linear-gradient(135deg, #ffd18c, #ff8f5b); box-shadow: 0 .75rem 1.8rem #d664344d; cursor: pointer; }.dashboard-report .manual-report__submission { min-height: 1.5rem; margin-top: 1rem; color: #ffd18c; }
.dashboard-map .map { height: clamp(22rem, 48vh, 34rem); }.dashboard-map .map-header { background: #121d37; }.dashboard-map .legend { display: none; }
.dashboard-upload { padding: clamp(1rem, 3vw, 1.5rem); }
.dashboard-upload .drop-zone { min-height: 12rem; }
@media (max-width: 42rem) { .dashboard-shell { width: min(100% - 1.25rem, 70rem); }.dashboard-section__header { align-items: flex-start; flex-direction: column; }.dashboard-link { width: 100%; }.dashboard-map .map { height: 23rem; } }
:root[data-theme="light"] body.dashboard-page { --dashboard-ink: #172b50; --dashboard-muted: #596d88; --dashboard-line: #cbd9ed; --dashboard-surface: #fff; --dashboard-surface-raised: #f4f8ff; background: radial-gradient(circle at 8% 0%, #dbeaff 0, transparent 31rem), radial-gradient(circle at 96% 100%, #eee2ff 0, transparent 29rem), #f4f7fc; }
:root[data-theme="light"] .dashboard-intro h1, :root[data-theme="light"] .dashboard-section__header h2 { color: #172b50 !important; }
:root[data-theme="light"] .dashboard-kicker { color: #3f6fa9 !important; }
:root[data-theme="light"] .dashboard-link { border-color: #9fc0e9; color: #234a7b; background: #e6f0ff; }.dashboard-link:hover { background: #d8e8ff; }
:root[data-theme="light"] .dashboard-report { border-color: #eca851; background: linear-gradient(145deg, #fff8ef, #ffe0bb); box-shadow: 0 1.4rem 3.4rem rgba(116, 69, 25, .18); }
:root[data-theme="light"] .dashboard-report .eyebrow { color: #9f4d16 !important; }:root[data-theme="light"] .dashboard-report .manual-report__title { color: #4a2510 !important; }:root[data-theme="light"] .dashboard-report .manual-report__intro { color: #70411d !important; }:root[data-theme="light"] .dashboard-report .manual-report__label { color: #54311b; }:root[data-theme="light"] .dashboard-report #manual-occurrences { border-color: #dfaa68; color: #322014; background: #fffdfa; }:root[data-theme="light"] .dashboard-report .manual-direction-panel { border-color: #d9b4d8; background: #fff5fc; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__heading { color: #492846; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__heading span { color: #70466d; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__copy { color: #694b68; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__button { border-color: #b68bb5; color: #321a34; background: #ead2eb; }:root[data-theme="light"] .dashboard-report .manual-direction-panel__status { color: #6b4267; }:root[data-theme="light"] .dashboard-report .manual-report__submission { color: #87421b; }
:root[data-theme="light"] .dashboard-map .map-header { background: #f2f6fc !important; }
.dashboard-page .profile-circle { display: grid; width: 3rem; height: 3rem; position: fixed; top: 1.25rem; right: 1.25rem; place-items: center; border: 1px solid #d0c0ff; border-radius: 50%; z-index: 1201; color: #17132b; font-weight: 900; text-decoration: none; background: linear-gradient(135deg, #fcd34d, #c4a5fd); box-shadow: 0 .5rem 1.5rem #01030c66; }.dashboard-page .profile-circle:focus-visible { outline: 3px solid #a5c9ff80; outline-offset: 3px; }
+48
View File
@@ -0,0 +1,48 @@
:root{--i:#edf3ff;--m:#aab9d8;--l:#2b3d68}*{box-sizing:border-box}body{margin:0;min-height:100vh;padding:2rem;color:var(--i);font-family:system-ui;background:radial-gradient(circle at 8% 0,#263a76,transparent 31rem),#090e1d}.shell{width:min(100%,70rem);margin:auto}.top{display:flex;justify-content:space-between;gap:1rem;align-items:center;margin-bottom:3rem}.brand,a{color:inherit}.brand{text-decoration:none;font-weight:900;letter-spacing:.1em;text-transform:uppercase}.top a:not(.brand){padding:.6rem .8rem;border:1px solid var(--l);border-radius:.6rem;text-decoration:none}.eyebrow{color:#bcd4ff;font-size:.76rem;letter-spacing:.15em;text-transform:uppercase;font-weight:800}h1{font-size:clamp(2.5rem,6vw,4.5rem);letter-spacing:-.06em;margin:.4rem 0}.lede{color:var(--m);max-width:38rem;line-height:1.6}.grid{display:grid;grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:1rem;margin-top:2rem}.panel{border:1px solid var(--l);border-radius:1rem;padding:1rem;background:#111a31d9}.event{width:100%;display:flex;justify-content:space-between;gap:.6rem;text-align:left;margin:.6rem 0;padding:.85rem;border:1px solid #374e7e;border-radius:.7rem;color:var(--i);background:#15223f;cursor:pointer}.event:hover{background:#20345f}.event--manual{border-color:#e2934a;background:linear-gradient(90deg,#70401e,#15223f)}.event small,.empty{color:var(--m)}.badge{color:#ffd08a}.detail h2{margin-top:0}.prediction{display:flex;justify-content:space-between;gap:1rem;padding:.65rem;margin:.45rem 0;border-left:3px solid #78a4f0;background:#111c34}.prediction--firework{border-color:#f5aa44}.prediction--speech{border-color:#fb7185}.meta{color:var(--m);font-size:.9rem}@media(max-width:42rem){body{padding:1rem}.grid{grid-template-columns:1fr}}
/* Event source styles keep manual reports and sensor classifications recognisable. */
.event__content { display: grid; gap: .16rem; }
.event__source { color: #bcd4ff; font-size: .67rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.event--sensor { border-color: #5478b7; background: linear-gradient(90deg, #1b355f, #15223f 72%); }
.event--sensor .badge { color: #a9ccff; }
.event--manual .event__source { color: #ffd08a; }
.event--sensor:hover { background: linear-gradient(90deg, #25497e, #20345f 72%); }
.event-nav { display: flex; gap: .3rem; padding: .25rem; border: 1px solid var(--l); border-radius: .75rem; background: #111a31d9; box-shadow: 0 .5rem 1.5rem #03071440; }
.top .event-nav a { padding: .5rem .75rem; border: 0; border-radius: .5rem; color: var(--m); font-size: .86rem; font-weight: 750; text-decoration: none; }
.top .event-nav a:hover { color: var(--i); background: #20345f; }
.top .event-nav a[aria-current="page"] { color: var(--i); background: #2a3b67; }
:root[data-theme="light"] .event-nav {
border-color: #cbd9ed;
background: #edf4ff;
box-shadow: 0 .45rem 1.25rem rgba(34, 68, 117, .12);
}
:root[data-theme="light"] .top .event-nav a { color: #47617f; }
:root[data-theme="light"] .top .event-nav a:hover { color: #234a7b; background: #dceaff; }
:root[data-theme="light"] .top .event-nav a[aria-current="page"] {
color: #173d6a;
background: #cfe3ff;
box-shadow: inset 0 0 0 1px #9cc0ed;
}
:root[data-theme="light"] .event {
color: #1d2d46;
border-color: #cfdaea;
background: #f7faff;
box-shadow: 0 .35rem .9rem rgba(38, 62, 101, .06);
}
:root[data-theme="light"] .event:hover { background: #edf4ff; }
:root[data-theme="light"] .event small { color: #61718a; }
:root[data-theme="light"] .event__source { color: #426b9f; }
:root[data-theme="light"] .event--sensor {
border-color: #8eafd9;
background: linear-gradient(90deg, #edf6ff, #e1edff 76%);
}
:root[data-theme="light"] .event--sensor:hover { background: linear-gradient(90deg, #e2f0ff, #d4e6ff 76%); }
:root[data-theme="light"] .event--sensor .badge { color: #245b95; }
:root[data-theme="light"] .event--manual {
border-color: #e4a35c;
background: linear-gradient(90deg, #fff8ee, #ffe3bf 76%);
}
:root[data-theme="light"] .event--manual:hover { background: linear-gradient(90deg, #fff1df, #ffd7a3 76%); }
:root[data-theme="light"] .event--manual .event__source,
:root[data-theme="light"] .event--manual .badge { color: #9a4b13; }
@@ -0,0 +1,522 @@
:root {
--ink: #eaf0ff;
--muted: #9caed1;
--surface: #111a31;
--surface-2: #17223e;
--line: #2a3a61;
--blue: #6aa8ff;
--violet: #a78bfa;
--fire: #ffb454;
--danger: #ff727c;
--success: #6ee7b7;
}
* {
box-sizing: border-box;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: radial-gradient(circle at 10% 0%, #263a76 0, transparent 30rem), radial-gradient(circle at 90% 20%, #4d236c 0, transparent 28rem), #090e1d;
}
.shell {
width: min(100% - 2.5rem, 70rem);
margin: 0 auto;
padding: clamp(2rem, 6vw, 5rem) 0;
}
.brand {
display: flex;
align-items: center;
gap: .75rem;
/* margin-bottom: clamp(2.5rem, 6vw, 5rem); */
font-size: .9rem;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.brand-mark {
display: grid;
width: 2.25rem;
aspect-ratio: 1;
place-items: center;
border-radius: .75rem;
color: #141022;
background: linear-gradient(135deg, #fcd34d, #fb7185);
box-shadow: 0 .5rem 1.5rem #fb718550;
}
.intro {
max-width: 45rem;
}
.kicker {
margin: 0 0 .8rem;
color: #bfdbfe;
font-size: .78rem;
font-weight: 800;
letter-spacing: .15em;
text-transform: uppercase;
}
h1 {
max-width: 12ch;
margin: 0;
font-size: clamp(2.6rem, 7vw, 5.75rem);
line-height: .96;
letter-spacing: -.065em;
}
.lede {
max-width: 38rem;
margin: 1.5rem 0 2.5rem;
color: var(--muted);
font-size: clamp(1rem, 2vw, 1.18rem);
line-height: 1.65;
}
.upload-card,
.results-card {
border: 1px solid var(--line);
border-radius: 1.5rem;
background: linear-gradient(145deg, #162240d9, #0e162bdd);
box-shadow: 0 1.5rem 4rem #02061680;
backdrop-filter: blur(16px);
}
.upload-card {
padding: clamp(1rem, 3vw, 1.5rem);
}
.drop-zone {
display: grid;
min-height: 16rem;
place-items: center;
padding: 2rem;
border: 1.5px dashed #5d75aa;
border-radius: 1rem;
cursor: pointer;
text-align: center;
background: linear-gradient(135deg, #1b2a4e80, #291c4b66);
transition: .2s ease;
}
.drop-zone:hover,
.drop-zone.dragging {
border-color: var(--blue);
transform: translateY(-2px);
background: #203360a8;
}
.drop-zone:focus-within {
outline: 3px solid #6aa8ff66;
outline-offset: 3px;
}
.file-input {
width: .1px;
height: .1px;
position: absolute;
opacity: 0;
overflow: hidden;
}
.drop-zone .upload-icon {
display: grid;
width: 4rem;
aspect-ratio: 1;
place-items: center;
margin: 0 auto 1rem;
border-radius: 50%;
color: #dbeafe;
font-size: 1.8rem;
background: #4777c94d;
}
.drop-zone .upload-icon__content { position: relative; z-index: 1; margin: 0; color: inherit; font-size: inherit; font-weight: 850; }
.audio-upload--uploading .upload-icon,
.audio-upload--processing .upload-icon,
.audio-upload--success .upload-icon,
.audio-upload--error .upload-icon { position: relative; width: 5.5rem; margin-bottom: .25rem; color: #fff; font-size: 1.25rem; box-shadow: 0 0 0 .35rem #334e8d70, 0 .6rem 2rem #101a3fa6; }
.audio-upload--uploading .upload-icon { background: conic-gradient(#91baff var(--upload-progress, 0%), #334b82 0); }
.audio-upload--processing .upload-icon { background: #405caa; }
.audio-upload--processing .upload-icon::after { content: ""; position: absolute; inset: -.42rem; border: 3px solid #9fc5ff; border-right-color: transparent; border-radius: 50%; animation: spin 1.5s linear infinite; }
.audio-upload--success .upload-icon { background: #147d6c; }
.audio-upload--error .upload-icon { background: #9d385b; }
.audio-upload--uploading .drop-zone,
.audio-upload--processing .drop-zone { border-color: #7296d5; background: linear-gradient(135deg, #18284c, #242046); }
.audio-upload--uploading .drop-zone strong,
.audio-upload--processing .drop-zone strong,
.audio-upload--uploading .drop-zone > span > span:not(.upload-icon),
.audio-upload--processing .drop-zone > span > span:not(.upload-icon),
.audio-upload--uploading .file-name,
.audio-upload--processing .file-name { opacity: .35; }
.audio-upload--uploading .drop-zone,
.audio-upload--processing .drop-zone { cursor: default; }
.audio-upload--uploading .drop-zone:hover,
.audio-upload--processing .drop-zone:hover { transform: none; }
.upload-cancel[hidden] { display: none; }
#classification-results { scroll-margin-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) {
.audio-upload--processing .upload-icon::after { animation: none; }
.audio-upload--uploading .drop-zone,
.audio-upload--processing .drop-zone,
.audio-upload--uploading .upload-icon,
.audio-upload--processing .upload-icon { transition: none; }
}
.drop-zone strong {
display: block;
font-size: 1.15rem;
}
.drop-zone span {
display: block;
margin-top: .4rem;
color: var(--muted);
font-size: .92rem;
}
.file-name {
min-height: 1.3rem;
margin: 1rem 0 0;
color: #c7d2fe;
font-size: .9rem;
overflow-wrap: anywhere;
}
.form-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: .9rem .25rem 0;
}
.file-note {
margin: 0;
color: var(--muted);
font-size: .8rem;
}
button,
.button {
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
gap: .6rem;
border: 0;
border-radius: .8rem;
padding: .85rem 1.15rem;
cursor: pointer;
color: #10172c;
font: inherit;
font-weight: 800;
background: linear-gradient(135deg, #93c5fd, #c4b5fd);
box-shadow: 0 .5rem 1.25rem #8b5cf640;
transition: transform .2s ease, filter .2s ease;
}
button:hover,
.button:hover {
transform: translateY(-1px);
filter: brightness(1.08);
}
button:disabled {
cursor: wait;
filter: saturate(.4);
transform: none;
}
.spinner {
width: 1rem;
height: 1rem;
border: 2px solid #263253;
border-top-color: currentColor;
border-radius: 50%;
animation: spin .75s linear infinite;
}
.htmx-indicator {
display: none;
}
.htmx-request.htmx-indicator {
display: inline-block;
}
.upload-form.htmx-request button {
pointer-events: none;
}
#upload-status {
min-height: 1.4rem;
margin: 1rem .25rem 0;
color: #c7d2fe;
font-size: .9rem;
}
.upload-form.htmx-request+#upload-status {
color: #fcd34d;
}
#classification-results {
margin-top: 1.5rem;
}
.results-card {
padding: clamp(1.25rem, 3vw, 2rem);
animation: reveal .35s ease-out;
}
.result-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.result-heading h2 {
margin: 0;
font-size: clamp(1.4rem, 3vw, 2rem);
letter-spacing: -.04em;
}
.result-heading p {
margin: .3rem 0 0;
color: var(--muted);
}
.result-status {
padding: .4rem .65rem;
border-radius: 999px;
color: #a7f3d0;
font-size: .75rem;
font-weight: 800;
white-space: nowrap;
background: #065f464d;
}
.meta {
display: flex;
flex-wrap: wrap;
gap: .6rem;
margin: 1.5rem 0;
}
.meta span,
.legend span {
padding: .4rem .65rem;
border: 1px solid var(--line);
border-radius: 999px;
color: #bdc9e5;
font-size: .8rem;
background: #101a31;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: .5rem;
margin: 0 0 1.25rem;
}
.legend .firework {
color: #ffd18c;
border-color: #c7721e80;
}
.legend .speech {
color: #ffadb4;
border-color: #d5485880;
}
.topbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:3.5rem; }.brand { display:flex; align-items:center; gap:.7rem; color:var(--ink); font-size:.9rem; font-weight:800; letter-spacing:.1em; text-decoration:none; text-transform:uppercase; }.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }.nav { display:flex; gap:.35rem; padding:.25rem; border:1px solid var(--line); border-radius:.75rem; background:#111a31a6; }.nav a { padding:.5rem .75rem; border-radius:.5rem; color:var(--muted); font-size:.86rem; font-weight:700; text-decoration:none; }.nav a[aria-current="page"] { color:var(--ink); background:#2a3b67; }
.result-grid {
display: grid;
grid-template-columns: minmax(0, 1.25fr) minmax(18rem, .75fr);
gap: 1.25rem;
}
.result-group {
padding: 1.1rem;
border: 1px solid var(--line);
border-radius: 1rem;
background: #0b1225a8;
}
.result-group h3 {
margin: 0 0 1rem;
font-size: 1rem;
}
.prediction-list {
display: grid;
gap: .75rem;
margin: 0;
padding: 0;
list-style: none;
}
.prediction {
--accent-color: #7799dd;
position: relative;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: .45rem .75rem;
align-items: center;
padding: .7rem .75rem;
overflow: hidden;
border: 1px solid #26365b;
border-left: 3px solid var(--accent-color);
border-radius: .7rem;
background: #121c34;
}
.prediction--firework {
--accent-color: var(--fire);
background: linear-gradient(90deg, #7a421d55, #121c34);
}
.prediction--speech {
--accent-color: var(--danger);
background: linear-gradient(90deg, #6c213055, #121c34);
}
.prediction-label {
min-width: 0;
font-weight: 700;
overflow-wrap: anywhere;
}
.prediction-score {
color: #c4d1ed;
font-size: .85rem;
font-variant-numeric: tabular-nums;
}
.score-bar {
grid-column: 1/-1;
height: .3rem;
overflow: hidden;
border-radius: 999px;
background: #263657;
}
.score-bar i {
display: block;
width: calc(var(--score) * 1%);
height: 100%;
border-radius: inherit;
background: var(--accent-color);
}
.peak-list {
display: grid;
gap: .7rem;
}
.peak-item {
padding-bottom: .7rem;
border-bottom: 1px solid #253453;
}
.peak-item:last-child {
padding-bottom: 0;
border-bottom: 0;
}
.peak-time {
color: #a9bce0;
font-size: .78rem;
}
.peak-item .prediction {
margin-top: .35rem;
}
.empty {
margin: 0;
color: var(--muted);
}
.error-card {
border-color: #a43d4d;
background: linear-gradient(135deg, #4b1724dd, #1a1427dd);
}
.error-card h2 {
color: #fecdd3;
}
.error-card p {
color: #fecdd3;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes reveal {
from {
opacity: 0;
transform: translateY(.75rem);
}
}
@media (max-width:42rem) {
.shell {
width: min(100% - 1.25rem, 70rem);
}
.form-footer,
.result-heading {
align-items: stretch;
flex-direction: column;
}
.form-footer button {
width: 100%;
}
.result-grid {
grid-template-columns: 1fr;
}
.result-status {
align-self: flex-start;
}
}
@media (prefers-reduced-motion:reduce) {
*,
::before,
::after {
scroll-behavior: auto !important;
animation-duration: .01ms !important;
transition-duration: .01ms !important;
}
}
.browser-gate { margin: 1rem 0; padding: 1rem; border: 1px solid #e5bb7a; border-radius: .75rem; background: #4d392950; }
.browser-gate[hidden] { display: none; }
.browser-gate p { margin: .45rem 0 1rem; }
.browser-gate-actions { display: flex; gap: .65rem; flex-wrap: wrap; }
.browser-gate-actions button { cursor: pointer; }
.browser-mode { margin: 1rem 0; }
.browser-mode__label { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; cursor: pointer; }
.browser-mode__label input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: #91baff; }
.browser-mode p { margin: .35rem 0 0 1.65rem; font-size: .9rem; opacity: .85; }
+85
View File
@@ -0,0 +1,85 @@
:root { --ink:#eef3ff; --muted:#aab9d8; --line:#2b3d68; --blue:#8abaff; --violet:#b69cff; --amber:#ffbd62; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; display:grid; place-items:center; margin:0; padding:1.5rem; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 8% 0%,#263a76 0,transparent 31rem),radial-gradient(circle at 96% 100%,#512363 0,transparent 29rem),#090e1d; }
.welcome-card { width:min(100%,44rem); position:relative; overflow:hidden; padding:clamp(2rem,7vw,4.75rem); border:1px solid var(--line); border-radius:1.5rem; background:linear-gradient(145deg,#172443e8,#10182ddd); box-shadow:0 1.75rem 5rem #01030c99; backdrop-filter:blur(16px); }
.welcome-card::before { content:""; width:15rem; height:15rem; position:absolute; top:-8rem; right:-6rem; border-radius:50%; background:linear-gradient(135deg,#609df177,#b27be266); filter:blur(1px); }.welcome-card::after { content:""; width:10rem; height:10rem; position:absolute; bottom:-6rem; left:-4rem; border-radius:50%; background:#f4a74225; }
.brand { display:flex; align-items:center; gap:.65rem; margin-bottom:clamp(2rem,5vw,4rem); color:#d9e5ff; font-size:.78rem; font-weight:900; letter-spacing:.14em; text-transform:uppercase; }.brand-mark { display:grid; width:2.2rem; aspect-ratio:1; place-items:center; border-radius:.7rem; color:#17132b; font-size:1.1rem; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }
.eyebrow { margin:0 0 .8rem; color:#bad3ff; font-size:.76rem; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }.eyebrow::before { content:""; display:inline-block; width:.55rem; height:.55rem; margin-right:.45rem; border-radius:50%; background:var(--amber); box-shadow:0 0 0 .25rem #fbbf2430; }
h1 { max-width:10ch; margin:0; font-size:clamp(2.8rem,8vw,5.75rem); line-height:.96; letter-spacing:-.065em; }.subject { max-width:33rem; margin:1.35rem 0 0; color:var(--muted); font-size:clamp(1rem,2vw,1.15rem); line-height:1.65; }.subject strong { color:#e8efff; }.sparkle { color:var(--violet); font-size:1.2em; }
.actions { display:flex; align-items:center; gap:1rem; flex-wrap:wrap; margin-top:2.25rem; }
.profile-circle { display:grid; width:3rem; height:3rem; position:fixed; top:1.25rem; right:1.25rem; place-items:center; border:1px solid #d0c0ff; border-radius:50%; z-index:2; color:#17132b; font-weight:900; text-decoration:none; background:linear-gradient(135deg,#fcd34d,#c4a5fd); box-shadow:0 .5rem 1.5rem #01030c66; }
.profile-circle:focus-visible { outline:3px solid #a5c9ff80; outline-offset:3px; }
.button { display:inline-flex; align-items:center; justify-content:center; gap:.6rem; min-height:2.9rem; padding:.75rem 1.05rem; border:1px solid #b3c9ff; border-radius:.8rem; color:#121a34; font:inherit; font-size:.93rem; font-weight:850; text-decoration:none; background:linear-gradient(135deg,#99c8ff,#c6adff); box-shadow:0 .65rem 1.75rem #7058dd50; transition:transform .2s ease,filter .2s ease; }
.button:hover { transform:translateY(-2px); filter:brightness(1.08); }
.button:focus-visible { outline:3px solid #a5c9ff80; outline-offset:3px; }.hint { color:#99add2; font-size:.82rem; }
@media (max-width:30rem) { .welcome-card { padding:2rem 1.5rem; }.actions { align-items:stretch; flex-direction:column; }.button { width:100%; }.hint { text-align:center; } }
@media (prefers-reduced-motion:reduce) { .button { transition:none; } }
.home-grid { width:min(100%,80rem); display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,20rem),1fr)); gap:1.25rem; align-items:stretch; }
.welcome-card { width:100%; }
.manual-report { position:relative; overflow:hidden; padding:clamp(2rem,6vw,4.75rem); border:2px solid #a85a1e; border-radius:1.5rem; background:linear-gradient(145deg,#4a2b16e8,#171225dd); box-shadow:0 1.75rem 5rem #01030c99; }
.manual-report__title { margin:.2rem 0 .75rem; font-size:clamp(2rem,4vw,3.1rem); line-height:1; letter-spacing:-.06em; }
.manual-report__intro { margin:0 0 1.5rem; color:#f3c8a3; line-height:1.55; }
.manual-report__label { display:block; margin-bottom:.5rem; font-weight:800; }
#manual-occurrences { width:100%; min-height:3.3rem; margin-bottom:1rem; padding:.75rem .9rem; border:1px solid #e2934a; border-radius:.75rem; color:#eef3ff; font:inherit; font-weight:800; background:#151b31; }
.manual-direction-panel { margin:0 0 1rem; padding:1rem; border:1px solid #8d5bb5; border-radius:.75rem; background:#241b38; }
.manual-direction-panel__heading { display:block; margin-bottom:.35rem; }
.manual-direction-panel__heading span { color:#c7b5eb; font-weight:600; }
.manual-direction-panel__copy { margin:0 0 .75rem; color:#d4c6ef; font-size:.88rem; line-height:1.45; }
.manual-direction-panel__button { min-height:2.75rem; padding:.65rem .9rem; border:1px solid #c3a5eb; border-radius:.65rem; color:#211234; font:inherit; font-weight:850; background:#d8c1fb; cursor:pointer; }
.manual-direction-panel__status { min-height:1.4rem; margin-top:.7rem; color:#e5dcf7; font-size:.9rem; }
.manual-report__submit { width:100%; min-height:6rem; border:0; border-radius:1rem; color:#281306; font:inherit; font-size:clamp(1.1rem,2vw,1.45rem); font-weight:900; background:linear-gradient(135deg,#ffd18c,#ff8f5b); box-shadow:0 .75rem 1.8rem #d664344d; cursor:pointer; }
.manual-report__submission { min-height:1.5rem; margin-top:1rem; color:#ffd18c; }
/* Homepage-specific light palette: the two cards intentionally retain distinct roles. */
:root[data-theme="light"] .home-grid .welcome-card {
color: #17233b;
border-color: #d5e0f1 !important;
background: linear-gradient(145deg, #ffffff 0%, #f4f8ff 100%) !important;
box-shadow: 0 1.4rem 3.4rem rgba(38, 65, 111, .16) !important;
}
:root[data-theme="light"] .home-grid .welcome-card::before {
background: linear-gradient(135deg, #a9c9fb99, #d4b8f299);
}
:root[data-theme="light"] .home-grid .welcome-card::after { background: #ffd49a66; }
:root[data-theme="light"] .home-grid .welcome-card .brand { color: #365b97; }
:root[data-theme="light"] .home-grid .welcome-card .eyebrow { color: #4269a5; }
:root[data-theme="light"] .home-grid .welcome-card .subject strong { color: #182b50; }
:root[data-theme="light"] .home-grid .welcome-card .hint { color: #5d7191; }
:root[data-theme="light"] .home-grid .manual-report {
color: #42210f;
border-color: #eca851 !important;
background: linear-gradient(145deg, #fff8ef 0%, #ffe0bb 100%) !important;
box-shadow: 0 1.4rem 3.4rem rgba(116, 69, 25, .18) !important;
}
:root[data-theme="light"] .home-grid .manual-report .eyebrow { color: #9f4d16; }
:root[data-theme="light"] .home-grid .manual-report__title { color: #4a2510; }
:root[data-theme="light"] .home-grid .manual-report__intro { color: #70411d; }
:root[data-theme="light"] .home-grid .manual-report__label { color: #54311b; }
:root[data-theme="light"] .home-grid #manual-occurrences {
border-color: #dfaa68;
color: #322014;
background: #fffdfa;
}
:root[data-theme="light"] .home-grid .manual-direction-panel {
border-color: #d9b4d8;
background: #fff5fc;
}
:root[data-theme="light"] .home-grid .manual-direction-panel__heading { color: #492846; }
:root[data-theme="light"] .home-grid .manual-direction-panel__heading span { color: #70466d; }
:root[data-theme="light"] .home-grid .manual-direction-panel__copy { color: #694b68; }
:root[data-theme="light"] .home-grid .manual-direction-panel__button {
border-color: #b68bb5;
color: #321a34;
background: #ead2eb;
}
:root[data-theme="light"] .home-grid .manual-direction-panel__status { color: #6b4267; }
:root[data-theme="light"] .home-grid .manual-report__submit {
color: #281306;
box-shadow: 0 .75rem 1.8rem rgba(190, 90, 34, .27);
}
:root[data-theme="light"] .home-grid .manual-report__submission { color: #87421b; }
@@ -0,0 +1,38 @@
:root { --ink:#eaf0ff; --muted:#9caed1; --surface:#111a31; --surface-2:#17223e; --line:#2a3a61; --blue:#6aa8ff; --violet:#a78bfa; --fire:#ffb454; --danger:#ff727c; --success:#6ee7b7; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; margin:0; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 10% 0%,#263a76 0,transparent 30rem),radial-gradient(circle at 90% 20%,#4d236c 0,transparent 28rem),#090e1d; }
.shell { width:min(100% - 2.5rem,70rem); margin:0 auto; padding:clamp(2rem,6vw,5rem) 0; }
.brand { display:flex; align-items:center; gap:.75rem; margin-bottom:clamp(2.5rem,6vw,5rem); font-size:.9rem; font-weight:800; letter-spacing:.11em; text-transform:uppercase; }
.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }
.intro { max-width:45rem; }
.kicker { margin:0 0 .8rem; color:#bfdbfe; font-size:.78rem; font-weight:800; letter-spacing:.15em; text-transform:uppercase; }
h1 { max-width:12ch; margin:0; font-size:clamp(2.6rem,7vw,5.75rem); line-height:.96; letter-spacing:-.065em; }
.lede { max-width:38rem; margin:1.5rem 0 2.5rem; color:var(--muted); font-size:clamp(1rem,2vw,1.18rem); line-height:1.65; }
.upload-card,.results-card { border:1px solid var(--line); border-radius:1.5rem; background:linear-gradient(145deg,#162240d9,#0e162bdd); box-shadow:0 1.5rem 4rem #02061680; backdrop-filter:blur(16px); }
.upload-card { padding:clamp(1rem,3vw,1.5rem); }
.drop-zone { display:grid; min-height:16rem; place-items:center; padding:2rem; border:1.5px dashed #5d75aa; border-radius:1rem; cursor:pointer; text-align:center; background:linear-gradient(135deg,#1b2a4e80,#291c4b66); transition:.2s ease; }
.drop-zone:hover,.drop-zone.dragging { border-color:var(--blue); transform:translateY(-2px); background:#203360a8; }
.drop-zone:focus-within { outline:3px solid #6aa8ff66; outline-offset:3px; }
.file-input { width:.1px; height:.1px; position:absolute; opacity:0; overflow:hidden; }
.upload-icon { display:grid; width:4rem; aspect-ratio:1; place-items:center; margin:0 auto 1rem; border-radius:50%; color:#dbeafe; font-size:1.8rem; background:#4777c94d; }
.drop-zone strong { display:block; font-size:1.15rem; }
.drop-zone span { display:block; margin-top:.4rem; color:var(--muted); font-size:.92rem; }
.file-name { min-height:1.3rem; margin:1rem 0 0; color:#c7d2fe; font-size:.9rem; overflow-wrap:anywhere; }
.form-footer { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.9rem .25rem 0; }
.file-note { margin:0; color:var(--muted); font-size:.8rem; }
button { display:inline-flex; align-items:center; justify-content:center; gap:.6rem; border:0; border-radius:.8rem; padding:.85rem 1.15rem; cursor:pointer; color:#10172c; font:inherit; font-weight:800; background:linear-gradient(135deg,#93c5fd,#c4b5fd); box-shadow:0 .5rem 1.25rem #8b5cf640; transition:transform .2s ease,filter .2s ease; }
button:hover { transform:translateY(-1px); filter:brightness(1.08); } button:disabled { cursor:wait; filter:saturate(.4); transform:none; }
.spinner { width:1rem; height:1rem; border:2px solid #263253; border-top-color:currentColor; border-radius:50%; animation:spin .75s linear infinite; }
.htmx-indicator { display:none; }.htmx-request.htmx-indicator { display:inline-block; }.upload-form.htmx-request button { pointer-events:none; }
#upload-status { min-height:1.4rem; margin:1rem .25rem 0; color:#c7d2fe; font-size:.9rem; } .upload-form.htmx-request + #upload-status { color:#fcd34d; }
#classification-results { margin-top:1.5rem; }
.results-card { padding:clamp(1.25rem,3vw,2rem); animation:reveal .35s ease-out; }
.result-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; } .result-heading h2 { margin:0; font-size:clamp(1.4rem,3vw,2rem); letter-spacing:-.04em; }.result-heading p { margin:.3rem 0 0; color:var(--muted); }
.result-status { padding:.4rem .65rem; border-radius:999px; color:#a7f3d0; font-size:.75rem; font-weight:800; white-space:nowrap; background:#065f464d; }
.meta { display:flex; flex-wrap:wrap; gap:.6rem; margin:1.5rem 0; }.meta span,.legend span { padding:.4rem .65rem; border:1px solid var(--line); border-radius:999px; color:#bdc9e5; font-size:.8rem; background:#101a31; }.legend { display:flex; flex-wrap:wrap; gap:.5rem; margin:0 0 1.25rem; }.legend .firework { color:#ffd18c; border-color:#c7721e80; }.legend .speech { color:#ffadb4; border-color:#d5485880; }
.result-grid { display:grid; grid-template-columns:minmax(0,1.25fr) minmax(18rem,.75fr); gap:1.25rem; }.result-group { padding:1.1rem; border:1px solid var(--line); border-radius:1rem; background:#0b1225a8; }.result-group h3 { margin:0 0 1rem; font-size:1rem; }.prediction-list { display:grid; gap:.75rem; margin:0; padding:0; list-style:none; }.prediction { --accent-color:#7799dd; position:relative; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.45rem .75rem; align-items:center; padding:.7rem .75rem; overflow:hidden; border:1px solid #26365b; border-left:3px solid var(--accent-color); border-radius:.7rem; background:#121c34; }.prediction--firework { --accent-color:var(--fire); background:linear-gradient(90deg,#7a421d55,#121c34); }.prediction--speech { --accent-color:var(--danger); background:linear-gradient(90deg,#6c213055,#121c34); }.prediction-label { min-width:0; font-weight:700; overflow-wrap:anywhere; }.prediction-score { color:#c4d1ed; font-size:.85rem; font-variant-numeric:tabular-nums; }.score-bar { grid-column:1/-1; height:.3rem; overflow:hidden; border-radius:999px; background:#263657; }.score-bar i { display:block; width:calc(var(--score) * 1%); height:100%; border-radius:inherit; background:var(--accent-color); }.peak-list { display:grid; gap:.7rem; }.peak-item { padding-bottom:.7rem; border-bottom:1px solid #253453; }.peak-item:last-child { padding-bottom:0; border-bottom:0; }.peak-time { color:#a9bce0; font-size:.78rem; }.peak-item .prediction { margin-top:.35rem; }.empty { margin:0; color:var(--muted); }.error-card { border-color:#a43d4d; background:linear-gradient(135deg,#4b1724dd,#1a1427dd); }.error-card h2 { color:#fecdd3; }.error-card p { color:#fecdd3; }
@keyframes spin { to { transform:rotate(360deg); } } @keyframes reveal { from { opacity:0; transform:translateY(.75rem); } }
@media (max-width:42rem) { .shell { width:min(100% - 1.25rem,70rem); }.form-footer,.result-heading { align-items:stretch; flex-direction:column; }.form-footer button { width:100%; }.result-grid { grid-template-columns:1fr; }.result-status { align-self:flex-start; } }
@media (prefers-reduced-motion:reduce) { *,::before,::after { scroll-behavior:auto!important; animation-duration:.01ms!important; transition-duration:.01ms!important; } }
+1
View File
@@ -0,0 +1 @@
body{min-width:320px;min-height:100vh;display:grid;place-items:center;margin:0;padding:1.5rem;color:#eef3ff;font-family:Inter,system-ui,sans-serif;background:radial-gradient(circle at 8% 0,#263a76,transparent 31rem),#090e1d}.card{width:min(100%,27rem);padding:2rem;border:1px solid #2b3d68;border-radius:1.25rem;background:#172443;box-shadow:0 1.75rem 5rem #01030c99}h1{margin:.5rem 0}.intro{color:#aab9d8;line-height:1.5}.error{margin:1rem 0;padding:.75rem;border-radius:.6rem;color:#fee2e2;background:#7f1d1d}label{display:block;margin:1rem 0 .35rem;font-weight:700}input{width:100%;min-height:2.8rem;padding:.65rem;border:1px solid #526b9f;border-radius:.55rem;color:#eef3ff;font:inherit;background:#0a1123}button{width:100%;min-height:2.9rem;margin-top:1.5rem;border:0;border-radius:.65rem;color:#17132b;font:inherit;font-weight:850;background:linear-gradient(135deg,#99c8ff,#c6adff);cursor:pointer}
+17
View File
@@ -0,0 +1,17 @@
:root { --ink:#eef3ff; --muted:#a9b9d8; --surface:#111a31; --line:#2a3a61; --blue:#83b7ff; --violet:#b69cff; --amber:#ffbc61; --green:#6ee7b7; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; margin:0; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 8% 0%,#263a76 0,transparent 32rem),radial-gradient(circle at 95% 0%,#492064 0,transparent 27rem),#090e1d; }
.shell {
width: min(100% - 2.5rem, 70rem);
margin: 0 auto;
padding: clamp(2rem, 6vw, 5rem) 0;
}
.topbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:3.5rem; }.brand { display:flex; align-items:center; gap:.7rem; color:var(--ink); font-size:.9rem; font-weight:800; letter-spacing:.1em; text-decoration:none; text-transform:uppercase; }.brand-mark { display:grid; width:2.25rem; aspect-ratio:1; place-items:center; border-radius:.75rem; color:#141022; background:linear-gradient(135deg,#fcd34d,#fb7185); box-shadow:0 .5rem 1.5rem #fb718550; }.nav { display:flex; gap:.35rem; padding:.25rem; border:1px solid var(--line); border-radius:.75rem; background:#111a31a6; }.nav a { padding:.5rem .75rem; border-radius:.5rem; color:var(--muted); font-size:.86rem; font-weight:700; text-decoration:none; }.nav a[aria-current="page"] { color:var(--ink); background:#2a3b67; }
.kicker { margin:0 0 .65rem; color:#bfdbfe; font-size:.76rem; font-weight:800; letter-spacing:.14em; text-transform:uppercase; }.headline { display:flex; align-items:end; justify-content:space-between; gap:2rem; margin-bottom:2rem; }.headline h1 { margin:0; font-size:clamp(2.3rem,5vw,4.5rem); line-height:.98; letter-spacing:-.06em; }.headline p { max-width:30rem; margin:0; color:var(--muted); line-height:1.6; }
.filters { display:grid; grid-template-columns:repeat(5,minmax(8rem,1fr)) auto auto; gap:.75rem; align-items:end; margin-bottom:1rem; padding:1rem; border:1px solid var(--line); border-radius:1.1rem; background:#121d37d9; box-shadow:0 1rem 3rem #03071466; }.filter { display:grid; gap:.35rem; }.filter label { color:#9fb1d5; font-size:.7rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }.filter select,.filter input { width:100%; min-height:2.65rem; border:1px solid #354a77; border-radius:.65rem; padding:0 .75rem; color:var(--ink); font:inherit; background:#0c1428; }.filter select:focus,.filter input:focus { outline:2px solid #82b5ff; outline-offset:2px; }.filter-submit { min-height:2.65rem; border:1px solid #8ab7ff; border-radius:.65rem; padding:0 1rem; color:#101a31; font:inherit; font-weight:800; background:#b9d6ff; cursor:pointer; }.map-tag { align-self:center; padding:.46rem .65rem; border:1px solid #4a5f8e; border-radius:999px; color:#c9d8f6; font-size:.75rem; font-weight:700; white-space:nowrap; background:#1d2b4e; }
.map-panel { overflow:hidden; border:1px solid var(--line); border-radius:1.25rem; background:var(--surface); box-shadow:0 1.5rem 4rem #0206168a; }.map-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1rem 1.2rem; border-bottom:1px solid var(--line); }.map-header strong { font-size:.95rem; }.live { display:flex; align-items:center; gap:.45rem; color:#a7f3d0; font-size:.8rem; }.live i { width:.5rem; height:.5rem; border-radius:50%; background:var(--green); box-shadow:0 0 0 .25rem #34d3992e; }.map-wrap { position:relative; }.map { height:clamp(30rem,65vh,45rem); background:#dce4cf; }.legend { position:absolute; z-index:600; right:1rem; bottom:1rem; width:min(15rem,calc(100% - 2rem)); padding:.85rem; border:1px solid #344973; border-radius:.8rem; color:#dce7fe; font-size:.78rem; background:#101a31e8; box-shadow:0 .75rem 2rem #05091480; backdrop-filter:blur(10px); }.legend h2 { margin:0 0 .6rem; font-size:.82rem; }.legend div { display:flex; align-items:center; gap:.5rem; margin-top:.4rem; }.legend-dot { width:.7rem; height:.7rem; border:2px solid #f2c56b; border-radius:50%; background:#ed8e2e88; }.legend-ring { width:.85rem; height:.85rem; border:2px solid #a98af7; border-radius:50%; background:#8b5cf633; }.legend-line { width:1.1rem; border-top:2px dashed #644b9c; }.report-icon { display:grid; width:2.3rem; height:2.3rem; place-items:center; border:2px solid #fff3d5; border-radius:50%; color:#452000; font-size:1rem; font-weight:900; background:#f7a52f; box-shadow:0 .3rem 1rem #a84f2670; }.source-icon { display:grid; width:2.45rem; height:2.45rem; place-items:center; border:2px solid #fff3d5; border-radius:50% 50% 50% 0; color:#452000; font-size:1.15rem; background:#f7a52f; box-shadow:0 .3rem 1rem #a84f2670; transform:rotate(-45deg); }.source-icon span { transform:rotate(45deg); }.direction-marker { display:grid; width:3.5rem; height:3.5rem; place-items:center; border:3px solid #fff7e6; border-radius:50%; color:#fff; background:#6d45a0; box-shadow:0 .3rem 1rem #281642b3; }.direction-marker span { display:block; font-size:2.45rem; font-weight:950; line-height:1; text-shadow:0 .1rem .25rem #1e1136; transform-origin:center; }
.map-compass { position:relative; width:5rem; height:5rem; border:2px solid #eaf1ff; border-radius:50%; color:#f7fbff; font-size:.72rem; font-weight:900; background:#111a31e8; box-shadow:0 .5rem 1.5rem #05091480; backdrop-filter:blur(8px); }.map-compass span { position:absolute; display:grid; place-items:center; }.map-compass .compass-n { top:.35rem; left:50%; transform:translateX(-50%); color:#ffd18c; }.map-compass .compass-e { top:50%; right:.45rem; transform:translateY(-50%); }.map-compass .compass-s { bottom:.35rem; left:50%; transform:translateX(-50%); }.map-compass .compass-w { top:50%; left:.45rem; transform:translateY(-50%); }.map-compass .compass-needle { top:1.3rem; left:50%; color:#ffd18c; font-size:2rem; line-height:1; transform:translateX(-50%); text-shadow:0 .1rem .35rem #3b1b48; }.leaflet-control-zoom a { color:#243456!important; }.leaflet-popup-content-wrapper,.leaflet-popup-tip { color:#e9f1ff; background:#14203a; }.leaflet-popup-content { margin:.75rem .9rem; font-family:inherit; }.popup-title { display:block; margin-bottom:.2rem; font-weight:800; }.popup-meta { color:#a9b9d8; font-size:.78rem; }
@media (max-width:52rem) { .shell { width:min(100% - 1.25rem,80rem); }.topbar { margin-bottom:2.5rem; }.headline { align-items:start; flex-direction:column; gap:1rem; }.filters { grid-template-columns:1fr 1fr; }.filters .filter:first-child { grid-column:1/-1; }.map { height:32rem; } }
@media (max-width:30rem) { .nav a { padding:.5rem; }.filters { grid-template-columns:1fr; }.filters .filter:first-child { grid-column:auto; } }
+129
View File
@@ -0,0 +1,129 @@
:root {
--ink: #172033;
--muted: #667085;
--card: rgba(255, 255, 255, .92);
--line: #d7ddea;
--primary: #6255e7;
--success-bg: #eafaf1;
--success-ink: #176b42;
}
* { box-sizing: border-box; }
body {
min-width: 320px;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
padding: 1.5rem;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
background:
radial-gradient(circle at 12% 15%, #cfe1ff 0, transparent 28rem),
radial-gradient(circle at 88% 88%, #e6d8ff 0, transparent 26rem),
#f6f7fb;
}
.card {
width: min(100%, 31rem);
padding: clamp(1.75rem, 7vw, 3rem);
border: 1px solid rgba(255, 255, 255, .85);
border-radius: 1.5rem;
background: var(--card);
box-shadow: 0 1.5rem 4rem rgba(53, 56, 105, .16);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: .5rem;
margin: 0 0 1rem;
color: var(--primary);
font-size: .78rem;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.sparkle {
display: grid;
width: 1.65rem;
aspect-ratio: 1;
place-items: center;
border-radius: .55rem;
color: white;
font-size: .95rem;
background: linear-gradient(135deg, #7668ff, #a75ff4);
}
h1 {
margin: 0;
font-size: clamp(2rem, 7vw, 3rem);
letter-spacing: -.055em;
line-height: 1.05;
}
.intro {
margin: 1rem 0 2rem;
color: var(--muted);
line-height: 1.6;
}
label {
display: block;
margin-bottom: .55rem;
font-size: .92rem;
font-weight: 700;
}
input {
width: 100%;
min-height: 3.15rem;
padding: .75rem 1rem;
border: 1px solid var(--line);
border-radius: .75rem;
outline: none;
color: var(--ink);
font: inherit;
background: white;
}
input:focus {
border-color: var(--primary);
box-shadow: 0 0 0 .25rem rgba(98, 85, 231, .15);
}
button {
width: 100%;
min-height: 3.15rem;
margin-top: 1rem;
border: 0;
border-radius: .75rem;
cursor: pointer;
color: white;
font: inherit;
font-weight: 750;
background: linear-gradient(135deg, var(--primary), #8a5ce5);
box-shadow: 0 .65rem 1.3rem rgba(98, 85, 231, .24);
}
button:hover {
transform: translateY(-1px);
}
.result {
margin: 1.5rem 0 0;
padding: .9rem 1rem;
border-radius: .75rem;
color: var(--success-ink);
line-height: 1.45;
background: var(--success-bg);
}
.button { width: 100%;display:inline-flex; align-items:center; justify-content:center; gap:.6rem; min-height:2.9rem; padding:.75rem 1.05rem; border:1px solid #b3c9ff; border-radius:.8rem; color:#121a34; font:inherit; font-size:.93rem; font-weight:850; text-decoration:none; background:linear-gradient(135deg,#99c8ff,#c6adff); box-shadow:0 .65rem 1.75rem #7058dd50; transition:transform .2s ease,filter .2s ease; }
.button:hover { transform:translateY(-2px); filter:brightness(1.08); }
.button:focus-visible { outline:3px solid #a5c9ff80; outline-offset:3px; }
+209
View File
@@ -0,0 +1,209 @@
:root {
--ink: #172033;
--muted: #667085;
--card: rgba(255, 255, 255, .94);
--line: #e1e6ef;
--primary: #6255e7;
--primary-soft: #f0eeff;
--empty-bg: #f7f8fc;
}
* {
box-sizing: border-box;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
padding: clamp(1.25rem, 5vw, 4rem);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
background:
radial-gradient(circle at 8% 8%, #d9e7ff 0, transparent 30rem),
radial-gradient(circle at 92% 90%, #eadcff 0, transparent 30rem),
#f6f7fb;
}
.page {
width: min(100%, 70rem);
margin: 0 auto;
}
.card {
overflow: hidden;
border: 1px solid rgba(255, 255, 255, .9);
border-radius: 1.5rem;
background: var(--card);
box-shadow: 0 1.5rem 4rem rgba(53, 56, 105, .14);
}
.header {
display: flex;
align-items: end;
justify-content: space-between;
gap: 1.5rem;
padding: clamp(1.5rem, 5vw, 3rem);
border-bottom: 1px solid var(--line);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: .5rem;
margin: 0 0 .85rem;
color: var(--primary);
font-size: .78rem;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.sparkle {
display: grid;
width: 1.65rem;
aspect-ratio: 1;
place-items: center;
border-radius: .55rem;
color: white;
font-size: .95rem;
background: linear-gradient(135deg, #7668ff, #a75ff4);
}
h1 {
margin: 0;
font-size: clamp(2rem, 5vw, 3.25rem);
letter-spacing: -.06em;
line-height: 1.05;
}
.intro {
max-width: 38rem;
margin: .85rem 0 0;
color: var(--muted);
line-height: 1.6;
}
.count {
flex: 0 0 auto;
margin: 0;
padding: .6rem .85rem;
border-radius: 999px;
color: var(--primary);
font-size: .88rem;
font-weight: 750;
white-space: nowrap;
background: var(--primary-soft);
}
.table-wrap {
overflow-x: auto;
}
table {
width: 100%;
min-width: 38rem;
border-collapse: collapse;
text-align: left;
}
th {
padding: 1rem clamp(1.25rem, 3vw, 2rem);
color: var(--muted);
font-size: .75rem;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
background: #fafbfe;
}
td {
padding: 1.15rem clamp(1.25rem, 3vw, 2rem);
border-top: 1px solid var(--line);
vertical-align: middle;
}
tbody tr {
transition: background .18s ease;
}
tbody tr:hover {
background: #faf9ff;
}
.member {
display: flex;
align-items: center;
gap: .85rem;
font-weight: 750;
}
.avatar {
display: grid;
width: 2.45rem;
aspect-ratio: 1;
flex: 0 0 auto;
place-items: center;
border-radius: 50%;
color: var(--primary);
font-size: .82rem;
font-weight: 850;
background: var(--primary-soft);
}
.phone {
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.date {
color: var(--muted);
white-space: nowrap;
}
.empty {
padding: clamp(3rem, 10vw, 6rem) 1.5rem;
text-align: center;
background: var(--empty-bg);
}
.empty-icon {
display: grid;
width: 3.5rem;
aspect-ratio: 1;
place-items: center;
margin: 0 auto 1rem;
border-radius: 1rem;
color: var(--primary);
font-size: 1.4rem;
background: var(--primary-soft);
}
.empty h2 {
margin: 0;
font-size: 1.2rem;
letter-spacing: -.03em;
}
.empty p {
margin: .5rem 0 0;
color: var(--muted);
}
@media (max-width: 40rem) {
.header {
align-items: start;
flex-direction: column;
}
.count {
align-self: start;
}
}
.button { display:inline-flex; align-items:center; justify-content:center; gap:.6rem; min-height:2.9rem; padding:.75rem 1.05rem; border:1px solid #b3c9ff; border-radius:.8rem; color:#121a34; font:inherit; font-size:.93rem; font-weight:850; text-decoration:none; background:linear-gradient(135deg,#99c8ff,#c6adff); box-shadow:0 .65rem 1.75rem #7058dd50; transition:transform .2s ease,filter .2s ease; }
.button:hover { transform:translateY(-2px); filter:brightness(1.08); }
.button:focus-visible { outline:3px solid #a5c9ff80; outline-offset:3px; }
@@ -0,0 +1,127 @@
:root {
--ink: #172033;
--muted: #667085;
--card: rgba(255, 255, 255, .92);
--line: #d7ddea;
--primary: #6255e7;
--success-bg: #eafaf1;
--success-ink: #176b42;
}
* { box-sizing: border-box; }
body {
min-width: 320px;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
padding: 1.5rem;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
background:
radial-gradient(circle at 12% 15%, #cfe1ff 0, transparent 28rem),
radial-gradient(circle at 88% 88%, #e6d8ff 0, transparent 26rem),
#f6f7fb;
}
.card {
width: min(100%, 31rem);
padding: clamp(1.75rem, 7vw, 3rem);
border: 1px solid rgba(255, 255, 255, .85);
border-radius: 1.5rem;
background: var(--card);
box-shadow: 0 1.5rem 4rem rgba(53, 56, 105, .16);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: .5rem;
margin: 0 0 1rem;
color: var(--primary);
font-size: .78rem;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.sparkle {
display: grid;
width: 1.65rem;
aspect-ratio: 1;
place-items: center;
border-radius: .55rem;
color: white;
font-size: .95rem;
background: linear-gradient(135deg, #7668ff, #a75ff4);
}
.button { display:inline-flex; align-items:center; justify-content:center; gap:.6rem; min-height:2.9rem; padding:.75rem 1.05rem; border:1px solid #b3c9ff; border-radius:.8rem; color:#121a34; font:inherit; font-size:.93rem; font-weight:850; text-decoration:none; background:linear-gradient(135deg,#99c8ff,#c6adff); box-shadow:0 .65rem 1.75rem #7058dd50; transition:transform .2s ease,filter .2s ease; }
.button:hover { transform:translateY(-2px); filter:brightness(1.08); }
.button:focus-visible { outline:3px solid #a5c9ff80; outline-offset:3px; }
h1 {
margin: 0;
font-size: clamp(2rem, 7vw, 3rem);
letter-spacing: -.055em;
line-height: 1.05;
}
.intro {
margin: 1rem 0 2rem;
color: var(--muted);
line-height: 1.6;
}
label {
display: block;
margin-bottom: .55rem;
font-size: .92rem;
font-weight: 700;
}
input {
width: 100%;
min-height: 3.15rem;
padding: .75rem 1rem;
border: 1px solid var(--line);
border-radius: .75rem;
outline: none;
color: var(--ink);
font: inherit;
background: white;
}
input:focus {
border-color: var(--primary);
box-shadow: 0 0 0 .25rem rgba(98, 85, 231, .15);
}
button {
width: 100%;
min-height: 3.15rem;
margin-top: 1rem;
border: 0;
border-radius: .75rem;
cursor: pointer;
color: white;
font: inherit;
font-weight: 750;
background: linear-gradient(135deg, var(--primary), #8a5ce5);
box-shadow: 0 .65rem 1.3rem rgba(98, 85, 231, .24);
}
button:hover {
transform: translateY(-1px);
}
.result {
margin: 1.5rem 0 0;
padding: .9rem 1rem;
border-radius: .75rem;
color: var(--success-ink);
line-height: 1.45;
background: var(--success-bg);
}
+8
View File
@@ -0,0 +1,8 @@
:root { --ink:#eef3ff; --muted:#aab9d8; --line:#2b3d68; --violet:#b69cff; --blue:#8abaff; }
* { box-sizing:border-box; }
body { min-width:320px; min-height:100vh; display:grid; place-items:center; margin:0; padding:1.5rem; color:var(--ink); font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:radial-gradient(circle at 8% 0%,#263a76 0,transparent 31rem),radial-gradient(circle at 96% 100%,#512363 0,transparent 29rem),#090e1d; }
.card { width:min(100%,42rem); position:relative; overflow:hidden; padding:clamp(2rem,7vw,4.75rem); border:1px solid var(--line); border-radius:1.5rem; text-align:center; background:linear-gradient(145deg,#172443e8,#10182ddd); box-shadow:0 1.75rem 5rem #01030c99; backdrop-filter:blur(16px); }.card::before,.card::after { content:""; position:absolute; border-radius:50%; filter:blur(1px); pointer-events:none; }.card::before { width:14rem; height:14rem; top:-8rem; left:-5rem; background:#5888e536; }.card::after { width:11rem; height:11rem; right:-5rem; bottom:-5rem; background:#b069e73d; }
.mark { display:grid; width:4.25rem; aspect-ratio:1; place-items:center; margin:0 auto 1.75rem; border:1px solid #a7c7ff66; border-radius:1.1rem; color:#141c39; font-size:1.7rem; background:linear-gradient(135deg,#a8ceff,#c5b3ff); box-shadow:0 .65rem 1.75rem #735ee150; transform:rotate(8deg); }.mark span { transform:rotate(-8deg); }.code { margin:0; color:#bfcfff; font-size:.78rem; font-weight:900; letter-spacing:.2em; text-transform:uppercase; }.code strong { color:#f2d07f; }.title { max-width:10ch; margin:.75rem auto 1rem; font-size:clamp(2.5rem,8vw,5rem); line-height:.96; letter-spacing:-.065em; }.message { max-width:31rem; margin:0 auto; color:var(--muted); line-height:1.65; }.path { display:inline-block; max-width:100%; margin-top:1.1rem; padding:.45rem .7rem; overflow-wrap:anywhere; border:1px solid #354b7a; border-radius:.55rem; color:#c6d5f3; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.78rem; background:#0a1123; }.actions { display:flex; justify-content:center; gap:.75rem; flex-wrap:wrap; margin-top:2rem; }.button { display:inline-flex; align-items:center; justify-content:center; min-height:2.8rem; padding:.7rem 1rem; border:1px solid #455d92; border-radius:.75rem; color:#dce7ff; font-size:.92rem; font-weight:800; text-decoration:none; background:#1b2949; transition:transform .2s ease,background .2s ease; }.button:hover { transform:translateY(-2px); background:#263b69; }.button-primary { border-color:#b2c8ff; color:#121a34; background:linear-gradient(135deg,#97c5ff,#c2adff); }.button-primary:hover { background:linear-gradient(135deg,#b0d4ff,#d1c2ff); }
@media (prefers-reduced-motion:reduce) { .button { transition:none; } }
+51
View File
@@ -0,0 +1,51 @@
/* Settings cards follow the shared blue and violet theme. */
*{box-sizing:border-box}
body{min-height:100vh;padding:0;color:var(--theme-ink);background:var(--theme-bg)}
.settings-shell{width:min(100% - 3.5rem,73.75rem);margin:auto;padding:4rem 0 5rem}
.settings-content{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2.25rem 2rem;width:100%}
.settings-heading,.messages{grid-column:1/-1}
.settings-heading{margin-bottom:0}
.eyebrow{margin:0 0 .7rem;color:#9fc5ff;font-size:.74rem;font-weight:800;letter-spacing:.1em;text-transform:uppercase}
h1,h2{font-family:Georgia,ui-serif,serif;font-weight:700}
h1{margin:0;font-size:clamp(2.3rem,4vw,3.5rem);letter-spacing:-.045em;line-height:1.12}
h2{margin:0 0 .45rem;font-size:1.5rem;letter-spacing:-.02em}
.intro,.help{margin:.45rem 0 0;color:var(--theme-muted);line-height:1.55}
.card{min-width:0;width:100%;margin:0;padding:1.75rem;border:1px solid var(--theme-line);border-radius:1.125rem;background:var(--theme-surface);box-shadow:0 1.125rem 2.8rem #02071429}
.settings-form{display:flex;flex-direction:column;gap:1rem}.settings-form h2+.field{margin-top:.4rem}
.settings-form>.button[type=submit]{margin-top:auto}
.field label{display:block;margin:0 0 .375rem;font-size:.85rem;font-weight:700}
.field input,.field select{display:block;width:100%;min-height:2.625rem;padding:.55rem .625rem;border:1px solid var(--theme-line);border-radius:.56rem;color:var(--theme-ink);background:var(--theme-input);font:inherit}
.field input:focus-visible,.field select:focus-visible,.button:focus-visible,.switch-control input:focus-visible+.switch-track{outline:3px solid #80b6ff;outline-offset:3px}
.errorlist{margin:.5rem 0 0;padding:.7rem .9rem;border-radius:.55rem;color:#fee2e2;background:#7f1d1d}
.button{display:inline-flex;align-items:center;justify-content:center;width:100%;min-height:2.875rem;margin:0;padding:.65rem 1.2rem;border:1px solid transparent;border-radius:999px;color:#111c30;background:#a6ccff;font:inherit;font-size:.9rem;font-weight:800;text-align:center;text-decoration:none;cursor:pointer;transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
.button:hover{transform:translateY(-1px);background:#c0ddff;box-shadow:0 .45rem 1rem #5899f733}
.button--secondary{border-color:#6386bd;color:#d7e8ff;background:#223755}.button--secondary:hover{color:#111c30;background:#a6ccff}
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:1.125rem;min-height:4.375rem;padding:.8rem 1rem;border:1px solid #3d5879;border-radius:.94rem;background:#1a2a43;cursor:pointer}
.switch-row:hover{border-color:#739ad0;background:#203554}.switch-copy{display:grid;gap:.2rem;min-width:0}.switch-copy strong{font-size:.92rem}.switch-copy small{color:var(--theme-muted);font-size:.77rem;line-height:1.35}
.switch-control{position:relative;display:block;flex:0 0 3.1875rem;width:3.1875rem;height:1.9375rem}.switch-control input{position:absolute;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}.switch-track{display:block;width:100%;height:100%;border-radius:999px;background:#62758b;pointer-events:none;transition:background .16s ease}
.switch-track::after{content:"";position:absolute;top:2px;left:2px;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 1px 4px #0004;transition:transform .16s ease}.switch-control input:checked+.switch-track{background:#34c76a}.switch-control input:checked+.switch-track::after{transform:translateX(20px)}
.messages{margin:0;padding:0;list-style:none}.alert{margin:.5rem 0 0;padding:.75rem 1rem;border-radius:.65rem;line-height:1.45}#ntfy-test-result:empty{display:none}
.sensor-list__intro{padding-bottom:1.25rem;border-bottom:1px solid var(--theme-line)}.sensor-list__intro .eyebrow{margin-bottom:.35rem}
.sensor-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;margin:1.5rem 0}.sensor-card{display:flex;flex-direction:column;min-width:0;margin:0;padding:1.3rem;border:1px solid var(--theme-line);border-radius:1rem;background:var(--theme-surface-raised)}
.sensor-card__heading{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem}.sensor-card__heading h3{margin:0;font-family:Georgia,ui-serif,serif;font-size:1.25rem;overflow-wrap:anywhere}.sensor-card .sensor-status{display:inline-flex;padding:.32rem .65rem;border-radius:999px;background:var(--theme-input);font-size:.78rem;white-space:nowrap}
.sensor-status{color:var(--theme-muted);font-weight:700}.sensor-status--online{color:#64dca0}.sensor-status--delayed{color:#f5c46b}.sensor-status--offline{color:#f49aa7}
.sensor-access{align-self:flex-start;margin-top:.7rem;padding:.25rem .55rem;border:1px solid #3d806b;border-radius:999px;color:#8be0b9;font-size:.72rem;font-weight:800}.sensor-access--off{border-color:#806b75;color:#d4b9c5}
.sensor-card__facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.8rem 1rem;margin:1.3rem 0}.sensor-card__facts div{min-width:0}.sensor-card__facts dt{margin-bottom:.25rem;color:var(--theme-muted);font-size:.75rem;font-weight:700}.sensor-card__facts dd{margin:0;font-size:.88rem;font-weight:600;overflow-wrap:anywhere}.sensor-card__facts code{font:inherit}.sensor-card__facts div:last-child{grid-column:1/-1}
.sensor-card .button{margin-top:auto}.sensor-empty{grid-column:1/-1;margin:0;padding:1.5rem;border:1px dashed var(--theme-line);border-radius:1rem;color:var(--theme-muted);text-align:center;line-height:1.5}
.sensor-form{margin-top:1.5rem;padding:1.3rem;border:1px dashed #6386bd;border-radius:1rem;background:var(--theme-surface-raised)}.sensor-form h3{margin:0;font-family:Georgia,ui-serif,serif;font-size:1.2rem}.sensor-form .help{margin-top:.3rem}.sensor-form__controls{display:grid;grid-template-columns:minmax(0,1fr) 11rem;align-items:end;gap:1rem}
.settings-content>#sensor-card{grid-column:1/-1}
.sensor-detail__header{display:flex;align-items:start;justify-content:space-between;gap:1rem;padding-bottom:1.2rem;border-bottom:1px solid var(--theme-line)}.sensor-detail__header .eyebrow{margin-bottom:.35rem}.sensor-detail__header h2{margin:0;font-size:clamp(1.6rem,3vw,2rem);overflow-wrap:anywhere}.sensor-close{display:inline-flex;align-items:center;gap:.35rem;flex:none;padding:.45rem .85rem;border:1px solid var(--theme-line);border-radius:999px;color:var(--theme-ink);background:var(--theme-surface-raised);font-size:.85rem;font-weight:700;text-decoration:none}.sensor-close:hover{border-color:#86ade0;background:#2b4266}.sensor-close:focus-visible{outline:3px solid #80b6ff;outline-offset:3px}
.sensor-detail__overview{margin:1.25rem 0 1.5rem;padding:1.2rem;border:1px solid var(--theme-line);border-radius:1rem;background:var(--theme-surface-raised)}.sensor-detail__overview>.sensor-status{display:inline-flex;margin:0 0 1rem;padding:.35rem .7rem;border-radius:999px;background:var(--theme-input);font-size:.85rem}
.sensor-detail__facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem 1.5rem;margin:0}.sensor-detail__facts div{min-width:0}.sensor-detail__facts dt{margin:0 0 .3rem;color:var(--theme-muted);font-size:.78rem;font-weight:700}.sensor-detail__facts dd{margin:0;overflow-wrap:anywhere;font-size:.92rem;font-weight:600}.sensor-detail__facts code{font:inherit}
.sensor-detail__actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}.sensor-detail__section{display:flex;flex-direction:column;min-width:0;padding:1.2rem;border:1px solid var(--theme-line);border-radius:1rem;background:var(--theme-surface-raised)}.sensor-detail__section h3{margin:0 0 .35rem;font-family:Georgia,ui-serif,serif;font-size:1.15rem}.sensor-detail__section>.help{margin:0}.sensor-detail__section form{display:flex;flex:1;flex-direction:column;gap:.8rem;margin-top:1rem}.sensor-detail__section form .button{margin-top:auto}.sensor-detail__section .field{width:100%}.sensor-detail__section:last-child{border-color:#945f68;background:#392432}.sensor-detail__section:last-child .button--danger{border-color:#dc7b89;color:#fff;background:#a43c50}.sensor-detail__section:last-child .button--danger:hover{background:#bd4a60}
.sensor-confirm{display:flex;align-items:start;gap:.6rem;line-height:1.4;font-size:.82rem;cursor:pointer}.sensor-confirm input{flex:none;width:1.1rem;height:1.1rem;margin:.15rem 0 0;accent-color:#84baff}.sensor-confirm input:focus-visible{outline:3px solid #80b6ff;outline-offset:3px}
.sensor-messages{margin-top:1rem}.token-once{margin:1.25rem 0;padding:1rem;border:1px solid #e4ad55;border-radius:.8rem;background:var(--theme-surface-raised)}.token-once code{display:block;margin:.75rem 0;padding:.7rem;border-radius:.5rem;background:var(--theme-input);overflow-wrap:anywhere;user-select:all}
.button--danger{color:#fff;background:#991b1b}.button--danger:hover{color:#fff;background:#b91c1c}
:root[data-theme=light] .eyebrow{color:#23578d}:root[data-theme=light] .card{box-shadow:0 1.125rem 2.8rem #20365c1a}:root[data-theme=light] .button:not(.button--secondary):not(.button--danger){color:#fff;background:#245b96}:root[data-theme=light] .button:not(.button--secondary):not(.button--danger):hover{background:#174877}:root[data-theme=light] .button--secondary{border-color:#9cc0ed;color:#245b96;background:#edf4ff}:root[data-theme=light] .button--secondary:hover{color:#fff;background:#245b96}:root[data-theme=light] .switch-row{border-color:#d4e0ef;background:#f2f7fe}:root[data-theme=light] .switch-row:hover{border-color:#9cc0ed;background:#eaf3ff}:root[data-theme=light] .switch-track{background:#c1cbd8}:root[data-theme=light] .switch-control input:checked+.switch-track{background:#34c76a}
:root[data-theme=light] .sensor-close:hover{background:#e4efff}:root[data-theme=light] .sensor-detail__section:last-child{border-color:#ecc6cb;background:#fff5f6}:root[data-theme=light] .sensor-detail__section:last-child .button--danger{color:#fff;background:#a43c50}
:root[data-theme=light] .sensor-access{border-color:#b8dfca;color:#256147;background:#ecf8f0}:root[data-theme=light] .sensor-access--off{border-color:#dbcbd3;color:#80556a;background:#fbf4f7}:root[data-theme=light] .sensor-form{border-color:#9cc0ed}
@media(max-width:48rem){.settings-content{grid-template-columns:minmax(0,1fr)}.settings-shell{width:min(100% - 2.25rem,73.75rem);padding:2.5rem 0 3rem}}
@media(max-width:48rem){.sensor-detail__actions,.sensor-list{grid-template-columns:minmax(0,1fr)}}
@media(max-width:30rem){.sensor-detail__facts{grid-template-columns:minmax(0,1fr)}.sensor-detail__header{align-items:start}.sensor-close span{display:none}}
@media(max-width:35rem){.card{padding:1.25rem}.sensor-form__controls{grid-template-columns:minmax(0,1fr)}}
@media(prefers-reduced-motion:reduce){.button,.switch-track,.switch-track::after{transition:none}.button:hover{transform:none}}
+117
View File
@@ -0,0 +1,117 @@
:root {
color-scheme: dark;
--theme-bg: #090e1d;
--theme-ink: #eef3ff;
--theme-muted: #aab9d8;
--theme-surface: #172443;
--theme-surface-raised: #111a31;
--theme-line: #2b3d68;
--theme-input: #0a1123;
}
:root[data-theme="light"] {
color-scheme: light;
--ink: #172033;
--i: #172033;
--muted: #536174;
--m: #536174;
--line: #c4cede;
--l: #c4cede;
--surface: #ffffff;
--surface-2: #f2f6fc;
--card: rgba(255, 255, 255, .94);
--theme-bg: #f4f7fc;
--theme-ink: #172033;
--theme-muted: #536174;
--theme-surface: #ffffff;
--theme-surface-raised: #f2f6fc;
--theme-line: #c4cede;
--theme-input: #ffffff;
}
:root[data-theme="light"] body {
color: var(--theme-ink) !important;
background: radial-gradient(circle at 8% 0%, #dbeaff 0, transparent 31rem), radial-gradient(circle at 96% 100%, #eee2ff 0, transparent 29rem), var(--theme-bg) !important;
}
:root[data-theme="light"] .card,
:root[data-theme="light"] .welcome-card,
:root[data-theme="light"] .upload-card,
:root[data-theme="light"] .results-card,
:root[data-theme="light"] .panel,
:root[data-theme="light"] .map-panel {
border-color: var(--theme-line) !important;
background: var(--theme-surface) !important;
box-shadow: 0 1rem 3rem rgba(32, 54, 92, .14) !important;
}
:root[data-theme="light"] .topbar,
:root[data-theme="light"] .map-header,
:root[data-theme="light"] .nav,
:root[data-theme="light"] .filters,
:root[data-theme="light"] .result-group,
:root[data-theme="light"] .prediction,
:root[data-theme="light"] .event,
:root[data-theme="light"] .drop-zone {
border-color: var(--theme-line) !important;
color: var(--theme-ink);
background: var(--theme-surface-raised) !important;
}
:root[data-theme="light"] .audio-upload--uploading .drop-zone,
:root[data-theme="light"] .audio-upload--processing .drop-zone {
border-color: #7296d5 !important;
background: #e4ebff !important;
}
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea,
:root[data-theme="light"] .path {
border-color: var(--theme-line) !important;
color: var(--theme-ink) !important;
background: var(--theme-input) !important;
}
:root[data-theme="light"] .intro,
:root[data-theme="light"] .lede,
:root[data-theme="light"] .subject,
:root[data-theme="light"] .message,
:root[data-theme="light"] .help,
:root[data-theme="light"] .empty,
:root[data-theme="light"] .meta,
:root[data-theme="light"] .popup-meta {
color: var(--theme-muted) !important;
}
.theme-toggle {
position: fixed;
top: 1rem;
left: 1rem;
z-index: 1200;
min-height: 2.5rem;
padding: .5rem .75rem;
border: 1px solid var(--theme-line);
border-radius: 999px;
color: var(--theme-ink);
font: 700 .82rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
background: var(--theme-surface);
box-shadow: 0 .35rem 1.25rem rgba(1, 3, 12, .24);
cursor: pointer;
}
.theme-toggle:hover { filter: brightness(1.08); }
.theme-toggle:focus-visible { outline: 3px solid #8abaff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { transition-duration: .01ms !important; }
}
/* Shared light-mode typography for the Fireworks pages. */
:root[data-theme="light"] .shell h1 { color: #172b50 !important; }
:root[data-theme="light"] .shell h2 { color: #203b63 !important; }
:root[data-theme="light"] .shell h3 { color: #31527f !important; }
:root[data-theme="light"] .shell .kicker,
:root[data-theme="light"] .shell .eyebrow { color: #3f6fa9 !important; }
:root[data-theme="light"] .shell .map-header strong { color: #243e65 !important; }
+84
View File
@@ -0,0 +1,84 @@
import assert from "node:assert/strict";
import test from "node:test";
import { JSDOM } from "jsdom";
function fixture() {
const dom = new JSDOM(`<!doctype html><html><body>
<script id="boomcast-browser-config" type="application/json">{"browserProcessingBeta":true,"policyUrl":"/policy","policyVersion":1}</script>
<form class="upload-form" action="/classify">
<label id="drop-zone"><input id="audio-file" name="audio" type="file" accept="audio/*,.wav" required><span id="upload-progress-circle"><span id="upload-icon-content"></span></span><span id="file-name"></span></label>
<input id="browser-processing-toggle" type="checkbox">
<button type="submit">Submit</button><button class="upload-cancel" type="button" hidden>Cancel</button>
<section id="browser-gate" hidden><strong id="browser-gate-title"></strong><p id="browser-gate-message"></p><button id="browser-gate-choose" type="button"></button><button id="browser-gate-override" type="button"></button></section>
<section id="classification-results"></section>
</form><p id="upload-status"></p></body></html>`, { url: "https://example.test/" });
const { window } = dom;
window.matchMedia = () => ({ matches: false });
window.BOOMCAST_I18N = {};
const requests = [];
class MockXHR {
upload = { addEventListener() {} };
addEventListener() {}
open() {}
send(data) { requests.push(data); }
}
const originals = Object.fromEntries(["window", "document", "FormData", "XMLHttpRequest", "DOMParser", "fetch"].map((name) => [name, globalThis[name]]));
Object.assign(globalThis, { window, document: window.document, FormData: window.FormData, XMLHttpRequest: MockXHR, DOMParser: window.DOMParser });
const form = window.document.querySelector("form");
form.reportValidity = () => true;
const input = window.document.querySelector("#audio-file");
const audio = new window.File(["audio"], "clip.wav", { type: "audio/wav" });
Object.defineProperty(input, "files", { configurable: true, value: [audio] });
const toggle = window.document.querySelector("#browser-processing-toggle");
return { window, form, input, audio, toggle, requests, restore: () => {
for (const [name, value] of Object.entries(originals)) {
if (value === undefined) delete globalThis[name];
else globalThis[name] = value;
}
dom.window.close();
} };
}
test("admin ON with user toggle OFF uploads the original audio without policy fetch", async () => {
const ui = fixture();
let fetches = 0;
globalThis.fetch = () => { fetches += 1; throw new Error("browser policy must not load"); };
try {
await import("../src/scripts/audio-upload.js?mode=server");
assert.equal(ui.toggle.checked, false);
ui.input.dispatchEvent(new ui.window.Event("change", { bubbles: true }));
assert.equal(ui.form.querySelector('button[type="submit"]').disabled, false);
ui.form.dispatchEvent(new ui.window.Event("submit", { bubbles: true, cancelable: true }));
assert.equal(fetches, 0);
assert.equal(ui.requests.length, 1);
assert.equal(ui.requests[0].get("audio").name, "clip.wav");
assert.equal(ui.requests[0].has("browser_processing_metadata"), false);
} finally { ui.restore(); }
});
test("switching browser mode off invalidates a policy job and restores server submission", async () => {
const ui = fixture();
let resolveFetch;
let fetches = 0;
globalThis.fetch = () => { fetches += 1; return new Promise((resolve) => { resolveFetch = resolve; }); };
try {
await import("../src/scripts/audio-upload.js?mode=switch");
ui.input.dispatchEvent(new ui.window.Event("change", { bubbles: true }));
ui.toggle.checked = true;
ui.toggle.dispatchEvent(new ui.window.Event("change", { bubbles: true }));
for (let i = 0; i < 30 && !resolveFetch; i += 1) await new Promise((resolve) => setTimeout(resolve, 5));
assert.equal(fetches, 1);
assert.equal(ui.form.querySelector('button[type="submit"]').disabled, true);
ui.toggle.checked = false;
ui.toggle.dispatchEvent(new ui.window.Event("change", { bubbles: true }));
resolveFetch({ ok: true, json: async () => ({ browser_processing_beta_enabled: true, version: 1 }) });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(ui.input.accept, "audio/*,.wav");
assert.equal(ui.form.querySelector('button[type="submit"]').disabled, false);
assert.equal(ui.window.document.querySelector("#browser-gate").hidden, true);
ui.form.dispatchEvent(new ui.window.Event("submit", { bubbles: true, cancelable: true }));
assert.equal(ui.requests.length, 1);
assert.equal(ui.requests[0].get("audio").name, "clip.wav");
assert.equal(ui.requests[0].has("browser_processing_metadata"), false);
} finally { ui.restore(); }
});
@@ -0,0 +1,99 @@
import assert from "node:assert/strict";
import test from "node:test";
import { BrowserSubmissionGate } from "../src/scripts/browser-submission-gate.js";
import { BrowserSubmissionProcessor } from "../src/scripts/browser-submission-processor.js";
const policy = { whitelist: ["Fireworks"], privacy_sensitive_speech: ["Speech"], thresholds: { relevance: .5, speech: .5 } };
test("whitelist match allows normal submission even when speech is present", () => {
const decision = BrowserSubmissionGate.evaluate([{ class: "Fireworks", score: .8 }, { class: "Speech", score: .9 }], policy);
assert.equal(decision.result, "whitelist_match");
assert.equal(decision.speechDetected, true);
});
test("speech without relevance and irrelevant audio require explicit override", () => {
assert.equal(BrowserSubmissionGate.evaluate([{ class: "Speech", score: .9 }], policy).result, "speech_only");
assert.equal(BrowserSubmissionGate.evaluate([{ class: "Music", score: .9 }], policy).result, "no_match");
});
test("audio and video-derived WAV use the same gate; audio never calls FFmpeg", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ ...policy, browser_processing_beta_enabled: true, version: 1 }) });
let extractionCalls = 0;
let classificationCalls = 0;
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/policy", policyVersion: 1 },
async () => { extractionCalls += 1; return new File(["wav"], "clip.wav", { type: "audio/wav" }); },
{ prepareAudio: async () => new Float32Array(16000), classify: async () => { classificationCalls += 1; return [{ class: "Speech", score: .9 }]; } },
);
processor.setEnabled(true);
try {
assert.equal((await processor.prepare(new File(["audio"], "audio.wav", { type: "audio/wav" }))).gate, "speech_only");
assert.equal(extractionCalls, 0);
assert.equal((await processor.prepare(new File(["video"], "clip.mp4", { type: "video/mp4" }))).gate, "speech_only");
assert.equal(extractionCalls, 1);
assert.equal(classificationCalls, 2);
} finally { globalThis.fetch = originalFetch; }
});
test("local classifier failure restores ordinary server upload", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ ...policy, browser_processing_beta_enabled: true, version: 1 }) });
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/policy", policyVersion: 1 }, null,
{ prepareAudio: async () => new Float32Array(16000), classify: async () => { throw new Error("offline"); } },
);
const audio = new File(["audio"], "audio.wav", { type: "audio/wav" });
processor.setEnabled(true);
try {
const result = await processor.prepare(audio);
assert.equal(result.file, audio);
assert.equal(result.gate, "unavailable");
} finally { globalThis.fetch = originalFetch; }
});
test("aborted classification never yields a gate decision", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ ...policy, browser_processing_beta_enabled: true, version: 1 }) });
const controller = new AbortController();
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/policy", policyVersion: 1 }, null,
{ prepareAudio: async () => new Float32Array(16000), classify: async () => { controller.abort(); return [{ class: "Fireworks", score: .9 }]; } },
);
processor.setEnabled(true);
try {
await assert.rejects(processor.prepare(new File(["audio"], "audio.wav", { type: "audio/wav" }), { signal: controller.signal }));
} finally { globalThis.fetch = originalFetch; }
});
test("replacing a classification cancels the old result and keeps the new file", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ ...policy, browser_processing_beta_enabled: true, version: 1 }) });
let firstStarted;
const started = new Promise((resolve) => { firstStarted = resolve; });
let finishFirst;
let calls = 0;
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/policy", policyVersion: 1 }, null,
{ prepareAudio: async () => new Float32Array(16000), classify: async () => {
calls += 1;
if (calls === 1) {
firstStarted();
return new Promise((resolve) => { finishFirst = resolve; });
}
return [{ class: "Fireworks", score: .9 }];
} },
);
processor.setEnabled(true);
const firstFile = new File(["a"], "first.wav", { type: "audio/wav" });
const secondFile = new File(["b"], "second.wav", { type: "audio/wav" });
try {
const first = processor.process(firstFile);
await started;
const second = await processor.process(secondFile);
assert.equal(second.file, secondFile);
assert.equal(second.gate, "whitelist_match");
finishFirst([{ class: "Speech", score: .9 }]);
await assert.rejects(first);
} finally { globalThis.fetch = originalFetch; }
});
@@ -0,0 +1,112 @@
import assert from "node:assert/strict";
import test from "node:test";
import { BrowserSubmissionProcessor } from "../src/scripts/browser-submission-processor.js";
const file = { type: "audio/wav", size: 64 };
test("disabled beta returns the original file without loading policy", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = () => { throw new Error("fetch must not run"); };
try {
const processor = new BrowserSubmissionProcessor({ browserProcessingBeta: false });
processor.setEnabled(true);
assert.equal(processor.isEnabled(), false);
assert.equal(processor.canProcess(file), false);
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
} finally {
globalThis.fetch = originalFetch;
}
});
test("enabled shell checks current server policy and never claims processing occurred", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ browser_processing_beta_enabled: true, version: 1 }) });
try {
const processor = new BrowserSubmissionProcessor({ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 });
processor.setEnabled(true);
const result = await processor.prepare(file);
assert.equal(result.file, file);
assert.equal(result.metadata.browser_processing_used, false);
assert.equal(result.metadata.browser_gate_result, "unavailable");
} finally {
globalThis.fetch = originalFetch;
}
});
test("admin-disabled policy and fetch failure both fall back to the original file", async () => {
const originalFetch = globalThis.fetch;
const processor = new BrowserSubmissionProcessor({ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 });
processor.setEnabled(true);
try {
globalThis.fetch = async () => ({ ok: true, json: async () => ({ browser_processing_beta_enabled: false, version: 1 }) });
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
globalThis.fetch = async () => { throw new Error("offline"); };
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
} finally {
globalThis.fetch = originalFetch;
}
});
test("video routing is gated and audio never invokes FFmpeg", async () => {
const originalFetch = globalThis.fetch;
let calls = 0;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ browser_processing_beta_enabled: true, version: 1 }) });
try {
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 },
async () => { calls += 1; return new File(["wav"], "clip.wav", { type: "audio/wav" }); },
{ prepareAudio: async () => new Float32Array(16000), classify: async () => [{ class: "Fireworks", score: .9 }] },
);
processor.setEnabled(true);
await processor.prepare(file);
assert.equal(calls, 0);
const video = { type: "video/mp4", size: 123, name: "clip.mp4" };
const result = await processor.prepare(video);
assert.equal(calls, 1);
assert.equal(result.file.type, "audio/wav");
assert.equal(result.metadata.browser_processing_used, true);
const disabled = new BrowserSubmissionProcessor({ browserProcessingBeta: false }, async () => { throw new Error("must not run"); });
assert.deepEqual(await disabled.prepare(video), { file: video, metadata: null, gate: "unavailable" });
} finally {
globalThis.fetch = originalFetch;
}
});
test("video conversion failure rejects instead of falling back to original video", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => ({ ok: true, json: async () => ({ browser_processing_beta_enabled: true, version: 1 }) });
try {
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 },
async () => { throw new Error("decode failed"); },
);
processor.setEnabled(true);
await assert.rejects(processor.prepare({ type: "video/mp4", name: "bad.mp4" }), /decode failed/);
} finally {
globalThis.fetch = originalFetch;
}
});
test("admin ON and user toggle OFF bypasses policy, FFmpeg and TensorFlow", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = () => { throw new Error("policy must not load"); };
const audio = new File(["audio"], "clip.wav", { type: "audio/wav" });
const processor = new BrowserSubmissionProcessor(
{ browserProcessingBeta: true, policyUrl: "/policy", policyVersion: 1 },
async () => { throw new Error("FFmpeg must not load"); },
{ prepareAudio: async () => { throw new Error("audio preparation must not run"); },
classify: async () => { throw new Error("TensorFlow must not load"); } },
);
try {
assert.equal(processor.isAvailable(), true);
assert.equal(processor.isEnabled(), false);
assert.deepEqual(await processor.process(audio), { file: audio, metadata: null, gate: "unavailable" });
processor.setEnabled(true);
assert.equal(processor.isEnabled(), true);
processor.setEnabled(false);
assert.equal(processor.isEnabled(), false);
assert.deepEqual(await processor.process(audio), { file: audio, metadata: null, gate: "unavailable" });
} finally { globalThis.fetch = originalFetch; }
});
@@ -0,0 +1,45 @@
import assert from "node:assert/strict";
import test from "node:test";
import { BrowserYamnetClassifier } from "../src/scripts/browser-yamnet-classifier.js";
test("YAMNet peak scores are mapped and all owned resources are disposed", async () => {
const originalFetch = globalThis.fetch;
const disposed = [];
const values = new Float32Array(2 * 521);
values[0] = .4;
values[521] = .9;
const output = { shape: [2, 521], data: async () => values, dispose: () => disposed.push("output") };
const model = { executeAsync: async () => [output], dispose: () => disposed.push("model") };
const tf = {
ready: async () => {}, getBackend: () => "cpu", memory: () => ({ numTensors: 0 }),
loadGraphModel: async () => model,
tensor1d: () => ({ dispose: () => disposed.push("input") }),
};
globalThis.fetch = async () => ({ ok: true, json: async () => ["Fireworks", ...Array(520).fill("Other")] });
try {
const predictions = await BrowserYamnetClassifier.classify(new Float32Array(16000), {
modelUrl: "/static/browser-yamnet/model.json", classMapUrl: "/static/browser-yamnet/yamnet_class_map.json",
loadTensorFlow: async () => tf,
});
assert.equal(predictions[0].class, "Fireworks");
assert.equal(predictions[0].score, values[521]);
assert.equal(predictions[0].timeSeconds, .48);
assert.deepEqual(disposed, ["input", "output", "model"]);
} finally { globalThis.fetch = originalFetch; }
});
test("model failure still disposes the loaded model", async () => {
const originalFetch = globalThis.fetch;
let disposed = false;
const tf = {
ready: async () => {}, getBackend: () => "cpu", memory: () => ({ numTensors: 0 }),
loadGraphModel: async () => ({ dispose: () => { disposed = true; } }),
};
globalThis.fetch = async () => ({ ok: false });
try {
await assert.rejects(BrowserYamnetClassifier.classify(new Float32Array(16000), {
modelUrl: "/model.json", classMapUrl: "/map.json", loadTensorFlow: async () => tf,
}));
assert.equal(disposed, true);
} finally { globalThis.fetch = originalFetch; }
});
@@ -0,0 +1,38 @@
import assert from "node:assert/strict";
import test from "node:test";
import { extractVideoAudio } from "../src/scripts/ffmpeg-video-extractor.js";
function mockRuntime(exitCode = 0) {
const calls = [];
const ffmpeg = {
loaded: false,
on: () => {},
load: async () => { calls.push("load"); ffmpeg.loaded = true; },
writeFile: async () => { calls.push("write"); },
exec: async (args) => { calls.push(args); return exitCode; },
readFile: async () => { calls.push("read"); return new Uint8Array([82, 73, 70, 70]); },
deleteFile: async (path) => { calls.push(`delete:${path}`); },
terminate: () => { calls.push("terminate"); ffmpeg.loaded = false; },
};
return { ffmpeg, calls };
}
const video = new File(["video"], "clip.mp4", { type: "video/mp4" });
test("successful extraction emits WAV and cleans up virtual files and worker", async () => {
const runtime = mockRuntime();
const wav = await extractVideoAudio(video, { createFFmpeg: async () => runtime });
assert.equal(wav.type, "audio/wav");
assert.equal(wav.name, "clip.wav");
assert.deepEqual(runtime.calls.find(Array.isArray), ["-i", "input", "-vn", "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", "audio.wav"]);
assert.ok(runtime.calls.includes("delete:input"));
assert.ok(runtime.calls.includes("delete:audio.wav"));
assert.equal(runtime.calls.at(-1), "terminate");
});
test("failed extraction removes input and terminates worker", async () => {
const runtime = mockRuntime(1);
await assert.rejects(extractVideoAudio(video, { createFFmpeg: async () => runtime }), { code: "invalid_media" });
assert.ok(runtime.calls.includes("delete:input"));
assert.equal(runtime.calls.at(-1), "terminate");
});
+60
View File
@@ -0,0 +1,60 @@
import assert from "node:assert/strict";
import test from "node:test";
import { JSDOM } from "jsdom";
test("compass stays hidden until permission and a heading, then rotates and hides when stopped", async () => {
const dom = new JSDOM(`<!doctype html><html><body>
<form id="manual-report-form" action="/submit">
<input id="manual-latitude"><input id="manual-longitude">
<input id="manual-direction-degrees"><input id="manual-direction-accuracy">
<div id="manual-direction-panel" hidden><button id="manual-capture-direction" type="button"></button><div id="manual-direction-status"></div></div>
<button id="manual-submit" type="button"></button>
<button id="burst-start" type="button"></button><div id="burst-panel"></div><strong id="burst-heading"></strong>
<div id="burst-detail"></div><canvas id="burst-waveform"></canvas><audio id="burst-preview"></audio>
<button id="burst-resume" type="button"></button><button id="burst-discard" type="button"></button>
<button id="burst-stop" type="button"></button><p id="burst-error"></p>
</form>
<div id="manual-submission"></div>
<div id="manual-compass" hidden><div id="manual-compass-rose"></div><span id="manual-compass-heading"></span></div>
</body></html>`, { url: "https://example.test/" });
const { window } = dom;
Object.defineProperty(window, "isSecureContext", { value: true });
let resolvePermission;
class MockOrientation {}
MockOrientation.requestPermission = () => new Promise((resolve) => { resolvePermission = resolve; });
window.DeviceOrientationEvent = MockOrientation;
const previous = Object.fromEntries(["window", "document", "navigator", "DeviceOrientationEvent"].map((key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)]));
for (const [key, value] of Object.entries({ window, document: window.document, navigator: window.navigator, DeviceOrientationEvent: MockOrientation })) {
Object.defineProperty(globalThis, key, { configurable: true, writable: true, value });
}
try {
await import("../src/scripts/manual-report.js?compass=visual");
const compass = window.document.querySelector("#manual-compass");
const rose = window.document.querySelector("#manual-compass-rose");
const button = window.document.querySelector("#manual-capture-direction");
assert.equal(compass.hidden, true);
button.click();
assert.equal(compass.hidden, true);
resolvePermission("granted");
await new Promise((resolve) => setTimeout(resolve, 0));
const reading = (heading) => {
const event = new window.Event("deviceorientation");
Object.defineProperty(event, "webkitCompassHeading", { value: heading });
window.dispatchEvent(event);
};
reading(359);
assert.equal(compass.hidden, false);
assert.equal(rose.style.transform, "rotate(-359deg)");
reading(1);
assert.equal(rose.style.transform, "rotate(-361deg)");
assert.equal(window.document.querySelector("#manual-direction-degrees").value, "1");
button.click();
assert.equal(compass.hidden, true);
} finally {
for (const [key, descriptor] of Object.entries(previous)) {
if (descriptor === undefined) delete globalThis[key];
else Object.defineProperty(globalThis, key, descriptor);
}
dom.window.close();
}
});