194 lines
14 KiB
HTML
194 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Welkom · Sound Signal</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
|
|
<style>
|
|
: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; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
{% if user.is_authenticated %}<a class="profile-circle" href="{% url 'user_settings' %}" aria-label="Open settings for {{ user.get_username }}" title="Settings">{{ user.get_username|first|upper }}</a>{% endif %}
|
|
<div style="width:min(100%,80rem);display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,20rem),1fr));gap:1.25rem;align-items:stretch;">
|
|
<main class="welcome-card" style="width:100%;">
|
|
<div class="brand"><span class="brand-mark">✦</span> Sound Signal</div>
|
|
<p class="eyebrow">Control room</p>
|
|
<h1>Welkom {{ naam }}</h1>
|
|
<p class="subject"><span class="sparkle">✦</span> Je leert <strong>{{ vak }}</strong>. Explore the prototype for live audio classification and future sensor mapping.</p>
|
|
<div class="actions">
|
|
<a href="{% url 'fireworks_detect:fireworks' %}" class="button">Open vuurwerk detector <span aria-hidden="true">→</span></a>
|
|
<a href="{% url 'fireworks_detect:map' %}" class="button">Open kaart concept <span aria-hidden="true">→</span></a>
|
|
<a href="{% url 'member_create' %}" class="button">Open formulier <span aria-hidden="true">→</span></a>
|
|
<a href="{% url 'fireworks_detect:events' %}" class="button">Open gebeurtenissen <span aria-hidden="true">→</span></a>
|
|
<span class="hint">Audio analysis · Sensor map</span>
|
|
</div>
|
|
</main>
|
|
<section aria-labelledby="manual-report-title" style="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;">
|
|
<p class="eyebrow">No recording needed</p>
|
|
<h2 id="manual-report-title" style="margin:.2rem 0 .75rem;font-size:clamp(2rem,4vw,3.1rem);line-height:1;letter-spacing:-.06em;">Report fireworks now</h2>
|
|
<p style="margin:0 0 1.5rem;color:#f3c8a3;line-height:1.55;">Choose how many times you heard fireworks, then send it straight to Pending. The report is timestamped now.</p>
|
|
<form id="manual-report-form" action="{% url 'fireworks_detect:submit_manual_pending' %}" method="post" hx-post="{% url 'fireworks_detect:submit_manual_pending' %}" hx-target="#manual-submission" hx-swap="outerHTML">
|
|
{% csrf_token %}
|
|
<label for="manual-occurrences" style="display:block;margin-bottom:.5rem;font-weight:800;">Number of occurrences</label>
|
|
<input id="manual-latitude" name="latitude" type="hidden">
|
|
<input id="manual-longitude" name="longitude" type="hidden">
|
|
<input id="manual-direction-degrees" name="direction_degrees" type="hidden">
|
|
<input id="manual-direction-accuracy" name="direction_accuracy_degrees" type="hidden">
|
|
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric" style="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;">
|
|
<div id="manual-direction-panel" hidden style="margin:0 0 1rem;padding:1rem;border:1px solid #8d5bb5;border-radius:.75rem;background:#241b38;">
|
|
<strong style="display:block;margin-bottom:.35rem;">Direction <span style="color:#c7b5eb;font-weight:600;">(optional)</span></strong>
|
|
<p style="margin:0 0 .75rem;color:#d4c6ef;font-size:.88rem;line-height:1.45;">Point the top of your phone toward the fireworks, then capture a single compass reading.</p>
|
|
<button id="manual-capture-direction" type="button" style="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;">Capture direction</button>
|
|
<div id="manual-direction-status" style="min-height:1.4rem;margin-top:.7rem;color:#e5dcf7;font-size:.9rem;" aria-live="polite"></div>
|
|
</div>
|
|
<button id="manual-submit" type="button" style="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;">I heard fireworks — send to Pending</button>
|
|
</form>
|
|
<div id="manual-submission" style="min-height:1.5rem;margin-top:1rem;color:#ffd18c;" aria-live="polite"></div>
|
|
</section>
|
|
</div>
|
|
<script>
|
|
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 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;
|
|
|
|
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;
|
|
};
|
|
|
|
const showCapturedDirection = (heading, accuracy) => {
|
|
const accuracyText = accuracy === null ? "Accuracy unavailable" : "Accuracy: ±" + displayDegrees(accuracy) + "°";
|
|
directionStatus.innerHTML = "<strong>" + displayDegrees(heading) + "° · " + cardinalDirection(heading) + "</strong><br>" + accuracyText;
|
|
captureDirectionButton.textContent = "Stop direction capture";
|
|
};
|
|
|
|
const listenForCompassReading = () => {
|
|
stopCompassReading();
|
|
directionStatus.textContent = "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);
|
|
window.clearTimeout(compassUnavailableTimeout);
|
|
};
|
|
window.addEventListener("deviceorientation", orientationListener);
|
|
compassUnavailableTimeout = window.setTimeout(() => {
|
|
stopCompassReading();
|
|
captureDirectionButton.textContent = "Capture direction";
|
|
directionStatus.textContent = "Compass unavailable on this device.";
|
|
}, 15000);
|
|
};
|
|
|
|
const captureDirection = async () => {
|
|
if (orientationListener) {
|
|
stopCompassReading();
|
|
captureDirectionButton.textContent = "Capture again";
|
|
return;
|
|
}
|
|
if (!window.isSecureContext) {
|
|
directionStatus.textContent = "Compass capture requires a secure HTTPS connection.";
|
|
return;
|
|
}
|
|
if (typeof window.DeviceOrientationEvent === "undefined") {
|
|
directionStatus.textContent = "Compass unavailable on this device.";
|
|
return;
|
|
}
|
|
if (typeof DeviceOrientationEvent.requestPermission === "function") {
|
|
directionStatus.textContent = "Requesting compass permission…";
|
|
try {
|
|
if (await DeviceOrientationEvent.requestPermission(true) !== "granted") {
|
|
directionStatus.textContent = "Compass permission denied.";
|
|
return;
|
|
}
|
|
} catch (error) {
|
|
directionStatus.textContent = "Compass permission denied.";
|
|
return;
|
|
}
|
|
}
|
|
listenForCompassReading();
|
|
};
|
|
|
|
const submitManualReport = () => {
|
|
stopCompassReading();
|
|
manualSubmit.disabled = true;
|
|
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 = "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;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|