Add another writer to a run

This commit is contained in:
gator 2026-09-20 04:52:37 +00:00
parent 1edeec9b71
commit 31bb7fbfcc

View file

@ -338,6 +338,23 @@
return bits.join(" · ");
}
// One more writer on this run: same book, same notes, nobody else pays again.
var ALLWRITERS = null;
function addWriterHtml() {
if (!ALLWRITERS) {
ALLWRITERS = [];
api("camera_presets", {}).then(function (r) {
ALLWRITERS = (r && r.writers) || []; if (ALLWRITERS.length) paintTabs(); });
return "";
}
var have = {}; DRAFTS.forEach(function (d) { have[d.writer] = 1; });
var free = ALLWRITERS.filter(function (w) { return !have[w.id]; });
if (!free.length) return "";
return '<span style="margin-left:10px;white-space:nowrap"><select id="addwsel" style="font-size:12px">'
+ free.map(function (w) { return '<option value="' + esc(w.id) + '">' + esc(w.label) + '</option>'; }).join("")
+ '</select> <button type="button" class="btn" data-addwriter="1" style="font-size:12px">+ add this writer &middot; about $1</button></span>';
}
function paintTabs() {
document.getElementById("tabs").innerHTML = DRAFTS.map(function (d) {
var s = String(d.draw_state || "");
@ -352,10 +369,20 @@
+ esc(d.label || d.writer)
+ (Number(d.iteration) > 1 ? ' v' + d.iteration : '')
+ (d.writer === RUN.lead_writer ? ' ★' : '') + extra + '</button>';
}).join("");
}).join("") + addWriterHtml();
}
document.getElementById("tabs").addEventListener("click", function (e) {
var addb = e.target.closest ? e.target.closest("[data-addwriter]") : null;
if (addb) {
var aw = document.getElementById("addwsel");
addb.disabled = true;
api("add_writer", { run_id: runId, writer: aw ? aw.value : "" }).then(function (r) {
if (r && r.ok) { showMsg("msg", "That writer is reading the book now. Its script appears as a new tab in a few minutes.", "ok"); load(); }
else { showMsg("msg", (r && r.error) || "That writer could not be added."); addb.disabled = false; }
});
return;
}
var id = e.target.closest ? e.target.closest(".tab") : null;
if (!id) return;
CUR = id.getAttribute("data-tab"); EDITING = null;
@ -419,7 +446,7 @@
return '<li>' + esc(b.what || "")
+ (b.is_ending ? ' <b>(the ending)</b>' : '')
+ (b.why_it_matters ? ' <span class="kv">' + esc(b.why_it_matters) + '</span>' : '')
+ '</li>'; }).join("");
+ '</li>'; }).join("") + addWriterHtml();
return '<div class="spine"><h4>The story, as the writer worked it out from the book</h4>'
+ (sp.the_engine ? '<p class="eng">' + esc(sp.the_engine) + '</p>' : '')
@ -1537,6 +1564,13 @@
+ "automatically. This takes a few minutes." : (r.note || "Already checked."), "ok"); await refresh(); }
return;
}
if ((el = hit("data-addwriter"))) {
var aw = document.getElementById("addwsel");
el.disabled = true;
r = await act("add_writer", { run_id: runId, writer: aw ? aw.value : "" });
if (r) { showMsg("msg", "That writer is reading the book now. Its script appears as a new tab in a few minutes.", "ok"); await load(); }
return;
}
if ((el = hit("data-lineset"))) {
var lk = el.getAttribute("data-lineset"), lp = lk.split("|");
var lin = document.querySelector('[data-linetext="' + lk + '"]');