63284da8f919
Browse files- web/app.js +46 -7
- web/i18n/en.json +4 -1
- web/mobile.js +10 -6
- web/poster.js +2 -6
web/app.js
CHANGED
|
@@ -1138,9 +1138,7 @@ function showShot(item, fresh = false) {
|
|
| 1138 |
$("#shot-prompt").textContent = titleOf(item);
|
| 1139 |
$("#shot-prompt").title = item.prompt_finale || "";
|
| 1140 |
$("#shot-meta").replaceChildren(...metaSpans(item));
|
| 1141 |
-
|
| 1142 |
-
dl.href = outputUrl(item.file);
|
| 1143 |
-
dl.download = item.file.split("/").pop();
|
| 1144 |
const save = $("#act-save");
|
| 1145 |
save.dataset.saved = String(!item.bozza);
|
| 1146 |
const short = matchMedia("(max-width: 760px)").matches;
|
|
@@ -1455,6 +1453,49 @@ async function warnBlindModel() {
|
|
| 1455 |
$("#prompt").focus();
|
| 1456 |
}
|
| 1457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1458 |
/* ---------- scheda dettaglio ---------- */
|
| 1459 |
|
| 1460 |
const detailItem = () => galleryVisible()[g.detailIndex];
|
|
@@ -1492,9 +1533,7 @@ function renderDetail() {
|
|
| 1492 |
const fav = $("#d-fav");
|
| 1493 |
fav.setAttribute("aria-pressed", String(Boolean(item.preferita)));
|
| 1494 |
$("#d-fav-label").textContent = item.preferita ? "Tra le preferite" : "Preferita";
|
| 1495 |
-
|
| 1496 |
-
dl.href = outputUrl(item.file);
|
| 1497 |
-
dl.download = item.file.split("/").pop();
|
| 1498 |
const total = galleryVisible().length;
|
| 1499 |
$("#detail-prev").disabled = g.detailIndex <= 0;
|
| 1500 |
$("#detail-next").disabled = g.detailIndex >= total - 1;
|
|
@@ -2147,6 +2186,6 @@ async function boot() {
|
|
| 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();
|
|
|
|
| 1138 |
$("#shot-prompt").textContent = titleOf(item);
|
| 1139 |
$("#shot-prompt").title = item.prompt_finale || "";
|
| 1140 |
$("#shot-meta").replaceChildren(...metaSpans(item));
|
| 1141 |
+
prepareDownload($("#act-download"), item);
|
|
|
|
|
|
|
| 1142 |
const save = $("#act-save");
|
| 1143 |
save.dataset.saved = String(!item.bozza);
|
| 1144 |
const short = matchMedia("(max-width: 760px)").matches;
|
|
|
|
| 1453 |
$("#prompt").focus();
|
| 1454 |
}
|
| 1455 |
|
| 1456 |
+
/* ---------- salvare sul dispositivo ---------- */
|
| 1457 |
+
|
| 1458 |
+
// Su iPhone e iPad il foglio di condivisione offre "Salva immagine" e la mette nelle Foto;
|
| 1459 |
+
// altrove si scarica il file vero, letto dall'archivio del browser.
|
| 1460 |
+
const APPLE_TOUCH = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
| 1461 |
+
const ready = new Map();
|
| 1462 |
+
|
| 1463 |
+
async function fileFor(item) {
|
| 1464 |
+
const name = item.file.split("/").pop();
|
| 1465 |
+
if (ready.has(name)) return ready.get(name);
|
| 1466 |
+
const blob = await window.PixBackend?.readBlob?.(`outputs/${item.file}`) || await fetch(outputUrl(item.file)).then((r) => r.blob());
|
| 1467 |
+
const file = new File([blob], name, { type: blob.type || "image/png" });
|
| 1468 |
+
ready.clear();
|
| 1469 |
+
ready.set(name, file);
|
| 1470 |
+
return file;
|
| 1471 |
+
}
|
| 1472 |
+
|
| 1473 |
+
function saveFile(file) {
|
| 1474 |
+
if (APPLE_TOUCH && navigator.canShare?.({ files: [file] })) {
|
| 1475 |
+
return navigator.share({ files: [file] }).catch(() => {});
|
| 1476 |
+
}
|
| 1477 |
+
const url = URL.createObjectURL(file);
|
| 1478 |
+
const a = el("a", { href: url, download: file.name });
|
| 1479 |
+
document.body.append(a);
|
| 1480 |
+
a.click();
|
| 1481 |
+
a.remove();
|
| 1482 |
+
setTimeout(() => URL.revokeObjectURL(url), 4000);
|
| 1483 |
+
return Promise.resolve();
|
| 1484 |
+
}
|
| 1485 |
+
|
| 1486 |
+
function prepareDownload(link, item) {
|
| 1487 |
+
link.href = outputUrl(item.file);
|
| 1488 |
+
link.download = item.file.split("/").pop();
|
| 1489 |
+
link.onclick = (e) => {
|
| 1490 |
+
e.preventDefault();
|
| 1491 |
+
const name = item.file.split("/").pop();
|
| 1492 |
+
const cached = ready.get(name);
|
| 1493 |
+
if (cached) saveFile(cached);
|
| 1494 |
+
else fileFor(item).then(saveFile).catch(() => toast("Non riesco a leggere l'immagine. Riprova."));
|
| 1495 |
+
};
|
| 1496 |
+
fileFor(item).catch(() => {});
|
| 1497 |
+
}
|
| 1498 |
+
|
| 1499 |
/* ---------- scheda dettaglio ---------- */
|
| 1500 |
|
| 1501 |
const detailItem = () => galleryVisible()[g.detailIndex];
|
|
|
|
| 1533 |
const fav = $("#d-fav");
|
| 1534 |
fav.setAttribute("aria-pressed", String(Boolean(item.preferita)));
|
| 1535 |
$("#d-fav-label").textContent = item.preferita ? "Tra le preferite" : "Preferita";
|
| 1536 |
+
prepareDownload($("#d-download"), item);
|
|
|
|
|
|
|
| 1537 |
const total = galleryVisible().length;
|
| 1538 |
$("#detail-prev").disabled = g.detailIndex <= 0;
|
| 1539 |
$("#detail-next").disabled = g.detailIndex >= total - 1;
|
|
|
|
| 2186 |
setInterval(refreshStatus, 10000);
|
| 2187 |
}
|
| 2188 |
|
| 2189 |
+
window.PixRick = { api, toast, el, icon, radio, prefs, mediaUrl, outputUrl, confirmDialog, setView, refreshDraftCount, showInfo, saveFile, detailItem: () => detailItem() };
|
| 2190 |
|
| 2191 |
init();
|
web/i18n/en.json
CHANGED
|
@@ -660,5 +660,8 @@
|
|
| 660 |
"Uso Z-Image": "Use Z-Image",
|
| 661 |
"Torna a Klein": "Back to Klein",
|
| 662 |
"Qualcosa si è inceppato mentre lavoravo. Riprova; se succede ancora, prova con l'altro modello o segnalacelo dal menu.": "Something got stuck while I was working. Try again; if it keeps happening, try the other model or report it from the menu.",
|
| 663 |
-
"Su Hugging Face, serve un account": "On Hugging Face, account needed"
|
|
|
|
|
|
|
|
|
|
| 664 |
}
|
|
|
|
| 660 |
"Uso Z-Image": "Use Z-Image",
|
| 661 |
"Torna a Klein": "Back to Klein",
|
| 662 |
"Qualcosa si è inceppato mentre lavoravo. Riprova; se succede ancora, prova con l'altro modello o segnalacelo dal menu.": "Something got stuck while I was working. Try again; if it keeps happening, try the other model or report it from the menu.",
|
| 663 |
+
"Su Hugging Face, serve un account": "On Hugging Face, account needed",
|
| 664 |
+
"Salva sul dispositivo": "Save to device",
|
| 665 |
+
"Nelle Foto del telefono o tra i download": "To your phone's Photos or your downloads",
|
| 666 |
+
"Non riesco a leggere l'immagine. Riprova.": "I can't read the image. Try again."
|
| 667 |
}
|
web/mobile.js
CHANGED
|
@@ -157,6 +157,8 @@
|
|
| 157 |
/* ---------- "Altro": tutte le azioni sull'immagine, spiegate ---------- */
|
| 158 |
|
| 159 |
const ACTIONS = [
|
|
|
|
|
|
|
| 160 |
["act-variant", "i-shuffle", "Varia", "Stesse impostazioni, risultato nuovo"],
|
| 161 |
["act-edit", "i-wand", "Modifica", "Cambiala a comando, anche solo in una zona"],
|
| 162 |
["act-restyle", "i-palette", "Ristila", "Stessa composizione, stile diverso"],
|
|
@@ -170,7 +172,6 @@
|
|
| 170 |
["act-views", "i-layers", "Viste 3D", "Lato e retro, per Tripo, Meshy o Hunyuan3D"],
|
| 171 |
["m-style", "i-bookmark", "Salva come stile", "Per rifare immagini con questo aspetto"],
|
| 172 |
null,
|
| 173 |
-
["act-download", "i-download", "Scarica", null],
|
| 174 |
["act-info", "i-info", "Info sull'immagine", "Modello, misura, seme e prompt completo"],
|
| 175 |
["act-copy", "i-copy", "Copia il prompt", null],
|
| 176 |
["act-reuse", "i-reuse", "Riusa le impostazioni", null],
|
|
@@ -179,6 +180,8 @@
|
|
| 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"],
|
|
@@ -192,7 +195,6 @@
|
|
| 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"],
|
|
@@ -223,11 +225,13 @@
|
|
| 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 =
|
| 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") {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
afterClose(moreDlg, () => run(target, id));
|
| 232 |
});
|
| 233 |
items.push(item);
|
|
|
|
| 157 |
/* ---------- "Altro": tutte le azioni sull'immagine, spiegate ---------- */
|
| 158 |
|
| 159 |
const ACTIONS = [
|
| 160 |
+
["act-download", "i-download", "Salva sul dispositivo", "Nelle Foto del telefono o tra i download"],
|
| 161 |
+
null,
|
| 162 |
["act-variant", "i-shuffle", "Varia", "Stesse impostazioni, risultato nuovo"],
|
| 163 |
["act-edit", "i-wand", "Modifica", "Cambiala a comando, anche solo in una zona"],
|
| 164 |
["act-restyle", "i-palette", "Ristila", "Stessa composizione, stile diverso"],
|
|
|
|
| 172 |
["act-views", "i-layers", "Viste 3D", "Lato e retro, per Tripo, Meshy o Hunyuan3D"],
|
| 173 |
["m-style", "i-bookmark", "Salva come stile", "Per rifare immagini con questo aspetto"],
|
| 174 |
null,
|
|
|
|
| 175 |
["act-info", "i-info", "Info sull'immagine", "Modello, misura, seme e prompt completo"],
|
| 176 |
["act-copy", "i-copy", "Copia il prompt", null],
|
| 177 |
["act-reuse", "i-reuse", "Riusa le impostazioni", null],
|
|
|
|
| 180 |
];
|
| 181 |
|
| 182 |
const DETAIL_ACTIONS = [
|
| 183 |
+
["d-download", "i-download", "Salva sul dispositivo", "Nelle Foto del telefono o tra i download"],
|
| 184 |
+
null,
|
| 185 |
["d-edit", "i-wand", "Modifica", "Cambiala a comando, anche solo in una zona"],
|
| 186 |
["d-restyle", "i-palette", "Ristila", "Stessa composizione, stile diverso"],
|
| 187 |
["d-variant", "i-shuffle", "Varia", "Stesse impostazioni, risultato nuovo"],
|
|
|
|
| 195 |
["d-style", "i-bookmark", "Salva come stile", "Per rifare immagini con questo aspetto"],
|
| 196 |
["d-fav", "i-star", null, null],
|
| 197 |
null,
|
|
|
|
| 198 |
["d-info", "i-info", "Info sull'immagine", "Modello, misura, seme e prompt completo"],
|
| 199 |
null,
|
| 200 |
["d-trash", "i-trash", null, null, "danger"],
|
|
|
|
| 225 |
const text = label || target.querySelector?.("span")?.textContent.trim() || target.textContent?.trim() || target.title;
|
| 226 |
const children = [icon(ico), el("b", { text })];
|
| 227 |
if (note) children.push(el("small", { text: note }));
|
| 228 |
+
const item = el("button", { type: "button", class: `action-item${tone ? ` ${tone}` : ""}` }, children);
|
|
|
|
|
|
|
| 229 |
item.addEventListener("click", () => {
|
| 230 |
+
if (target.tagName === "A") {
|
| 231 |
+
target.click();
|
| 232 |
+
moreDlg.close();
|
| 233 |
+
return;
|
| 234 |
+
}
|
| 235 |
afterClose(moreDlg, () => run(target, id));
|
| 236 |
});
|
| 237 |
items.push(item);
|
web/poster.js
CHANGED
|
@@ -1143,12 +1143,8 @@
|
|
| 1143 |
async function download(e) {
|
| 1144 |
e.preventDefault();
|
| 1145 |
const data = await blob();
|
| 1146 |
-
const
|
| 1147 |
-
|
| 1148 |
-
document.body.append(a);
|
| 1149 |
-
a.click();
|
| 1150 |
-
a.remove();
|
| 1151 |
-
setTimeout(() => URL.revokeObjectURL(url), 4000);
|
| 1152 |
}
|
| 1153 |
|
| 1154 |
/* ---------- pannello ---------- */
|
|
|
|
| 1143 |
async function download(e) {
|
| 1144 |
e.preventDefault();
|
| 1145 |
const data = await blob();
|
| 1146 |
+
const name = `locandina-${posterTitle().toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 40)}.png`;
|
| 1147 |
+
await window.PixRick.saveFile(new File([data], name, { type: "image/png" }));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
/* ---------- pannello ---------- */
|