Background: shared-set warning, earlier pictures of a place with Use this one

This commit is contained in:
gator 2026-09-24 21:32:50 +00:00
parent 33ab8c30e7
commit 84fd6b257d

View file

@ -1453,6 +1453,13 @@
var body = '<b>Background</b> <span class="tiny">' + esc(st.name || s.scene || key) + (s.place ? ' · set by you' : '') + '</span>'; var body = '<b>Background</b> <span class="tiny">' + esc(st.name || s.scene || key) + (s.place ? ' · set by you' : '') + '</span>';
if (st.error) body += '<div class="warn">' + esc(st.error) + '</div>'; if (st.error) body += '<div class="warn">' + esc(st.error) + '</div>';
if (editing) { if (editing) {
var sharers = (PKG.shots || []).filter(function (x) { return x.id !== s.id && placeOf(x) === key && (x.opening_url || x.clip_url); });
if (url && sharers.length) body += '<div class="tiny" style="margin:4px 0">Shots ' + esc(sharers.map(function (x) { return x.id; }).join(", "))
+ ' already use this picture and keep it. Generating here gives shot ' + esc(s.id) + ' a background of its own.</div>';
var hist = (st.history || []).slice().reverse();
if (hist.length) body += '<div class="tiny" style="margin:6px 0 2px">Earlier pictures of this place:</div><div class="bghist">'
+ hist.map(function (h) { return '<span style="display:inline-block;margin:0 6px 6px 0;text-align:center"><img src="' + esc(h.ref_url) + '" data-zoom="' + esc(h.description || "") + '" alt="" style="width:120px;display:block">'
+ '<button type="button" class="btn small" data-bgrestore="' + esc(s.id) + '|' + esc(h.ref_url) + '">Use this one</button></span>'; }).join("") + '</div>';
body += '<textarea data-bgdesc="' + esc(s.id) + '" placeholder="The place with nobody in it: what is there, where the light comes from, the time of day.">' + esc(desc) + '</textarea>' body += '<textarea data-bgdesc="' + esc(s.id) + '" placeholder="The place with nobody in it: what is there, where the light comes from, the time of day.">' + esc(desc) + '</textarea>'
+ '<div class="tools"><button type="button" class="btn small primary" data-bggen="' + esc(s.id) + '">' + (url ? 'Generate it again' : 'Generate background image') + ' &middot; $0.07</button>' + '<div class="tools"><button type="button" class="btn small primary" data-bggen="' + esc(s.id) + '">' + (url ? 'Generate it again' : 'Generate background image') + ' &middot; $0.07</button>'
+ '<button type="button" class="btn small" data-bgcancel="1">Cancel</button></div>'; + '<button type="button" class="btn small" data-bgcancel="1">Cancel</button></div>';
@ -1824,6 +1831,13 @@
} }
if ((el = hit("data-bgedit"))) { BGEDIT = el.getAttribute("data-bgedit"); openTab(CUR); return; } if ((el = hit("data-bgedit"))) { BGEDIT = el.getAttribute("data-bgedit"); openTab(CUR); return; }
if ((el = hit("data-bgcancel"))) { BGEDIT = null; openTab(CUR); return; } if ((el = hit("data-bgcancel"))) { BGEDIT = null; openTab(CUR); return; }
if ((el = hit("data-bgrestore"))) {
var bgr = el.getAttribute("data-bgrestore"), bgi = bgr.indexOf("|");
el.disabled = true;
r = await act("background", { draft_id: CUR, shot_id: bgr.slice(0, bgi), op: "restore", ref_url: bgr.slice(bgi + 1) });
if (r) { BGEDIT = null; showMsg("msg", "The earlier picture is back for every shot in this place. Pictures drawn from the other one are marked to redraw.", "ok"); await refresh(); }
return;
}
if ((el = hit("data-bggen"))) { if ((el = hit("data-bggen"))) {
var sidb = el.getAttribute("data-bggen"), ta = document.querySelector('[data-bgdesc="' + sidb + '"]'); var sidb = el.getAttribute("data-bggen"), ta = document.querySelector('[data-bgdesc="' + sidb + '"]');
el.disabled = true; el.disabled = true;