added scheduling

This commit is contained in:
Joren de Graaf
2026-10-10 16:03:14 +02:00
parent 7559b61399
commit 314eb6b4ec
50 changed files with 768 additions and 67 deletions
+16
View File
@@ -21,6 +21,10 @@
const reportTime = document.querySelector("#manual-report-time");
const reportHours = document.querySelector("#report-clock-hours");
const reportMinutes = document.querySelector("#report-clock-minutes");
const occurredAt = document.querySelector("#manual-occurred-at");
const useNow = document.querySelector("#manual-use-now");
const burstStatus = document.querySelector("#manual-burst-status");
const burstDuration = document.querySelector("#manual-burst-duration");
let orientationListener;
let compassUnavailableTimeout;
let compassRotation = null;
@@ -47,6 +51,11 @@
updateReportTime();
if (reportTime) window.setInterval(updateReportTime, 60000);
const idleSubmitLabel = submitLabel?.textContent || "I heard fireworks";
useNow?.addEventListener("click", () => {
const now = new Date();
const local = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
occurredAt.value = local.toISOString().slice(0, 16);
});
const setSubmissionState = (next, message = "") => {
manualForm.dataset.state = next;
@@ -70,16 +79,23 @@
return successful;
};
const showBurstState = () => {
const burst = Number(occurrences.value) >= 3;
if (burstStatus) burstStatus.textContent = burst ? (t.burstEvent || "Burst Event") : (t.ordinaryReport || "Ordinary report");
if (burstDuration) burstDuration.hidden = !burst;
};
const setCount = (value) => {
const count = Number.parseInt(value, 10);
occurrences.value = String(Math.min(1000, Math.max(1, Number.isFinite(count) ? count : 1)));
decrease.disabled = occurrences.value === "1";
increase.disabled = occurrences.value === "1000";
showBurstState();
};
setCount(occurrences.value);
decrease.addEventListener("click", () => setCount(Number(occurrences.value) - 1));
increase.addEventListener("click", () => setCount(Number(occurrences.value) + 1));
occurrences.addEventListener("change", () => setCount(occurrences.value));
occurrences.addEventListener("input", showBurstState);
const stopCompassReading = () => {
if (orientationListener) window.removeEventListener("deviceorientation", orientationListener);