- Add delete button (SVG X, hover-reveal) and confirmation modal to comic cards - Add DELETE /api/comics/delete endpoint with path traversal protection - Fix container downloads: delegate Cloudflare-blocked requests to FlareSolverr (headless Chrome sidecar) instead of retrying with Go HTTP client, whose Linux TCP fingerprint is flagged by Cloudflare even with network_mode: host - Add FlareSolverr service to docker-compose; inject FLARESOLVERR_URL env var - Add diagnostic logging to BatcaveBizMarkup request flow - Trim URL whitespace before storing in download job - Guard Archive() against empty filelist; fix runJob error-check ordering
1605 lines
51 KiB
HTML
1605 lines
51 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Yoink</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
:root {
|
|
--bg: #0c0e15;
|
|
--surface: #12151f;
|
|
--surface2: #181c2a;
|
|
--card: #1a1e2e;
|
|
--border: #21273d;
|
|
--border2: #2c3350;
|
|
--accent: #5b8cf5;
|
|
--accent-hv: #7aa3ff;
|
|
--accent-dim: rgba(91,140,245,0.12);
|
|
--text: #dde3f0;
|
|
--text2: #a8b3cc;
|
|
--muted: #505870;
|
|
--success: #34d399;
|
|
--error: #f87171;
|
|
--warn: #fbbf24;
|
|
|
|
--radius: 8px;
|
|
--radius-sm: 5px;
|
|
}
|
|
|
|
html { scrollbar-color: var(--border2) var(--bg); scrollbar-width: thin; }
|
|
|
|
body {
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
font-size: 14px;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
/* Subtle dot grid background */
|
|
body::before {
|
|
content: '';
|
|
position: fixed;
|
|
inset: 0;
|
|
background-image: radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
|
|
background-size: 28px 28px;
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
}
|
|
|
|
/* Everything above the background */
|
|
header, #queue, main, #toast { position: relative; z-index: 1; }
|
|
|
|
/* ── Header ──────────────────────────────────────────────────────────── */
|
|
header {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
height: 68px;
|
|
padding: 0 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
background: rgba(18, 21, 31, 0.88);
|
|
backdrop-filter: blur(14px);
|
|
-webkit-backdrop-filter: blur(14px);
|
|
border-bottom: 1px solid var(--border);
|
|
box-shadow: 0 4px 24px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
/* ── Logo ──────────────────────────────────────────────────────────── */
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
text-decoration: none;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.logo-icon {
|
|
width: 30px;
|
|
height: 30px;
|
|
background: var(--accent);
|
|
border-radius: 7px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 0 12px rgba(91,140,245,0.4);
|
|
}
|
|
|
|
.logo-icon svg { display: block; }
|
|
|
|
.logo-text {
|
|
font-size: 1.1rem;
|
|
font-weight: 800;
|
|
letter-spacing: 0.08em;
|
|
color: var(--text);
|
|
}
|
|
|
|
.logo-text span { color: var(--accent); }
|
|
|
|
/* ── URL form ────────────────────────────────────────────────────────── */
|
|
.url-form {
|
|
flex: 1;
|
|
display: flex;
|
|
max-width: 680px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: 999px;
|
|
padding: 4px 4px 4px 20px;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
|
|
.url-form:focus-within {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 3px rgba(91,140,245,0.15);
|
|
}
|
|
|
|
.url-input {
|
|
flex: 1;
|
|
background: transparent;
|
|
border: none;
|
|
color: var(--text);
|
|
font-family: inherit;
|
|
font-size: 0.875rem;
|
|
outline: none;
|
|
min-width: 0;
|
|
}
|
|
|
|
.url-input::placeholder { color: var(--muted); }
|
|
|
|
.url-btn {
|
|
height: 36px;
|
|
padding: 0 20px;
|
|
background: var(--accent);
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 999px;
|
|
font-family: inherit;
|
|
font-size: 0.8rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.02em;
|
|
cursor: pointer;
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
transition: background 0.15s, transform 0.1s;
|
|
}
|
|
|
|
.url-btn:hover { background: var(--accent-hv); }
|
|
.url-btn:active { transform: scale(0.97); }
|
|
.url-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
|
|
|
|
/* ── Queue strip ─────────────────────────────────────────────────────── */
|
|
#queue {
|
|
background: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
display: none;
|
|
flex-direction: column;
|
|
}
|
|
|
|
#queue.visible { display: flex; }
|
|
|
|
.queue-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14px;
|
|
padding: 11px 28px;
|
|
border-bottom: 1px solid var(--border);
|
|
transition: background 0.15s;
|
|
}
|
|
|
|
.queue-item:last-child { border-bottom: none; }
|
|
.queue-item:hover { background: rgba(255,255,255,0.02); }
|
|
|
|
.queue-status-bar {
|
|
width: 3px;
|
|
height: 36px;
|
|
border-radius: 999px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.queue-item[data-status="pending"] .queue-status-bar { background: var(--muted); }
|
|
.queue-item[data-status="running"] .queue-status-bar { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
|
|
.queue-item[data-status="complete"] .queue-status-bar { background: var(--success); }
|
|
.queue-item[data-status="error"] .queue-status-bar { background: var(--error); }
|
|
|
|
.queue-meta { flex: 1; min-width: 0; }
|
|
|
|
.queue-title {
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.queue-url {
|
|
font-size: 0.72rem;
|
|
color: var(--muted);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.status-pill {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 3px 10px;
|
|
border-radius: 999px;
|
|
font-size: 0.72rem;
|
|
font-weight: 600;
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.status-pill.pending { background: rgba(80,88,112,0.25); color: var(--text2); }
|
|
.status-pill.running { background: var(--accent-dim); color: var(--accent); }
|
|
.status-pill.complete { background: rgba(52,211,153,0.12); color: var(--success); }
|
|
.status-pill.error { background: rgba(248,113,113,0.12); color: var(--error); }
|
|
|
|
.spinner {
|
|
width: 11px; height: 11px;
|
|
border: 2px solid currentColor;
|
|
border-top-color: transparent;
|
|
border-radius: 50%;
|
|
animation: spin 0.7s linear infinite;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
.dismiss-btn {
|
|
background: none;
|
|
border: none;
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
font-size: 1.1rem;
|
|
line-height: 1;
|
|
width: 26px;
|
|
height: 26px;
|
|
border-radius: var(--radius-sm);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
transition: color 0.12s, background 0.12s;
|
|
}
|
|
|
|
.dismiss-btn:hover { color: var(--text); background: var(--border); }
|
|
|
|
/* ── Main ────────────────────────────────────────────────────────────── */
|
|
main { padding: 32px 28px; flex: 1; }
|
|
|
|
/* ── Library toolbar ─────────────────────────────────────────────────── */
|
|
.library-toolbar {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
margin-bottom: 24px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.section-heading {
|
|
font-size: 0.68rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.14em;
|
|
text-transform: uppercase;
|
|
color: var(--muted);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.comic-count {
|
|
font-size: 0.72rem;
|
|
font-weight: 600;
|
|
color: var(--accent);
|
|
background: var(--accent-dim);
|
|
padding: 2px 8px;
|
|
border-radius: 999px;
|
|
}
|
|
|
|
.filter-wrap {
|
|
position: relative;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.filter-icon {
|
|
position: absolute;
|
|
left: 10px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: var(--muted);
|
|
pointer-events: none;
|
|
display: flex;
|
|
}
|
|
|
|
.filter-input {
|
|
height: 32px;
|
|
padding: 0 12px 0 32px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text);
|
|
font-family: inherit;
|
|
font-size: 0.8rem;
|
|
outline: none;
|
|
width: 200px;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
|
|
.filter-input::placeholder { color: var(--muted); }
|
|
|
|
.filter-input:focus {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 3px rgba(91,140,245,0.12);
|
|
}
|
|
|
|
/* Clear button inside filter */
|
|
.filter-input::-webkit-search-cancel-button { display: none; }
|
|
|
|
.sort-group {
|
|
display: flex;
|
|
gap: 3px;
|
|
margin-left: auto;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
padding: 3px;
|
|
}
|
|
|
|
.sort-btn {
|
|
height: 26px;
|
|
padding: 0 10px;
|
|
background: transparent;
|
|
border: none;
|
|
border-radius: 4px;
|
|
color: var(--muted);
|
|
font-family: inherit;
|
|
font-size: 0.72rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: color 0.12s, background 0.12s;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.sort-btn:hover { color: var(--text2); }
|
|
.sort-btn.active { background: var(--border2); color: var(--text); }
|
|
|
|
/* ── Comics grid ─────────────────────────────────────────────────────── */
|
|
#comics-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, 150px);
|
|
gap: 20px;
|
|
}
|
|
|
|
/* ── Comic card — full-bleed poster style ────────────────────────────── */
|
|
.comic-card {
|
|
width: 150px;
|
|
height: 300px;
|
|
border-radius: var(--radius);
|
|
overflow: hidden;
|
|
display: block;
|
|
position: relative;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
border: 1px solid var(--border);
|
|
background: var(--card);
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
|
|
}
|
|
|
|
.comic-card:hover {
|
|
transform: translateY(-4px) scale(1.03);
|
|
box-shadow: 0 16px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(91,140,245,0.3);
|
|
border-color: rgba(91,140,245,0.4);
|
|
}
|
|
|
|
.comic-cover {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
object-position: top center;
|
|
display: block;
|
|
}
|
|
|
|
/* Persistent gradient for title legibility */
|
|
.comic-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0; left: 0; right: 0;
|
|
height: 55%;
|
|
background: linear-gradient(to top, rgba(8,10,18,0.95) 0%, rgba(8,10,18,0.5) 50%, transparent 100%);
|
|
z-index: 1;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
/* Download overlay on hover */
|
|
.comic-download-overlay {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #fff;
|
|
background: rgba(91, 140, 245, 0.72);
|
|
backdrop-filter: blur(3px);
|
|
-webkit-backdrop-filter: blur(3px);
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
z-index: 3;
|
|
}
|
|
|
|
.comic-card:hover .comic-download-overlay { opacity: 1; }
|
|
|
|
.comic-delete-btn {
|
|
position: absolute;
|
|
top: 6px;
|
|
right: 6px;
|
|
width: 20px;
|
|
height: 20px;
|
|
min-width: 20px;
|
|
min-height: 20px;
|
|
box-sizing: content-box;
|
|
border-radius: 50%;
|
|
background: rgba(10,12,20,0.75);
|
|
border: 1px solid rgba(255,255,255,0.15);
|
|
color: var(--text2);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
opacity: 0;
|
|
transition: opacity 0.15s, background 0.15s, color 0.15s;
|
|
z-index: 4;
|
|
padding: 0;
|
|
line-height: 0;
|
|
}
|
|
|
|
.comic-card:hover .comic-delete-btn { opacity: 1; }
|
|
.comic-delete-btn:hover { background: var(--error); color: #fff; border-color: transparent; }
|
|
|
|
.comic-cover-placeholder {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(145deg, #1a2040 0%, #0d1020 100%);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.comic-cover-placeholder svg { opacity: 0.2; }
|
|
|
|
.comic-cover-placeholder .placeholder-initials {
|
|
font-size: 3.5rem;
|
|
font-weight: 800;
|
|
color: rgba(255,255,255,0.18);
|
|
line-height: 1;
|
|
letter-spacing: -0.02em;
|
|
user-select: none;
|
|
}
|
|
|
|
.comic-info {
|
|
position: absolute;
|
|
bottom: 0; left: 0; right: 0;
|
|
padding: 10px 10px 10px;
|
|
z-index: 2;
|
|
}
|
|
|
|
.comic-title {
|
|
font-size: 0.72rem;
|
|
font-weight: 600;
|
|
line-height: 1.35;
|
|
color: #fff;
|
|
overflow: hidden;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
text-shadow: 0 1px 4px rgba(0,0,0,0.8);
|
|
}
|
|
|
|
/* ── Pagination ──────────────────────────────────────────────────────── */
|
|
#pagination {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 4px;
|
|
margin-top: 36px;
|
|
padding-bottom: 36px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.page-btn {
|
|
height: 34px;
|
|
min-width: 34px;
|
|
padding: 0 12px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text2);
|
|
font-family: inherit;
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: border-color 0.12s, color 0.12s, background 0.12s;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
|
|
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
|
|
.page-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
|
|
|
|
.page-ellipsis {
|
|
color: var(--muted);
|
|
font-size: 0.8rem;
|
|
padding: 0 4px;
|
|
line-height: 34px;
|
|
}
|
|
|
|
/* ── Skeleton loading cards ──────────────────────────────────────────── */
|
|
.skeleton-card {
|
|
width: 150px;
|
|
height: 300px;
|
|
border-radius: var(--radius);
|
|
border: 1px solid var(--border);
|
|
background: linear-gradient(90deg, var(--card) 25%, var(--surface2) 50%, var(--card) 75%);
|
|
background-size: 400% 100%;
|
|
animation: shimmer 1.6s ease infinite;
|
|
}
|
|
|
|
@keyframes shimmer {
|
|
0% { background-position: 100% 0; }
|
|
100% { background-position: -100% 0; }
|
|
}
|
|
|
|
/* ── Empty state ─────────────────────────────────────────────────────── */
|
|
#empty-state {
|
|
display: none;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 16px;
|
|
margin-top: 80px;
|
|
color: var(--muted);
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-box {
|
|
width: 100px;
|
|
height: 100px;
|
|
border: 2px dashed var(--border2);
|
|
border-radius: 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.empty-box svg { opacity: 0.3; }
|
|
|
|
#empty-state p {
|
|
font-size: 0.85rem;
|
|
color: var(--text2);
|
|
max-width: 260px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.empty-hint {
|
|
font-size: 0.76rem !important;
|
|
font-style: italic;
|
|
color: var(--muted) !important;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.empty-hint svg {
|
|
flex-shrink: 0;
|
|
opacity: 0.5;
|
|
}
|
|
|
|
/* ── Toasts ──────────────────────────────────────────────────────────── */
|
|
#toast {
|
|
position: fixed;
|
|
bottom: 24px;
|
|
right: 24px;
|
|
z-index: 999;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
pointer-events: none;
|
|
max-width: 340px;
|
|
}
|
|
|
|
.toast-msg {
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border2);
|
|
border-left: 3px solid var(--accent);
|
|
color: var(--text);
|
|
padding: 11px 16px;
|
|
border-radius: var(--radius);
|
|
font-size: 0.8rem;
|
|
line-height: 1.4;
|
|
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
|
animation: slideIn 0.22s ease;
|
|
opacity: 1;
|
|
transition: opacity 0.3s;
|
|
}
|
|
|
|
.toast-msg.is-error { border-left-color: var(--error); }
|
|
.toast-msg.fade { opacity: 0; }
|
|
|
|
/* ── Upload button ───────────────────────────────────────────────────── */
|
|
.upload-btn {
|
|
height: 36px;
|
|
width: 36px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
color: var(--text2);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
|
}
|
|
|
|
.upload-btn:hover { background: var(--border); border-color: var(--border2); color: var(--text); }
|
|
|
|
/* ── Upload modal ────────────────────────────────────────────────────── */
|
|
.modal-backdrop {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(0,0,0,0.6);
|
|
backdrop-filter: blur(4px);
|
|
-webkit-backdrop-filter: blur(4px);
|
|
z-index: 200;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
.modal-backdrop.open { opacity: 1; pointer-events: all; }
|
|
|
|
.modal {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border2);
|
|
border-radius: 12px;
|
|
padding: 28px;
|
|
width: 480px;
|
|
max-width: calc(100vw - 32px);
|
|
box-shadow: 0 24px 80px rgba(0,0,0,0.6);
|
|
transform: translateY(12px);
|
|
transition: transform 0.2s;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 18px;
|
|
}
|
|
|
|
.modal-backdrop.open .modal { transform: translateY(0); }
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.modal-title {
|
|
font-size: 0.95rem;
|
|
font-weight: 700;
|
|
color: var(--text);
|
|
}
|
|
|
|
.modal-close {
|
|
background: none;
|
|
border: none;
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
font-size: 1.2rem;
|
|
line-height: 1;
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: var(--radius-sm);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: color 0.12s, background 0.12s;
|
|
}
|
|
|
|
.modal-close:hover { color: var(--text); background: var(--border); }
|
|
|
|
.upload-title-input {
|
|
width: 100%;
|
|
height: 38px;
|
|
padding: 0 14px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
color: var(--text);
|
|
font-family: inherit;
|
|
font-size: 0.875rem;
|
|
outline: none;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
|
|
.upload-title-input::placeholder { color: var(--muted); }
|
|
|
|
.upload-title-input:focus {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 3px rgba(91,140,245,0.15);
|
|
}
|
|
|
|
.drop-zone {
|
|
border: 2px dashed var(--border2);
|
|
border-radius: var(--radius);
|
|
padding: 36px 20px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: border-color 0.15s, background 0.15s;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 10px;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.drop-zone:hover, .drop-zone.drag-over {
|
|
border-color: var(--accent);
|
|
background: var(--accent-dim);
|
|
color: var(--text2);
|
|
}
|
|
|
|
.drop-zone svg { opacity: 0.5; }
|
|
.drop-zone.drag-over svg { opacity: 0.8; }
|
|
|
|
.drop-zone-label {
|
|
font-size: 0.85rem;
|
|
font-weight: 500;
|
|
color: var(--text2);
|
|
}
|
|
|
|
.drop-zone-sub {
|
|
font-size: 0.75rem;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.drop-zone-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.pick-btn {
|
|
height: 30px;
|
|
padding: 0 14px;
|
|
background: var(--surface2);
|
|
border: 1px solid var(--border2);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text2);
|
|
font-family: inherit;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: border-color 0.12s, color 0.12s, background 0.12s;
|
|
}
|
|
|
|
.pick-btn:hover { border-color: var(--accent); color: var(--text); background: var(--accent-dim); }
|
|
|
|
.file-count {
|
|
font-size: 0.78rem;
|
|
color: var(--accent);
|
|
font-weight: 600;
|
|
min-height: 1.2em;
|
|
}
|
|
|
|
.upload-progress {
|
|
height: 3px;
|
|
background: var(--border);
|
|
border-radius: 999px;
|
|
overflow: hidden;
|
|
display: none;
|
|
}
|
|
|
|
.upload-progress-bar {
|
|
height: 100%;
|
|
background: var(--accent);
|
|
border-radius: 999px;
|
|
width: 0%;
|
|
transition: width 0.2s;
|
|
}
|
|
|
|
.modal-submit {
|
|
height: 40px;
|
|
background: var(--accent);
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: var(--radius);
|
|
font-family: inherit;
|
|
font-size: 0.875rem;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
transition: background 0.15s, transform 0.1s;
|
|
}
|
|
|
|
.modal-submit:hover { background: var(--accent-hv); }
|
|
.modal-submit:active { transform: scale(0.98); }
|
|
.modal-submit:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
|
|
|
|
.toast-icon {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
margin-right: 7px;
|
|
vertical-align: middle;
|
|
position: relative;
|
|
top: -1px;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from { transform: translateX(32px); opacity: 0; }
|
|
to { transform: translateX(0); opacity: 1; }
|
|
}
|
|
|
|
/* ── Footer ──────────────────────────────────────────────────────────── */
|
|
footer {
|
|
position: relative;
|
|
z-index: 1;
|
|
text-align: center;
|
|
padding: 14px 28px;
|
|
font-size: 0.72rem;
|
|
color: var(--muted);
|
|
border-top: 1px solid var(--border);
|
|
}
|
|
|
|
footer a {
|
|
color: var(--muted);
|
|
text-decoration: none;
|
|
transition: color 0.15s;
|
|
}
|
|
|
|
footer a:hover { color: var(--text2); }
|
|
|
|
/* ── Responsive — tablet ─────────────────────────────────────────────── */
|
|
@media (max-width: 860px) {
|
|
.url-form { max-width: 100%; }
|
|
|
|
.filter-input { width: 160px; }
|
|
|
|
.queue-url { display: none; }
|
|
}
|
|
|
|
/* ── Responsive — mobile ─────────────────────────────────────────────── */
|
|
@media (max-width: 600px) {
|
|
/* Header wraps to two rows: logo row + form row */
|
|
header {
|
|
height: auto;
|
|
flex-wrap: wrap;
|
|
padding: 12px 16px;
|
|
gap: 10px;
|
|
}
|
|
|
|
.url-form {
|
|
flex: 0 0 100%;
|
|
max-width: 100%;
|
|
}
|
|
|
|
/* Queue */
|
|
.queue-item { padding: 10px 16px; }
|
|
|
|
/* Main */
|
|
main { padding: 20px 16px; }
|
|
|
|
/* Toolbar: heading row then controls row */
|
|
.library-toolbar { flex-wrap: wrap; row-gap: 10px; }
|
|
|
|
.filter-wrap {
|
|
flex: 1 1 auto;
|
|
min-width: 0;
|
|
}
|
|
|
|
.filter-input { width: 100%; }
|
|
|
|
.sort-group {
|
|
flex: 0 0 100%;
|
|
order: 4;
|
|
margin-left: 0;
|
|
overflow-x: auto;
|
|
/* hide scrollbar visually but keep scrollable */
|
|
scrollbar-width: none;
|
|
}
|
|
|
|
.sort-group::-webkit-scrollbar { display: none; }
|
|
|
|
/* Center single-column grid on very small screens */
|
|
#comics-grid { justify-content: center; gap: 14px; }
|
|
|
|
/* Toasts go edge-to-edge */
|
|
#toast {
|
|
left: 12px;
|
|
right: 12px;
|
|
bottom: 12px;
|
|
max-width: none;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<a class="logo" href="/">
|
|
<div class="logo-icon">
|
|
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M12 5v14M5 12l7 7 7-7"/>
|
|
</svg>
|
|
</div>
|
|
<span class="logo-text">YOINK<span>.</span></span>
|
|
</a>
|
|
|
|
<form class="url-form" id="url-form">
|
|
<input
|
|
class="url-input"
|
|
id="url-input"
|
|
type="url"
|
|
placeholder="Paste a comic URL to download…"
|
|
required
|
|
autocomplete="off"
|
|
spellcheck="false"
|
|
/>
|
|
<button class="url-btn" id="url-btn" type="submit">Download</button>
|
|
</form>
|
|
|
|
<button class="upload-btn" id="upload-open-btn" title="Package local images as CBZ">
|
|
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
|
<polyline points="17 8 12 3 7 8"/>
|
|
<line x1="12" y1="3" x2="12" y2="15"/>
|
|
</svg>
|
|
</button>
|
|
</header>
|
|
|
|
<!-- Upload modal -->
|
|
<div class="modal-backdrop" id="upload-modal">
|
|
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="modal-title-label">
|
|
<div class="modal-header">
|
|
<span class="modal-title" id="modal-title-label">Package images as CBZ</span>
|
|
<button class="modal-close" id="upload-close-btn" aria-label="Close">×</button>
|
|
</div>
|
|
|
|
<input class="upload-title-input" id="upload-title" type="text" placeholder="Comic title…" autocomplete="off" />
|
|
|
|
<div class="drop-zone" id="drop-zone">
|
|
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
<path d="M3 9h18M9 21V9"/>
|
|
</svg>
|
|
<span class="drop-zone-label">Drop images or a folder here</span>
|
|
<span class="drop-zone-sub">JPG, PNG, WebP — sorted by filename</span>
|
|
<div class="drop-zone-actions">
|
|
<button class="pick-btn" id="pick-folder-btn" type="button">Select folder</button>
|
|
<button class="pick-btn" id="pick-files-btn" type="button">Select files</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="file-count" id="file-count"></div>
|
|
<div class="upload-progress" id="upload-progress"><div class="upload-progress-bar" id="upload-progress-bar"></div></div>
|
|
|
|
<button class="modal-submit" id="upload-submit-btn" disabled>Package & add to library</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="queue"></div>
|
|
|
|
<main>
|
|
<div class="library-toolbar">
|
|
<span class="section-heading">Library</span>
|
|
<span class="comic-count" id="comic-count" style="display:none"></span>
|
|
<div class="filter-wrap">
|
|
<span class="filter-icon">
|
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2">
|
|
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>
|
|
</svg>
|
|
</span>
|
|
<input class="filter-input" id="filter-input" type="search" placeholder="Filter by title…" />
|
|
</div>
|
|
<div class="sort-group">
|
|
<button class="sort-btn active" data-sort="newest">Newest</button>
|
|
<button class="sort-btn" data-sort="oldest">Oldest</button>
|
|
<button class="sort-btn" data-sort="az">A–Z</button>
|
|
<button class="sort-btn" data-sort="za">Z–A</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="comics-grid"></div>
|
|
<div id="pagination"></div>
|
|
|
|
<div id="empty-state">
|
|
<div class="empty-box">
|
|
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4">
|
|
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
<path d="M3 9h18M9 21V9"/>
|
|
</svg>
|
|
</div>
|
|
<p>No comics yet — paste a URL above to start building your library.</p>
|
|
<p class="empty-hint">
|
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M12 19V5M5 12l7-7 7 7"/>
|
|
</svg>
|
|
Your downloaded comics will appear here
|
|
</p>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
<a href="https://github.com/brizzbuzz/yoink-go" target="_blank" rel="noopener">Yoink</a>
|
|
· v1.1.0
|
|
</footer>
|
|
|
|
<div id="toast"></div>
|
|
|
|
<!-- Delete confirmation modal -->
|
|
<div class="modal-backdrop" id="delete-modal">
|
|
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="delete-modal-title">
|
|
<div class="modal-header">
|
|
<span class="modal-title" id="delete-modal-title">Delete comic?</span>
|
|
<button class="modal-close" id="delete-close-btn" aria-label="Close">×</button>
|
|
</div>
|
|
<p style="color:var(--text2);margin:0 0 20px;">This will permanently remove <strong id="delete-comic-name" style="color:var(--text)"></strong> and all its files from the library.</p>
|
|
<div style="display:flex;gap:10px;justify-content:flex-end;">
|
|
<button class="pick-btn" id="delete-cancel-btn" type="button">Cancel</button>
|
|
<button class="pick-btn" id="delete-confirm-btn" style="background:var(--error);border-color:var(--error);color:#fff;">Delete</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Hidden file inputs for upload modal -->
|
|
<input type="file" id="file-input-folder" style="display:none" multiple webkitdirectory />
|
|
<input type="file" id="file-input-files" style="display:none" multiple accept="image/*" />
|
|
|
|
<script>
|
|
// ── State ──────────────────────────────────────────────────────────────
|
|
const PAGE_SIZE = 48;
|
|
let knownJobs = {};
|
|
let dismissedJobs = JSON.parse(localStorage.getItem('dismissedJobs') || '{}');
|
|
let allComics = [];
|
|
let currentSort = localStorage.getItem('comicSort') || 'newest';
|
|
let currentPage = 1;
|
|
|
|
// ── DOM refs ───────────────────────────────────────────────────────────
|
|
const form = document.getElementById('url-form');
|
|
const input = document.getElementById('url-input');
|
|
const btn = document.getElementById('url-btn');
|
|
const queue = document.getElementById('queue');
|
|
const grid = document.getElementById('comics-grid');
|
|
const emptyEl = document.getElementById('empty-state');
|
|
const toastEl = document.getElementById('toast');
|
|
const filterInput = document.getElementById('filter-input');
|
|
const sortBtns = document.querySelectorAll('.sort-btn');
|
|
const countEl = document.getElementById('comic-count');
|
|
|
|
// ── Submit handler ─────────────────────────────────────────────────────
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const url = input.value.trim();
|
|
if (!url) return;
|
|
|
|
btn.disabled = true;
|
|
btn.textContent = 'Queuing…';
|
|
|
|
try {
|
|
const res = await fetch('/api/download', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ url }),
|
|
});
|
|
|
|
if (!res.ok) throw new Error(await res.text());
|
|
|
|
const job = await res.json();
|
|
knownJobs[job.id] = job;
|
|
input.value = '';
|
|
toast('Download queued');
|
|
renderQueue();
|
|
} catch (err) {
|
|
toast('Error: ' + err.message, true);
|
|
} finally {
|
|
btn.disabled = false;
|
|
btn.textContent = 'Download';
|
|
}
|
|
});
|
|
|
|
// ── Render queue ───────────────────────────────────────────────────────
|
|
function renderQueue() {
|
|
const active = Object.values(knownJobs).filter(j => !dismissedJobs[j.id]);
|
|
queue.innerHTML = '';
|
|
|
|
if (active.length === 0) {
|
|
queue.classList.remove('visible');
|
|
return;
|
|
}
|
|
|
|
queue.classList.add('visible');
|
|
active.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
|
|
|
|
active.forEach(job => {
|
|
const row = document.createElement('div');
|
|
row.className = 'queue-item';
|
|
row.dataset.status = job.status;
|
|
|
|
const bar = document.createElement('div');
|
|
bar.className = 'queue-status-bar';
|
|
|
|
const meta = document.createElement('div');
|
|
meta.className = 'queue-meta';
|
|
|
|
const title = document.createElement('div');
|
|
title.className = 'queue-title';
|
|
title.textContent = job.title || 'Fetching…';
|
|
|
|
const urlEl = document.createElement('div');
|
|
urlEl.className = 'queue-url';
|
|
urlEl.textContent = job.url;
|
|
|
|
meta.append(title, urlEl);
|
|
|
|
const pill = makeStatusPill(job);
|
|
|
|
const dismiss = document.createElement('button');
|
|
dismiss.className = 'dismiss-btn';
|
|
dismiss.title = 'Dismiss';
|
|
dismiss.innerHTML = '×';
|
|
dismiss.addEventListener('click', () => {
|
|
dismissedJobs[job.id] = true;
|
|
localStorage.setItem('dismissedJobs', JSON.stringify(dismissedJobs));
|
|
renderQueue();
|
|
});
|
|
|
|
row.append(bar, meta, pill, dismiss);
|
|
queue.append(row);
|
|
});
|
|
}
|
|
|
|
function makeStatusPill(job) {
|
|
const pill = document.createElement('span');
|
|
pill.className = 'status-pill ' + job.status;
|
|
|
|
if (job.status === 'pending' || job.status === 'running') {
|
|
const spin = document.createElement('span');
|
|
spin.className = 'spinner';
|
|
pill.append(spin);
|
|
}
|
|
|
|
const label = {
|
|
pending: 'Pending',
|
|
running: 'Downloading',
|
|
complete: '✓ Done',
|
|
error: '✕ Error',
|
|
}[job.status] || job.status;
|
|
|
|
pill.append(document.createTextNode(label));
|
|
if (job.error) pill.title = job.error;
|
|
|
|
return pill;
|
|
}
|
|
|
|
// ── Filter & sort ──────────────────────────────────────────────────────
|
|
function applyFilterAndSort(resetPage = false) {
|
|
const query = filterInput.value.trim().toLowerCase();
|
|
|
|
let comics = query
|
|
? allComics.filter(c => c.title.toLowerCase().includes(query))
|
|
: allComics.slice();
|
|
|
|
if (currentSort === 'oldest') {
|
|
comics = comics.slice().reverse();
|
|
} else if (currentSort === 'az') {
|
|
comics = comics.slice().sort((a, b) => a.title.localeCompare(b.title));
|
|
} else if (currentSort === 'za') {
|
|
comics = comics.slice().sort((a, b) => b.title.localeCompare(a.title));
|
|
}
|
|
|
|
const totalPages = Math.max(1, Math.ceil(comics.length / PAGE_SIZE));
|
|
if (resetPage || currentPage > totalPages) currentPage = 1;
|
|
|
|
const paged = comics.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE);
|
|
renderComics(paged);
|
|
renderPagination(totalPages);
|
|
}
|
|
|
|
function renderPagination(totalPages) {
|
|
const el = document.getElementById('pagination');
|
|
el.innerHTML = '';
|
|
if (totalPages <= 1) return;
|
|
|
|
const mkBtn = (label, page, active = false, disabled = false) => {
|
|
const b = document.createElement('button');
|
|
b.className = 'page-btn' + (active ? ' active' : '');
|
|
b.textContent = label;
|
|
b.disabled = disabled;
|
|
b.addEventListener('click', () => {
|
|
currentPage = page;
|
|
applyFilterAndSort();
|
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
});
|
|
return b;
|
|
};
|
|
|
|
const mkEllipsis = () => {
|
|
const s = document.createElement('span');
|
|
s.className = 'page-ellipsis';
|
|
s.textContent = '…';
|
|
return s;
|
|
};
|
|
|
|
el.append(mkBtn('← Prev', currentPage - 1, false, currentPage === 1));
|
|
|
|
// Page numbers with ellipsis: always show first, last, and window around current
|
|
const pages = new Set([1, totalPages]);
|
|
for (let p = currentPage - 2; p <= currentPage + 2; p++) {
|
|
if (p > 1 && p < totalPages) pages.add(p);
|
|
}
|
|
const sorted = [...pages].sort((a, b) => a - b);
|
|
|
|
let prev = 0;
|
|
for (const p of sorted) {
|
|
if (p - prev > 1) el.append(mkEllipsis());
|
|
el.append(mkBtn(p, p, p === currentPage));
|
|
prev = p;
|
|
}
|
|
|
|
el.append(mkBtn('Next →', currentPage + 1, false, currentPage === totalPages));
|
|
}
|
|
|
|
// ── Render comics ──────────────────────────────────────────────────────
|
|
function renderComics(comics) {
|
|
grid.innerHTML = '';
|
|
|
|
if (!comics || comics.length === 0) {
|
|
emptyEl.style.display = 'flex';
|
|
countEl.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
emptyEl.style.display = 'none';
|
|
countEl.textContent = allComics.length;
|
|
countEl.style.display = '';
|
|
|
|
comics.forEach(comic => {
|
|
const a = document.createElement('a');
|
|
a.className = 'comic-card';
|
|
a.href = comic.file_url;
|
|
|
|
if (comic.cover_url) {
|
|
const img = document.createElement('img');
|
|
img.className = 'comic-cover';
|
|
img.src = comic.cover_url;
|
|
img.alt = comic.title;
|
|
img.loading = 'lazy';
|
|
img.onerror = () => img.replaceWith(makePlaceholder(comic.title));
|
|
a.append(img);
|
|
} else {
|
|
a.append(makePlaceholder(comic.title));
|
|
}
|
|
|
|
const overlay = document.createElement('div');
|
|
overlay.className = 'comic-download-overlay';
|
|
overlay.innerHTML = `<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M12 3v13M5 14l7 7 7-7"/><path d="M3 21h18"/>
|
|
</svg>`;
|
|
a.append(overlay);
|
|
|
|
const info = document.createElement('div');
|
|
info.className = 'comic-info';
|
|
|
|
const title = document.createElement('div');
|
|
title.className = 'comic-title';
|
|
title.textContent = comic.title;
|
|
|
|
info.append(title);
|
|
a.append(info);
|
|
|
|
const delBtn = document.createElement('button');
|
|
delBtn.className = 'comic-delete-btn';
|
|
delBtn.title = 'Delete comic';
|
|
delBtn.innerHTML = '<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><line x1="1" y1="1" x2="9" y2="9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><line x1="9" y1="1" x2="1" y2="9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>';
|
|
delBtn.addEventListener('click', e => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
openDeleteModal(comic.title);
|
|
});
|
|
a.append(delBtn);
|
|
|
|
grid.append(a);
|
|
});
|
|
}
|
|
|
|
function makePlaceholder(title) {
|
|
const div = document.createElement('div');
|
|
div.className = 'comic-cover-placeholder';
|
|
if (title) {
|
|
const words = title.trim().split(/\s+/).filter(Boolean);
|
|
const initials = words.length === 1
|
|
? words[0].slice(0, 2)
|
|
: (words[0][0] + words[1][0]);
|
|
const span = document.createElement('span');
|
|
span.className = 'placeholder-initials';
|
|
span.textContent = initials.toUpperCase();
|
|
div.append(span);
|
|
} else {
|
|
div.innerHTML = `
|
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="1.2">
|
|
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
<path d="M3 9h18M9 21V9"/>
|
|
</svg>`;
|
|
}
|
|
return div;
|
|
}
|
|
|
|
function showSkeletons() {
|
|
grid.innerHTML = '';
|
|
emptyEl.style.display = 'none';
|
|
for (let i = 0; i < 10; i++) {
|
|
const sk = document.createElement('div');
|
|
sk.className = 'skeleton-card';
|
|
grid.append(sk);
|
|
}
|
|
}
|
|
|
|
// ── Toast ──────────────────────────────────────────────────────────────
|
|
function toast(msg, isError = false) {
|
|
const el = document.createElement('div');
|
|
el.className = 'toast-msg' + (isError ? ' is-error' : '');
|
|
|
|
const icon = document.createElement('span');
|
|
icon.className = 'toast-icon';
|
|
if (isError) {
|
|
icon.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--error)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M15 9l-6 6M9 9l6 6"/>
|
|
</svg>`;
|
|
} else {
|
|
icon.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--success)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M8 12l3 3 5-5"/>
|
|
</svg>`;
|
|
}
|
|
|
|
el.append(icon, document.createTextNode(msg));
|
|
toastEl.append(el);
|
|
setTimeout(() => {
|
|
el.classList.add('fade');
|
|
setTimeout(() => el.remove(), 350);
|
|
}, 3500);
|
|
}
|
|
|
|
// ── Polling ────────────────────────────────────────────────────────────
|
|
async function pollJobs() {
|
|
try {
|
|
const res = await fetch('/api/jobs');
|
|
const jobs = await res.json();
|
|
let needComicRefresh = false;
|
|
|
|
jobs.forEach(job => {
|
|
const prev = knownJobs[job.id];
|
|
if (prev && prev.status !== 'complete' && job.status === 'complete') {
|
|
needComicRefresh = true;
|
|
toast(`"${job.title}" downloaded`);
|
|
}
|
|
if (prev && prev.status !== 'error' && job.status === 'error') {
|
|
toast(`Failed: ${job.title || job.url}${job.error ? ' — ' + job.error : ''}`, true);
|
|
}
|
|
knownJobs[job.id] = job;
|
|
});
|
|
|
|
renderQueue();
|
|
if (needComicRefresh) await fetchComics();
|
|
} catch (_) {}
|
|
}
|
|
|
|
async function fetchComics() {
|
|
try {
|
|
const res = await fetch('/api/comics');
|
|
allComics = await res.json();
|
|
applyFilterAndSort();
|
|
} catch (_) {}
|
|
}
|
|
|
|
// ── Init ───────────────────────────────────────────────────────────────
|
|
sortBtns.forEach(b => {
|
|
if (b.dataset.sort === currentSort) b.classList.add('active');
|
|
else b.classList.remove('active');
|
|
|
|
b.addEventListener('click', () => {
|
|
currentSort = b.dataset.sort;
|
|
localStorage.setItem('comicSort', currentSort);
|
|
sortBtns.forEach(x => x.classList.toggle('active', x === b));
|
|
applyFilterAndSort(true);
|
|
});
|
|
});
|
|
|
|
filterInput.addEventListener('input', () => applyFilterAndSort(true));
|
|
|
|
showSkeletons();
|
|
fetchComics();
|
|
setInterval(pollJobs, 2000);
|
|
setInterval(fetchComics, 10000);
|
|
|
|
// ── Delete modal ───────────────────────────────────────────────────────
|
|
const deleteModal = document.getElementById('delete-modal');
|
|
const deleteCloseBtn = document.getElementById('delete-close-btn');
|
|
const deleteCancelBtn = document.getElementById('delete-cancel-btn');
|
|
const deleteConfirmBtn = document.getElementById('delete-confirm-btn');
|
|
const deleteComicName = document.getElementById('delete-comic-name');
|
|
|
|
let pendingDeleteTitle = null;
|
|
|
|
function openDeleteModal(title) {
|
|
pendingDeleteTitle = title;
|
|
deleteComicName.textContent = title;
|
|
deleteModal.classList.add('open');
|
|
}
|
|
|
|
function closeDeleteModal() {
|
|
deleteModal.classList.remove('open');
|
|
pendingDeleteTitle = null;
|
|
}
|
|
|
|
deleteCloseBtn.addEventListener('click', closeDeleteModal);
|
|
deleteCancelBtn.addEventListener('click', closeDeleteModal);
|
|
deleteModal.addEventListener('click', e => { if (e.target === deleteModal) closeDeleteModal(); });
|
|
|
|
deleteConfirmBtn.addEventListener('click', async () => {
|
|
if (!pendingDeleteTitle) return;
|
|
const title = pendingDeleteTitle;
|
|
closeDeleteModal();
|
|
try {
|
|
const res = await fetch('/api/comics/delete', {
|
|
method: 'DELETE',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ title }),
|
|
});
|
|
if (res.ok || res.status === 204) {
|
|
await fetchComics();
|
|
}
|
|
} catch (_) {}
|
|
});
|
|
|
|
// ── Upload modal ───────────────────────────────────────────────────────
|
|
const uploadModal = document.getElementById('upload-modal');
|
|
const uploadOpenBtn = document.getElementById('upload-open-btn');
|
|
const uploadCloseBtn = document.getElementById('upload-close-btn');
|
|
const uploadTitleInput = document.getElementById('upload-title');
|
|
const dropZone = document.getElementById('drop-zone');
|
|
const pickFolderBtn = document.getElementById('pick-folder-btn');
|
|
const pickFilesBtn = document.getElementById('pick-files-btn');
|
|
const fileInputFolder = document.getElementById('file-input-folder');
|
|
const fileInputFiles = document.getElementById('file-input-files');
|
|
const fileCountEl = document.getElementById('file-count');
|
|
const uploadProgress = document.getElementById('upload-progress');
|
|
const uploadProgressBar= document.getElementById('upload-progress-bar');
|
|
const uploadSubmitBtn = document.getElementById('upload-submit-btn');
|
|
|
|
let pendingFiles = [];
|
|
|
|
const IMAGE_EXTS = new Set(['.jpg', '.jpeg', '.png', '.webp']);
|
|
|
|
function isImage(name) {
|
|
const ext = name.slice(name.lastIndexOf('.')).toLowerCase();
|
|
return IMAGE_EXTS.has(ext);
|
|
}
|
|
|
|
function setFiles(fileList) {
|
|
const imgs = Array.from(fileList).filter(f => isImage(f.name));
|
|
imgs.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
|
|
pendingFiles = imgs;
|
|
fileCountEl.textContent = imgs.length
|
|
? `${imgs.length} image${imgs.length !== 1 ? 's' : ''} selected`
|
|
: '';
|
|
uploadSubmitBtn.disabled = imgs.length === 0 || !uploadTitleInput.value.trim();
|
|
}
|
|
|
|
function openModal() {
|
|
uploadModal.classList.add('open');
|
|
uploadTitleInput.focus();
|
|
}
|
|
|
|
function closeModal() {
|
|
uploadModal.classList.remove('open');
|
|
pendingFiles = [];
|
|
fileCountEl.textContent = '';
|
|
uploadTitleInput.value = '';
|
|
uploadSubmitBtn.disabled = true;
|
|
uploadProgress.style.display = 'none';
|
|
uploadProgressBar.style.width = '0%';
|
|
fileInputFolder.value = '';
|
|
fileInputFiles.value = '';
|
|
}
|
|
|
|
uploadOpenBtn.addEventListener('click', openModal);
|
|
uploadCloseBtn.addEventListener('click', closeModal);
|
|
uploadModal.addEventListener('click', e => { if (e.target === uploadModal) closeModal(); });
|
|
document.addEventListener('keydown', e => { if (e.key === 'Escape' && uploadModal.classList.contains('open')) closeModal(); });
|
|
|
|
pickFolderBtn.addEventListener('click', () => fileInputFolder.click());
|
|
pickFilesBtn.addEventListener('click', () => fileInputFiles.click());
|
|
|
|
fileInputFolder.addEventListener('change', e => {
|
|
// Auto-fill title from folder name via webkitRelativePath
|
|
const files = Array.from(e.target.files);
|
|
if (files.length && !uploadTitleInput.value.trim()) {
|
|
const rel = files[0].webkitRelativePath;
|
|
if (rel) uploadTitleInput.value = rel.split('/')[0];
|
|
}
|
|
setFiles(e.target.files);
|
|
});
|
|
|
|
fileInputFiles.addEventListener('change', e => setFiles(e.target.files));
|
|
|
|
uploadTitleInput.addEventListener('input', () => {
|
|
uploadSubmitBtn.disabled = pendingFiles.length === 0 || !uploadTitleInput.value.trim();
|
|
});
|
|
|
|
// Drag & drop
|
|
dropZone.addEventListener('dragover', e => {
|
|
e.preventDefault();
|
|
dropZone.classList.add('drag-over');
|
|
});
|
|
dropZone.addEventListener('dragleave', () => dropZone.classList.remove('drag-over'));
|
|
dropZone.addEventListener('drop', async e => {
|
|
e.preventDefault();
|
|
dropZone.classList.remove('drag-over');
|
|
|
|
const collected = [];
|
|
const entries = Array.from(e.dataTransfer.items)
|
|
.filter(i => i.kind === 'file')
|
|
.map(i => i.webkitGetAsEntry());
|
|
|
|
async function readEntry(entry) {
|
|
if (entry.isFile) {
|
|
await new Promise(res => entry.file(f => { collected.push(f); res(); }));
|
|
} else if (entry.isDirectory) {
|
|
if (!uploadTitleInput.value.trim()) uploadTitleInput.value = entry.name;
|
|
const reader = entry.createReader();
|
|
await new Promise(res => reader.readEntries(async entries => {
|
|
for (const e of entries) await readEntry(e);
|
|
res();
|
|
}));
|
|
}
|
|
}
|
|
|
|
for (const entry of entries) if (entry) await readEntry(entry);
|
|
setFiles(collected);
|
|
});
|
|
|
|
// Submit
|
|
uploadSubmitBtn.addEventListener('click', async () => {
|
|
const title = uploadTitleInput.value.trim();
|
|
if (!title || pendingFiles.length === 0) return;
|
|
|
|
uploadSubmitBtn.disabled = true;
|
|
uploadProgress.style.display = 'block';
|
|
|
|
const form = new FormData();
|
|
form.append('title', title);
|
|
pendingFiles.forEach(f => form.append('images', f, f.name));
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/api/upload');
|
|
|
|
xhr.upload.addEventListener('progress', e => {
|
|
if (e.lengthComputable) {
|
|
uploadProgressBar.style.width = Math.round((e.loaded / e.total) * 100) + '%';
|
|
}
|
|
});
|
|
|
|
xhr.addEventListener('load', () => {
|
|
if (xhr.status === 200) {
|
|
toast(`"${title}" added to library`);
|
|
closeModal();
|
|
fetchComics();
|
|
} else {
|
|
toast('Upload failed: ' + xhr.responseText, true);
|
|
uploadSubmitBtn.disabled = false;
|
|
uploadProgress.style.display = 'none';
|
|
}
|
|
});
|
|
|
|
xhr.addEventListener('error', () => {
|
|
toast('Upload failed', true);
|
|
uploadSubmitBtn.disabled = false;
|
|
uploadProgress.style.display = 'none';
|
|
});
|
|
|
|
xhr.send(form);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|