From 2b611917be1da4408d5b98806a09585b71d4b5f1 Mon Sep 17 00:00:00 2001 From: gator Date: Mon, 7 Sep 2026 01:17:42 +0000 Subject: [PATCH] Poll for the seam report now that measuring runs in the background --- script.html | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/script.html b/script.html index cbd5f97..7bddb0a 100644 --- a/script.html +++ b/script.html @@ -507,12 +507,54 @@ async function bindFilm(p) { function bindPost() { var sb = document.getElementById("seams"); + function paintSeams(r) { + var el = document.getElementById("seamout"); + if (!el) return; + el.innerHTML = '

' + esc(r.status_text || "") + '

' + + (r.seams || []).map(function (x) { + var col = x.verdict === "smooth" ? "var(--good)" + : (x.verdict === "visible" ? "var(--accent2)" : "var(--bad)"); + return '
' + + 'shot ' + x.after_shot + ' → ' + x.before_shot + ' at ' + x.at_seconds + 's · ' + + 'shift ' + x.shift_x + ',' + x.shift_y + ' · drift ' + x.drift + ' · ' + + '' + esc(x.verdict) + '' + + (x.recommend_broll ? ' · worth a cutaway' : '') + + '
'; + }).join(""); + } + if (sb) sb.onclick = async function () { sb.disabled = true; sb.textContent = "Measuring…"; - var r = await api("seam_report", { email: email, project_id: pid }); - sb.disabled = false; sb.textContent = "Measure the joins"; var el = document.getElementById("seamout"); - if (!r.ok) { showMsg("msg", r.error || "Could not measure."); return; } + var r = await api("seam_report", { email: email, project_id: pid }); + if (!r.ok) { + sb.disabled = false; sb.textContent = "Measure the joins"; + showMsg("msg", r.error || "Could not measure."); + return; + } + // Measuring downloads every shot and searches each join for the best + // alignment, which is far too slow to answer inside one request. + if (r.pending) { + el.innerHTML = '

' + esc(r.status_text || "Measuring…") + '

'; + var waited = 0; + var t = setInterval(async function () { + waited += 4; + var g = await api("seam_report", { email: email, project_id: pid }); + if (g.ok && !g.pending) { + clearInterval(t); + sb.disabled = false; sb.textContent = "Measure the joins"; + paintSeams(g); + return; + } + if (waited > 180) { + clearInterval(t); + sb.disabled = false; sb.textContent = "Measure the joins"; + showMsg("msg", "Measuring is taking unusually long."); + } + }, 4000); + return; + } + sb.disabled = false; sb.textContent = "Measure the joins"; if (!r.seams || !r.seams.length) { el.innerHTML = '

' + esc(r.status_text || "Nothing to measure.") + '

'; return;