Upload index.html
Browse files- h3/index.html +78 -0
h3/index.html
CHANGED
|
@@ -58,6 +58,7 @@ body {
|
|
| 58 |
.btn:active { transform: translateY(1px); }
|
| 59 |
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
|
| 60 |
.btn.primary:hover { filter: brightness(1.08); }
|
|
|
|
| 61 |
.btn:disabled { opacity: 0.45; cursor: default; }
|
| 62 |
|
| 63 |
.search {
|
|
@@ -758,6 +759,7 @@ body {
|
|
| 758 |
<span id="dirtyFlag" class="dirty-flag" hidden>β Unsaved</span>
|
| 759 |
<span class="spacer"></span>
|
| 760 |
<button id="renameBtn" class="btn" title="Rename image (and its .txt)">Rename</button>
|
|
|
|
| 761 |
<button id="prevBtn" class="btn" title="Previous (β)">β</button>
|
| 762 |
<button id="nextBtn" class="btn" title="Next (β)">β</button>
|
| 763 |
<button id="copyBtn" class="btn" title="Copy prompt (Ctrl+C)">Copy</button>
|
|
@@ -891,6 +893,7 @@ const el = {
|
|
| 891 |
detailMeta: $("detailMeta"),
|
| 892 |
backBtn: $("backBtn"),
|
| 893 |
renameBtn: $("renameBtn"),
|
|
|
|
| 894 |
prevBtn: $("prevBtn"),
|
| 895 |
nextBtn: $("nextBtn"),
|
| 896 |
copyBtn: $("copyBtn"),
|
|
@@ -1134,8 +1137,59 @@ async function renameCurrentImage() {
|
|
| 1134 |
toast(`Renamed to "${e.name}".`);
|
| 1135 |
}
|
| 1136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1137 |
el.backBtn.addEventListener("click", backToGrid);
|
| 1138 |
el.renameBtn.addEventListener("click", renameCurrentImage);
|
|
|
|
| 1139 |
el.prevBtn.addEventListener("click", () => nav(-1));
|
| 1140 |
el.nextBtn.addEventListener("click", () => nav(1));
|
| 1141 |
el.copyBtn.addEventListener("click", copyPrompt);
|
|
@@ -1697,6 +1751,30 @@ class FileSystemStorageAdapter {
|
|
| 1697 |
return entry;
|
| 1698 |
}
|
| 1699 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1700 |
async #assertFree(name) {
|
| 1701 |
let exists = false;
|
| 1702 |
try {
|
|
|
|
| 58 |
.btn:active { transform: translateY(1px); }
|
| 59 |
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
|
| 60 |
.btn.primary:hover { filter: brightness(1.08); }
|
| 61 |
+
.btn.danger:hover { border-color: var(--error); color: var(--error); }
|
| 62 |
.btn:disabled { opacity: 0.45; cursor: default; }
|
| 63 |
|
| 64 |
.search {
|
|
|
|
| 759 |
<span id="dirtyFlag" class="dirty-flag" hidden>β Unsaved</span>
|
| 760 |
<span class="spacer"></span>
|
| 761 |
<button id="renameBtn" class="btn" title="Rename image (and its .txt)">Rename</button>
|
| 762 |
+
<button id="deleteBtn" class="btn danger" title="Delete image (and its .txt) from disk">Delete</button>
|
| 763 |
<button id="prevBtn" class="btn" title="Previous (β)">β</button>
|
| 764 |
<button id="nextBtn" class="btn" title="Next (β)">β</button>
|
| 765 |
<button id="copyBtn" class="btn" title="Copy prompt (Ctrl+C)">Copy</button>
|
|
|
|
| 893 |
detailMeta: $("detailMeta"),
|
| 894 |
backBtn: $("backBtn"),
|
| 895 |
renameBtn: $("renameBtn"),
|
| 896 |
+
deleteBtn: $("deleteBtn"),
|
| 897 |
prevBtn: $("prevBtn"),
|
| 898 |
nextBtn: $("nextBtn"),
|
| 899 |
copyBtn: $("copyBtn"),
|
|
|
|
| 1137 |
toast(`Renamed to "${e.name}".`);
|
| 1138 |
}
|
| 1139 |
|
| 1140 |
+
// Delete the open image and its .txt sidecar, then land on the image that took
|
| 1141 |
+
// its place (same slot in the filtered list), or fall back to the grid when the
|
| 1142 |
+
// folder β or the current filter β is left empty.
|
| 1143 |
+
async function deleteCurrentImage() {
|
| 1144 |
+
const e = currentEntry();
|
| 1145 |
+
if (!e) return;
|
| 1146 |
+
if (
|
| 1147 |
+
!window.confirm(
|
| 1148 |
+
`Delete "${e.name}"${e.hasPrompt ? " and its .txt prompt" : ""}? This removes it from disk.`
|
| 1149 |
+
)
|
| 1150 |
+
)
|
| 1151 |
+
return;
|
| 1152 |
+
|
| 1153 |
+
try {
|
| 1154 |
+
await adapter.deleteImage(e);
|
| 1155 |
+
} catch (err) {
|
| 1156 |
+
toast("Could not delete: " + err.message, "error");
|
| 1157 |
+
return;
|
| 1158 |
+
}
|
| 1159 |
+
|
| 1160 |
+
// Drop any in-memory references to the removed image.
|
| 1161 |
+
state.dirty.delete(e.baseName);
|
| 1162 |
+
const orig = originalUrls.get(e.name);
|
| 1163 |
+
if (orig) {
|
| 1164 |
+
URL.revokeObjectURL(orig);
|
| 1165 |
+
originalUrls.delete(e.name);
|
| 1166 |
+
}
|
| 1167 |
+
const thumb = urlCache.get(e.thumbKey);
|
| 1168 |
+
if (thumb) {
|
| 1169 |
+
URL.revokeObjectURL(thumb);
|
| 1170 |
+
urlCache.delete(e.thumbKey);
|
| 1171 |
+
}
|
| 1172 |
+
|
| 1173 |
+
const slot = currentIndex();
|
| 1174 |
+
const gi = state.entries.indexOf(e);
|
| 1175 |
+
if (gi >= 0) state.entries.splice(gi, 1);
|
| 1176 |
+
applyFilters();
|
| 1177 |
+
updateCounts();
|
| 1178 |
+
toast(`Deleted "${e.name}".`);
|
| 1179 |
+
|
| 1180 |
+
if (state.filtered.length === 0) {
|
| 1181 |
+
currentImage = null;
|
| 1182 |
+
state.selectedIndex = -1;
|
| 1183 |
+
backToGrid();
|
| 1184 |
+
renderGrid();
|
| 1185 |
+
return;
|
| 1186 |
+
}
|
| 1187 |
+
openDetail(Math.min(Math.max(slot, 0), state.filtered.length - 1));
|
| 1188 |
+
}
|
| 1189 |
+
|
| 1190 |
el.backBtn.addEventListener("click", backToGrid);
|
| 1191 |
el.renameBtn.addEventListener("click", renameCurrentImage);
|
| 1192 |
+
el.deleteBtn.addEventListener("click", deleteCurrentImage);
|
| 1193 |
el.prevBtn.addEventListener("click", () => nav(-1));
|
| 1194 |
el.nextBtn.addEventListener("click", () => nav(1));
|
| 1195 |
el.copyBtn.addEventListener("click", copyPrompt);
|
|
|
|
| 1751 |
return entry;
|
| 1752 |
}
|
| 1753 |
|
| 1754 |
+
/**
|
| 1755 |
+
* Delete an image and its prompt sidecar together. Removes `<base>.<ext>` and
|
| 1756 |
+
* `<base>.txt` (if present) from disk, plus the disposable thumbnail cache
|
| 1757 |
+
* entry (best-effort β the cache is never counted and safe to leave behind).
|
| 1758 |
+
* The image file is removed last so a failure never leaves an orphaned prompt.
|
| 1759 |
+
* @param {ImageEntry} entry
|
| 1760 |
+
*/
|
| 1761 |
+
async deleteImage(entry) {
|
| 1762 |
+
if (entry._promptHandle) {
|
| 1763 |
+
await this.dirHandle.removeEntry(entry.baseName + ".txt");
|
| 1764 |
+
entry._promptHandle = null;
|
| 1765 |
+
}
|
| 1766 |
+
await this.dirHandle.removeEntry(entry.name);
|
| 1767 |
+
entry._imageHandle = null;
|
| 1768 |
+
|
| 1769 |
+
if (this.thumbDirHandle) {
|
| 1770 |
+
try {
|
| 1771 |
+
await this.thumbDirHandle.removeEntry(entry.thumbKey + ".webp");
|
| 1772 |
+
} catch {
|
| 1773 |
+
/* thumbnail may not have been generated β nothing to clean up */
|
| 1774 |
+
}
|
| 1775 |
+
}
|
| 1776 |
+
}
|
| 1777 |
+
|
| 1778 |
async #assertFree(name) {
|
| 1779 |
let exists = false;
|
| 1780 |
try {
|