diff --git a/script.html b/script.html index beed7ca..cbd5f97 100644 --- a/script.html +++ b/script.html @@ -195,6 +195,29 @@ function render(r) { + '
' + ''; + // Filming, from the browser. This was the last step that needed an operator. + var film = ''; + if (p.status === 'approved' || p.status === 'queued_to_film' + || p.status === 'filming' || p.status === 'film_failed') { + var busy = (p.status === 'queued_to_film' || p.status === 'filming'); + film = '

Film it

' + + '
' + + '
' + ((p.segments || 4) * 8) + 's
' + + '
of your time credit
' + + '
checking your balance…
' + + (p.status === 'film_failed' + ? '
That did not finish: ' + esc(p.film_note || 'unknown reason') + + '. Your seconds were returned.
' + : '') + + (busy + ? '

' + esc(p.film_note || 'Queued…') + '

' + : '' + + 'About a minute a shot.') + + '
'; + } + var post = ''; if (p.status === 'ready' || p.cut_url) { post = '

The cut

' @@ -227,6 +250,7 @@ function render(r) { + '

The shots

' + s.segments.map(function (x) { return shotHtml(x, locked); }).join("") + own + + film + post + actions; @@ -343,6 +367,7 @@ function bindPics() { function wire(locked) { bindPics(); + bindFilm((DATA && DATA.project) || {}); bindPost(); if (locked) { bindBottom(); return; } @@ -443,6 +468,43 @@ function wire(locked) { bindBottom(); } +async function bindFilm(p) { + var bal = document.getElementById("balsec"); + if (bal) { + var b = await api("get_balance", { email: email }); + var have = (b.ok && b.balance_seconds) || 0; + var need = (p.segments || 4) * 8; + bal.textContent = have + "s left" + (have < need ? " — not enough" : ""); + if (have < need) bal.style.color = "var(--bad)"; + } + + // While it films, keep the page honest about where it has got to. + if (p.status === "queued_to_film" || p.status === "filming") { + var t = setInterval(async function () { + var g = await api("get_project", { email: email, project_id: pid }); + if (!g.ok) return; + var st = g.project.status; + var note = document.getElementById("filmnote"); + if (note) note.textContent = g.project.film_note || st; + if (st === "ready" || st === "film_failed") { clearInterval(t); load(); } + }, 8000); + } + + var fb = document.getElementById("film"); + if (fb) fb.onclick = async function () { + hideMsg("msg"); + fb.disabled = true; fb.textContent = "Starting…"; + var r = await api("request_render", { email: email, project_id: pid }); + if (!r.ok) { + fb.disabled = false; fb.textContent = "Film it"; + showMsg("msg", r.error || "Could not start filming."); + return; + } + showMsg("msg", r.status_text || "Filming.", "ok"); + load(); + }; +} + function bindPost() { var sb = document.getElementById("seams"); if (sb) sb.onclick = async function () {