Grey zones: do not trust the data there (they are kept, not removed). Hover a bar for details; zoom the curves +
Grey zones: do not trust the data there (they are kept, not removed). Hover a bar for details, ▶ Images to see the camera; zoom the curves with the wheel or by dragging, double-click for the whole period.
+Nothing to report on this period.
'; } document.getElementById("j-list").addEventListener("click", ev => { const el = ev.target.closest("[data-n]"); if (!el) return; + if (ev.target.closest("button")) return openTimelapse(J[+el.dataset.n]); const e = J[+el.dataset.n], a = Date.parse(e.start), b = Date.parse(e.end), m = Math.max((b - a) / 2, 2 * 3600e3); // marge Plotly.relayout("j-curves", { "xaxis.range": [plotT(a - m), plotT(b + m)] }); }); +// Bouton ▶ Images (point 7 du plan) : le timelapse des images de l'événement, encadré d'une marge avant et après où tout +// va bien, pour que le client voie tout de suite qu'on ne distinguait plus les cibles. Recadré sur les cibles (D.view, +// comme le zoom « Targets » de View), en boucle ; pas de fichier GIF, tout est joué ici. +const J_MARGIN = [3600e3, 6 * 3600e3], J_FPS = 4, J_MAX = 60; // marge : la moitié de la durée, de 1 h à 6 h ; à régler à l'œil +function jFrames(ev) { // images de la plage, une sur n au-delà de J_MAX, avec leur rôle : avant, pendant ou après + const a = Date.parse(ev.start), b = Date.parse(ev.end), m = Math.min(J_MARGIN[1], Math.max(J_MARGIN[0], (b - a) / 2)); + const ims = IM.filter(im => Date.parse(im.t) >= a - m && Date.parse(im.t) <= b + m), n = Math.ceil(ims.length / J_MAX); + return ims.filter((_, k) => k % n === 0).map(im => ({ ...im, + role: Date.parse(im.t) < a ? "before" : Date.parse(im.t) > b ? "after" : "during" })); +} +const jv = document.getElementById("j-video"), jvCanvas = jv.querySelector("canvas"), jvInfo = jv.querySelector(".bar span"); +const jvPause = jv.querySelector('[data-v="p"]'), ROLE = { before: "Before", during: "During", after: "After" }; +let JV = { frames: [], imgs: [], k: 0, run: 0, playing: false }; +function jvShow(k) { // affiche l'image k une fois décodée + JV.k = (k + JV.frames.length) % JV.frames.length; + const f = JV.frames[JV.k], img = JV.imgs[JV.k]; + return img.decode().catch(() => {}).then(() => { + if (!img.naturalWidth) return; + const v = D.view || { x: [0, img.naturalWidth], y: [0, img.naturalHeight] }; + const x0 = Math.max(0, v.x[0]), y0 = Math.max(0, v.y[0]); + const w = Math.min(img.naturalWidth, v.x[1]) - x0, h = Math.min(img.naturalHeight, v.y[1]) - y0; + jvCanvas.width = w; jvCanvas.height = h; + jvCanvas.getContext("2d").drawImage(img, x0, y0, w, h, 0, 0, w, h); + jvCanvas.className = f.role === "during" ? "during" : ""; + jvInfo.textContent = `${utc(f.t)} · ${ROLE[f.role]} · ${JV.k + 1} / ${JV.frames.length}`; + }); +} +function jvPlay(on) { // lecture en boucle, l'image suivante une fois la précédente affichée + JV.playing = on; + const me = ++JV.run; + jvPause.textContent = on ? "❚❚ Pause" : "▶ Play"; + const step = () => { if (me === JV.run) jvShow(JV.k + 1).then(() => setTimeout(step, 1000 / J_FPS)); }; + if (on) setTimeout(step, 1000 / J_FPS); +} +function openTimelapse(ev, k = 0, on = true) { + JV.frames = jFrames(ev); + if (!JV.frames.length) return; + JV.imgs = JV.frames.map(f => Object.assign(new Image(), { src: f.src })); // chargées d'avance + jv.hidden = false; + jvShow(k).then(() => jvPlay(on)); +} +function closeTimelapse() { jvPlay(false); jv.hidden = true; } +jv.addEventListener("click", ev => { + if (ev.target === jv) return closeTimelapse(); // clic à côté de la fenêtre + const b = ev.target.closest("button"); + if (!b) return; + if (b.dataset.v === "x") closeTimelapse(); + else if (b.dataset.v === "p") jvPlay(!JV.playing); + else { jvPlay(false); jvShow(JV.k + +b.dataset.v); } // image par image +}); +document.addEventListener("keydown", ev => { if (ev.key === "Escape" && !jv.hidden) closeTimelapse(); }); + drawJournal(); +if (J[ASKED.get("play")]) openTimelapse(J[ASKED.get("play")], +ASKED.get("frame") || 0, !ASKED.has("frame")); // #play=n&frame=k : captures