Algorick commited on
Commit
ac35f84
·
verified ·
1 Parent(s): 9784e1d

406bbf1ad427

Browse files
Files changed (5) hide show
  1. web/app.js +37 -5
  2. web/i18n/en.json +5 -1
  3. web/index.html +1 -0
  4. web/mobile.js +55 -6
  5. web/style.css +11 -2
web/app.js CHANGED
@@ -207,7 +207,12 @@ function renderModels() {
207
  "aria-checked": String(state.model === o.key),
208
  "aria-disabled": String(!supported),
209
  title: supported ? "" : "Le modifiche a comando le fa solo FLUX.2 Klein",
210
- onclick: () => { if (supported) { state.model = o.key; syncAll(); } },
 
 
 
 
 
211
  }, [
212
  el("span", { class: "model-name" }, [o.nome, ...(o.note ? [el("small", { text: o.note })] : [])]),
213
  el("span", { class: "model-desc", text: o.descrizione }),
@@ -1420,10 +1425,11 @@ async function purgeFiles(trashFiles, all = false) {
1420
 
1421
  /* ---------- conferma a tema ---------- */
1422
 
1423
- function confirmDialog({ title, text, confirm = "Conferma", danger = false }) {
1424
  const dlg = $("#confirm");
1425
  $("#confirm-title").textContent = title;
1426
  $("#confirm-text").textContent = text;
 
1427
  const yes = $("#confirm-yes");
1428
  yes.textContent = confirm;
1429
  yes.classList.toggle("danger", danger);
@@ -1434,6 +1440,21 @@ function confirmDialog({ title, text, confirm = "Conferma", danger = false }) {
1434
  return new Promise((resolve) => dlg.addEventListener("close", () => resolve(dlg.returnValue === "si"), { once: true }));
1435
  }
1436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1437
  /* ---------- scheda dettaglio ---------- */
1438
 
1439
  const detailItem = () => galleryVisible()[g.detailIndex];
@@ -1493,8 +1514,10 @@ function infoRows(item) {
1493
  ];
1494
  }
1495
 
 
1496
  function showInfo(item = state.current) {
1497
  if (!item) return;
 
1498
  $("#info-prompt").textContent = item.prompt_finale || item.prompt || titleOf(item);
1499
  $("#info-list").replaceChildren(...infoRows(item).flatMap(([k, v]) => [el("dt", { text: k }), el("dd", { text: v })]));
1500
  $("#info-reuse").disabled = isFixed(item);
@@ -1959,8 +1982,17 @@ function wire() {
1959
  $("#act-restyle").addEventListener("click", () => state.current && useAsRef(state.current, "ristila"));
1960
  $("#act-reuse").addEventListener("click", () => reuse());
1961
  $("#act-info").addEventListener("click", () => showInfo());
1962
- $("#info-copy").addEventListener("click", () => { $("#act-copy").click(); $("#info-dlg").close(); });
1963
- $("#info-reuse").addEventListener("click", () => { $("#info-dlg").close(); reuse(); });
 
 
 
 
 
 
 
 
 
1964
  $("#act-upscale").addEventListener("click", () => runTool(state.current, "ingrandisci"));
1965
  $("#act-cutout").addEventListener("click", () => runTool(state.current, "scontorna"));
1966
  $("#act-poster").addEventListener("click", () => openInPoster(state.current));
@@ -2115,6 +2147,6 @@ async function boot() {
2115
  setInterval(refreshStatus, 10000);
2116
  }
2117
 
2118
- window.PixRick = { api, toast, el, icon, radio, prefs, mediaUrl, outputUrl, confirmDialog, setView, refreshDraftCount, showInfo };
2119
 
2120
  init();
 
207
  "aria-checked": String(state.model === o.key),
208
  "aria-disabled": String(!supported),
209
  title: supported ? "" : "Le modifiche a comando le fa solo FLUX.2 Klein",
210
+ onclick: () => {
211
+ if (!supported) return;
212
+ state.model = o.key;
213
+ syncAll();
214
+ if (state.mode === "ristila" && o.key === "z-image") warnBlindModel();
215
+ },
216
  }, [
217
  el("span", { class: "model-name" }, [o.nome, ...(o.note ? [el("small", { text: o.note })] : [])]),
218
  el("span", { class: "model-desc", text: o.descrizione }),
 
1425
 
1426
  /* ---------- conferma a tema ---------- */
1427
 
1428
+ function confirmDialog({ title, text, confirm = "Conferma", cancel = "Annulla", danger = false }) {
1429
  const dlg = $("#confirm");
1430
  $("#confirm-title").textContent = title;
1431
  $("#confirm-text").textContent = text;
1432
+ $("#confirm-no").textContent = cancel;
1433
  const yes = $("#confirm-yes");
1434
  yes.textContent = confirm;
1435
  yes.classList.toggle("danger", danger);
 
1440
  return new Promise((resolve) => dlg.addEventListener("close", () => resolve(dlg.returnValue === "si"), { once: true }));
1441
  }
1442
 
1443
+ async function warnBlindModel() {
1444
+ const keep = await confirmDialog({
1445
+ title: "Z-Image non vede la foto",
1446
+ text: "Ne prende colori e composizione, ma non capisce chi o cosa c'è. Scrivi nel prompt i dettagli che contano, per esempio «uomo con barba lunga, maglietta nera e chitarra rossa». Klein invece capisce la foto da solo.",
1447
+ confirm: "Uso Z-Image",
1448
+ cancel: "Torna a Klein",
1449
+ });
1450
+ if (!keep) {
1451
+ state.model = "auto";
1452
+ syncAll();
1453
+ return;
1454
+ }
1455
+ $("#prompt").focus();
1456
+ }
1457
+
1458
  /* ---------- scheda dettaglio ---------- */
1459
 
1460
  const detailItem = () => galleryVisible()[g.detailIndex];
 
1514
  ];
1515
  }
1516
 
1517
+ let infoItem = null;
1518
  function showInfo(item = state.current) {
1519
  if (!item) return;
1520
+ infoItem = item;
1521
  $("#info-prompt").textContent = item.prompt_finale || item.prompt || titleOf(item);
1522
  $("#info-list").replaceChildren(...infoRows(item).flatMap(([k, v]) => [el("dt", { text: k }), el("dd", { text: v })]));
1523
  $("#info-reuse").disabled = isFixed(item);
 
1982
  $("#act-restyle").addEventListener("click", () => state.current && useAsRef(state.current, "ristila"));
1983
  $("#act-reuse").addEventListener("click", () => reuse());
1984
  $("#act-info").addEventListener("click", () => showInfo());
1985
+ $("#info-copy").addEventListener("click", async () => {
1986
+ if (!infoItem) return;
1987
+ await navigator.clipboard.writeText(infoItem.prompt_finale || infoItem.prompt || "");
1988
+ $("#info-dlg").close();
1989
+ toast("Prompt completo copiato");
1990
+ });
1991
+ $("#info-reuse").addEventListener("click", () => {
1992
+ $("#info-dlg").close();
1993
+ if ($("#detail").open) $("#detail").close();
1994
+ reuse(infoItem);
1995
+ });
1996
  $("#act-upscale").addEventListener("click", () => runTool(state.current, "ingrandisci"));
1997
  $("#act-cutout").addEventListener("click", () => runTool(state.current, "scontorna"));
1998
  $("#act-poster").addEventListener("click", () => openInPoster(state.current));
 
2147
  setInterval(refreshStatus, 10000);
2148
  }
2149
 
2150
+ window.PixRick = { api, toast, el, icon, radio, prefs, mediaUrl, outputUrl, confirmDialog, setView, refreshDraftCount, showInfo, detailItem: () => detailItem() };
2151
 
2152
  init();
web/i18n/en.json CHANGED
@@ -655,5 +655,9 @@
655
  "Zona e impostazioni": "Area and settings",
656
  "Dipingi una zona": "Paint an area",
657
  "Scegli uno stile a destra. Se vuoi, aggiungi cosa cambiare: «di notte», «sotto la neve», «con un sorriso».": "Pick a style on the right. If you like, add what to change: «at night», «in the snow», «smiling».",
658
- "Scegli uno stile in «Stile e impostazioni». Se vuoi, aggiungi cosa cambiare: «di notte», «sotto la neve», «con un sorriso».": "Pick a style in «Style and settings». If you like, add what to change: «at night», «in the snow», «smiling»."
 
 
 
 
659
  }
 
655
  "Zona e impostazioni": "Area and settings",
656
  "Dipingi una zona": "Paint an area",
657
  "Scegli uno stile a destra. Se vuoi, aggiungi cosa cambiare: «di notte», «sotto la neve», «con un sorriso».": "Pick a style on the right. If you like, add what to change: «at night», «in the snow», «smiling».",
658
+ "Scegli uno stile in «Stile e impostazioni». Se vuoi, aggiungi cosa cambiare: «di notte», «sotto la neve», «con un sorriso».": "Pick a style in «Style and settings». If you like, add what to change: «at night», «in the snow», «smiling».",
659
+ "Z-Image non vede la foto": "Z-Image can't see the photo",
660
+ "Ne prende colori e composizione, ma non capisce chi o cosa c'è. Scrivi nel prompt i dettagli che contano, per esempio «uomo con barba lunga, maglietta nera e chitarra rossa». Klein invece capisce la foto da solo.": "It takes colours and composition, but doesn't understand who or what is in it. Write the details that matter in the prompt, for example «man with a long beard, black t-shirt and red guitar». Klein understands the photo on its own.",
661
+ "Uso Z-Image": "Use Z-Image",
662
+ "Torna a Klein": "Back to Klein"
663
  }
web/index.html CHANGED
@@ -575,6 +575,7 @@
575
  <button type="button" class="detail-btn primary" id="d-keep" data-scope="bozze"><svg><use href="#i-check"/></svg>Salva in galleria</button>
576
  <button type="button" class="detail-btn primary" id="d-open" data-scope="galleria"><svg><use href="#i-image"/></svg>Apri nello Studio</button>
577
  <button type="button" class="detail-btn" id="d-open-draft" data-scope="bozze"><svg><use href="#i-image"/></svg>Nello Studio</button>
 
578
  <button type="button" class="detail-btn" id="d-edit"><svg><use href="#i-wand"/></svg>Modifica</button>
579
  <button type="button" class="detail-btn" id="d-restyle"><svg><use href="#i-palette"/></svg>Ristila</button>
580
  <button type="button" class="detail-btn" id="d-variant"><svg><use href="#i-shuffle"/></svg>Varia</button>
 
575
  <button type="button" class="detail-btn primary" id="d-keep" data-scope="bozze"><svg><use href="#i-check"/></svg>Salva in galleria</button>
576
  <button type="button" class="detail-btn primary" id="d-open" data-scope="galleria"><svg><use href="#i-image"/></svg>Apri nello Studio</button>
577
  <button type="button" class="detail-btn" id="d-open-draft" data-scope="bozze"><svg><use href="#i-image"/></svg>Nello Studio</button>
578
+ <button type="button" class="detail-btn more-btn" id="d-more" aria-haspopup="dialog"><svg><use href="#i-more"/></svg><span>Altro</span></button>
579
  <button type="button" class="detail-btn" id="d-edit"><svg><use href="#i-wand"/></svg>Modifica</button>
580
  <button type="button" class="detail-btn" id="d-restyle"><svg><use href="#i-palette"/></svg>Ristila</button>
581
  <button type="button" class="detail-btn" id="d-variant"><svg><use href="#i-shuffle"/></svg>Varia</button>
web/mobile.js CHANGED
@@ -178,26 +178,57 @@
178
  ["act-trash", "i-trash", null, null, "danger"],
179
  ];
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  const moreDlg = $("#more-dlg");
182
- function openMore() {
 
 
 
 
 
 
 
 
183
  const items = [];
184
- for (const entry of ACTIONS) {
185
  if (!entry) {
186
  if (items.length && !items.at(-1).classList.contains("action-sep")) items.push(el("span", { class: "action-sep", "aria-hidden": "true" }));
187
  continue;
188
  }
189
  const [id, ico, label, note, tone] = entry;
190
- const target = document.getElementById(id);
191
  if (!target || target.hidden || target.disabled) continue;
192
- const text = label || target.querySelector("span")?.textContent.trim() || target.title || target.getAttribute("aria-label");
 
 
193
  const children = [icon(ico), el("b", { text })];
194
  if (note) children.push(el("small", { text: note }));
195
  const item = target.tagName === "A"
196
  ? el("a", { class: "action-item", href: target.href, download: target.download || "" }, children)
197
  : el("button", { type: "button", class: `action-item${tone ? ` ${tone}` : ""}` }, children);
198
  item.addEventListener("click", () => {
199
- moreDlg.close();
200
- if (target.tagName !== "A") requestAnimationFrame(() => target.click());
201
  });
202
  items.push(item);
203
  }
@@ -205,6 +236,24 @@
205
  $("#more-list").replaceChildren(...items);
206
  moreDlg.showModal();
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  $("#act-more").addEventListener("click", openMore);
209
  $("#shot-img").addEventListener("click", (e) => {
210
  if (!phone.matches) return;
 
178
  ["act-trash", "i-trash", null, null, "danger"],
179
  ];
180
 
181
+ const DETAIL_ACTIONS = [
182
+ ["d-edit", "i-wand", "Modifica", "Cambiala a comando, anche solo in una zona"],
183
+ ["d-restyle", "i-palette", "Ristila", "Stessa composizione, stile diverso"],
184
+ ["d-variant", "i-shuffle", "Varia", "Stesse impostazioni, risultato nuovo"],
185
+ ["d-story", "i-book", "Continua la storia", "Nuova scena con gli stessi personaggi"],
186
+ ["d-refine", "i-sparkle", "Rifinisci con Z-Image", "Più dettaglio e realismo, vedi prima e dopo"],
187
+ ["d-upscale", "i-expand", "Ingrandisci ×2", "Raddoppia la risoluzione"],
188
+ ["d-cutout", "i-scissors", "Scontorna", "Toglie lo sfondo e lascia il soggetto"],
189
+ ["d-vector", "i-vector", "Vettorizza in SVG", "Per stampa, taglio e loghi"],
190
+ ["d-poster", "i-poster", "Usa per una locandina", "Come sfondo, con testi e logo"],
191
+ ["d-views", "i-layers", "Viste 3D", "Lato e retro, per Tripo, Meshy o Hunyuan3D"],
192
+ ["d-style", "i-bookmark", "Salva come stile", "Per rifare immagini con questo aspetto"],
193
+ ["d-fav", "i-star", null, null],
194
+ null,
195
+ ["d-download", "i-download", "Scarica", null],
196
+ ["d-info", "i-info", "Info sull'immagine", "Modello, misura, seme e prompt completo"],
197
+ null,
198
+ ["d-trash", "i-trash", null, null, "danger"],
199
+ ["d-discard", "i-trash", null, null, "danger"],
200
+ ];
201
+
202
  const moreDlg = $("#more-dlg");
203
+ /** Chiude il foglio e poi esegue l'azione, dopo che il tasto indietro ha sistemato la cronologia. */
204
+ function afterClose(dlg, action) {
205
+ let done = false;
206
+ const go = () => { if (!done) { done = true; action(); } };
207
+ window.addEventListener("popstate", () => setTimeout(go, 0), { once: true });
208
+ setTimeout(go, 400);
209
+ dlg.close();
210
+ }
211
+ function openActions(list, run = (target) => target.click()) {
212
  const items = [];
213
+ for (const entry of list) {
214
  if (!entry) {
215
  if (items.length && !items.at(-1).classList.contains("action-sep")) items.push(el("span", { class: "action-sep", "aria-hidden": "true" }));
216
  continue;
217
  }
218
  const [id, ico, label, note, tone] = entry;
219
+ const target = document.getElementById(id) || (id === "d-info" ? { virtual: true } : null);
220
  if (!target || target.hidden || target.disabled) continue;
221
+ if (!target.virtual && target.closest("[hidden]")) continue;
222
+ if (target.dataset?.scope && target.dataset.scope !== $("#detail").dataset.scope) continue;
223
+ const text = label || target.querySelector?.("span")?.textContent.trim() || target.textContent?.trim() || target.title;
224
  const children = [icon(ico), el("b", { text })];
225
  if (note) children.push(el("small", { text: note }));
226
  const item = target.tagName === "A"
227
  ? el("a", { class: "action-item", href: target.href, download: target.download || "" }, children)
228
  : el("button", { type: "button", class: `action-item${tone ? ` ${tone}` : ""}` }, children);
229
  item.addEventListener("click", () => {
230
+ if (target.tagName === "A") { moreDlg.close(); return; }
231
+ afterClose(moreDlg, () => run(target, id));
232
  });
233
  items.push(item);
234
  }
 
236
  $("#more-list").replaceChildren(...items);
237
  moreDlg.showModal();
238
  }
239
+ const openMore = () => openActions(ACTIONS);
240
+ $("#d-more").addEventListener("click", () => openActions(DETAIL_ACTIONS, (target, id) => {
241
+ if (id === "d-info") window.PixRick?.showInfo(window.PixRick.detailItem());
242
+ else target.click();
243
+ }));
244
+
245
+ /* scorrere tra le immagini del dettaglio con il dito */
246
+ const media = $(".detail-media");
247
+ let swipeX = null;
248
+ media.addEventListener("touchstart", (e) => { swipeX = media.classList.contains("zoomed") ? null : e.touches[0].clientX; }, { passive: true });
249
+ media.addEventListener("touchend", (e) => {
250
+ if (swipeX === null) return;
251
+ const dx = e.changedTouches[0].clientX - swipeX;
252
+ swipeX = null;
253
+ if (Math.abs(dx) < 50) return;
254
+ const btn = $(dx < 0 ? "#detail-next" : "#detail-prev");
255
+ if (!btn.disabled) btn.click();
256
+ });
257
  $("#act-more").addEventListener("click", openMore);
258
  $("#shot-img").addEventListener("click", (e) => {
259
  if (!phone.matches) return;
web/style.css CHANGED
@@ -2082,8 +2082,17 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
2082
  /* ---------- finestre ---------- */
2083
 
2084
  .detail { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
2085
- .detail[open] { grid-template-columns: 1fr; grid-template-rows: 46% 1fr; }
2086
- .detail-side { border-left: 0; border-top: 1px solid var(--line); overflow-y: auto; }
 
 
 
 
 
 
 
 
 
2087
  .sheet, .confirm { width: 100vw; max-width: 100vw; max-height: 90dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; }
2088
  .vector[open] { grid-template-columns: 1fr; grid-template-rows: 50% auto; height: 92dvh; }
2089
  .picker { height: 92dvh; }
 
2082
  /* ---------- finestre ---------- */
2083
 
2084
  .detail { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
2085
+ .detail[open] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
2086
+ .detail-media { padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
2087
+ .detail-media .nav { opacity: 1; width: 38px; height: 38px; }
2088
+ .detail-side { gap: 12px; padding: 14px var(--pad) calc(14px + env(safe-area-inset-bottom)); border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
2089
+ .detail-prompt, .detail-meta { display: none; }
2090
+ .detail-actions { display: flex; gap: 8px; margin-top: 0; }
2091
+ .detail-actions .detail-btn { flex: 1; }
2092
+ .detail-actions #d-more { flex: none; }
2093
+ #detail-actions-gallery > :not(#d-keep):not(#d-open):not(#d-open-draft):not(#d-more) { display: none; }
2094
+ #detail-actions-gallery .detail-btn { height: 48px; }
2095
+ #d-more { display: inline-flex; padding: 0 16px; }
2096
  .sheet, .confirm { width: 100vw; max-width: 100vw; max-height: 90dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; }
2097
  .vector[open] { grid-template-columns: 1fr; grid-template-rows: 50% auto; height: 92dvh; }
2098
  .picker { height: 92dvh; }