1448 lines
55 KiB
HTML
1448 lines
55 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<meta name="theme-color" content="#06090e">
|
|
<meta name="color-scheme" content="dark">
|
|
<title>Phoenix · Visual Comparison Studio</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:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=JetBrains+Mono:wght@400;500;600;700&family=Sora:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
|
|
|
|
<style>
|
|
:root {
|
|
--bg-base: #06090e;
|
|
--bg-surface: #0a0e17;
|
|
--bg-elevated: #101623;
|
|
--glass-bg: rgba(16, 22, 35, 0.72);
|
|
--glass-border: rgba(255, 255, 255, 0.08);
|
|
--glass-hover: rgba(255, 255, 255, 0.12);
|
|
--border-1: rgba(255, 255, 255, 0.06);
|
|
--border-2: rgba(255, 255, 255, 0.12);
|
|
--accent: #7257ff;
|
|
--accent-rgb: 114, 87, 255;
|
|
--accent-light: #9d88ff;
|
|
--cyan: #38bdf8;
|
|
--cyan-rgb: 56, 189, 248;
|
|
--success: #10b981;
|
|
--success-rgb: 16, 185, 129;
|
|
--warning: #f59e0b;
|
|
--danger: #ef4444;
|
|
--text-1: #f8fafc;
|
|
--text-2: #94a3b8;
|
|
--text-3: #64748b;
|
|
--font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
--font-display: 'Sora', sans-serif;
|
|
--font-mono: 'JetBrains Mono', monospace;
|
|
--r-sm: 6px;
|
|
--r-md: 10px;
|
|
--r-lg: 14px;
|
|
--r-full: 9999px;
|
|
--sh-glow: 0 0 24px rgba(var(--accent-rgb), 0.28);
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
|
|
body {
|
|
font-family: var(--font-ui);
|
|
background: var(--bg-base);
|
|
color: var(--text-1);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow-x: hidden;
|
|
background-image:
|
|
radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb), 0.12) 0%, transparent 50%),
|
|
radial-gradient(circle at 100% 100%, rgba(var(--cyan-rgb), 0.06) 0%, transparent 40%);
|
|
}
|
|
|
|
/* ── Top Bar ────────────────────────────────────────── */
|
|
.topbar {
|
|
height: 60px;
|
|
background: var(--glass-bg);
|
|
backdrop-filter: blur(20px);
|
|
-webkit-backdrop-filter: blur(20px);
|
|
border-bottom: 1px solid var(--glass-border);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 20px;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 50;
|
|
}
|
|
|
|
.brand-section {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14px;
|
|
}
|
|
|
|
.brand-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
text-decoration: none;
|
|
color: var(--text-1);
|
|
}
|
|
|
|
.brand-icon {
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: var(--r-md);
|
|
background: linear-gradient(135deg, #7257ff, #38bdf8);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
|
|
}
|
|
|
|
.brand-name {
|
|
font-family: var(--font-display);
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
.brand-sub {
|
|
font-size: 11px;
|
|
color: var(--text-3);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.08em;
|
|
margin-left: 2px;
|
|
}
|
|
|
|
.title-section {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.comparison-title {
|
|
font-family: var(--font-display);
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: var(--text-1);
|
|
}
|
|
|
|
.meta-pill {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 3px 10px;
|
|
border-radius: var(--r-full);
|
|
font-size: 11px;
|
|
font-family: var(--font-mono);
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border: 1px solid var(--border-1);
|
|
color: var(--text-2);
|
|
}
|
|
|
|
.meta-pill.success {
|
|
background: rgba(var(--success-rgb), 0.12);
|
|
border-color: rgba(var(--success-rgb), 0.3);
|
|
color: var(--success);
|
|
}
|
|
|
|
.meta-pill.error {
|
|
background: rgba(239, 68, 68, 0.12);
|
|
border-color: rgba(239, 68, 68, 0.3);
|
|
color: var(--danger);
|
|
}
|
|
|
|
.actions-section {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
/* ── Buttons ────────────────────────────────────────── */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 7px;
|
|
padding: 7px 14px;
|
|
border-radius: var(--r-md);
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
font-family: var(--font-ui);
|
|
cursor: pointer;
|
|
transition: all 0.16s ease;
|
|
text-decoration: none;
|
|
border: 1px solid transparent;
|
|
outline: none;
|
|
}
|
|
|
|
.btn-ghost {
|
|
background: rgba(255, 255, 255, 0.04);
|
|
border-color: var(--border-2);
|
|
color: var(--text-2);
|
|
}
|
|
|
|
.btn-ghost:hover {
|
|
background: var(--glass-hover);
|
|
color: var(--text-1);
|
|
border-color: rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #7257ff, #5935f8);
|
|
color: #fff;
|
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
box-shadow: 0 2px 10px rgba(var(--accent-rgb), 0.35);
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.55);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.btn-success {
|
|
background: rgba(var(--success-rgb), 0.15);
|
|
border-color: rgba(var(--success-rgb), 0.4);
|
|
color: var(--success);
|
|
}
|
|
|
|
.btn-xs {
|
|
padding: 4px 8px;
|
|
font-size: 11px;
|
|
border-radius: var(--r-sm);
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 5px 11px;
|
|
font-size: 11.5px;
|
|
}
|
|
|
|
.btn-icon {
|
|
width: 34px;
|
|
height: 34px;
|
|
padding: 0;
|
|
border-radius: var(--r-md);
|
|
}
|
|
|
|
/* ── Main Layout ────────────────────────────────────── */
|
|
.workspace {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 16px 20px 24px;
|
|
gap: 16px;
|
|
max-width: 1700px;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
/* ── Studio Stage ───────────────────────────────────── */
|
|
.studio-card {
|
|
background: var(--bg-surface);
|
|
border: 1px solid var(--glass-border);
|
|
border-radius: var(--r-lg);
|
|
overflow: hidden;
|
|
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.studio-toolbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 10px 16px;
|
|
background: rgba(0, 0, 0, 0.25);
|
|
border-bottom: 1px solid var(--border-1);
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
|
|
.mode-segmented {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 3px;
|
|
background: rgba(255, 255, 255, 0.04);
|
|
border: 1px solid var(--border-1);
|
|
border-radius: var(--r-md);
|
|
gap: 3px;
|
|
}
|
|
|
|
.mode-btn {
|
|
background: transparent;
|
|
border: none;
|
|
color: var(--text-3);
|
|
font-size: 11.5px;
|
|
font-weight: 600;
|
|
padding: 5px 12px;
|
|
border-radius: var(--r-sm);
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.mode-btn:hover {
|
|
color: var(--text-1);
|
|
}
|
|
|
|
.mode-btn.active {
|
|
background: var(--accent);
|
|
color: #fff;
|
|
box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.45);
|
|
}
|
|
|
|
.stage-viewport {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 64vh;
|
|
min-height: 440px;
|
|
max-height: 820px;
|
|
background: #04060a;
|
|
user-select: none;
|
|
overflow: hidden;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.stage-viewport.mode-split {
|
|
cursor: ew-resize;
|
|
}
|
|
|
|
.stage-viewport.mode-blink {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.viewport-layer {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.layer-before {
|
|
z-index: 1;
|
|
}
|
|
|
|
.layer-after {
|
|
z-index: 2;
|
|
transition: opacity 0.12s ease;
|
|
}
|
|
|
|
.stage-img {
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
object-fit: contain;
|
|
pointer-events: none;
|
|
transition: transform 0.18s ease;
|
|
transform-origin: center center;
|
|
}
|
|
|
|
/* Floating Info Tags */
|
|
.floating-tag {
|
|
position: absolute;
|
|
top: 14px;
|
|
padding: 6px 14px;
|
|
border-radius: var(--r-full);
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
letter-spacing: 0.05em;
|
|
font-family: var(--font-display);
|
|
backdrop-filter: blur(12px);
|
|
-webkit-backdrop-filter: blur(12px);
|
|
z-index: 15;
|
|
pointer-events: none;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 7px;
|
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.15) inset;
|
|
}
|
|
|
|
.tag-before {
|
|
left: 16px;
|
|
background: rgba(245, 158, 11, 0.2);
|
|
border: 1px solid rgba(245, 158, 11, 0.45);
|
|
color: #fbbf24;
|
|
}
|
|
|
|
.tag-after {
|
|
right: 16px;
|
|
background: rgba(16, 185, 129, 0.2);
|
|
border: 1px solid rgba(16, 185, 129, 0.45);
|
|
color: #34d399;
|
|
}
|
|
|
|
/* Divider Handle */
|
|
.stage-divider {
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 2px;
|
|
background: #ffffff;
|
|
box-shadow: 0 0 12px rgba(255, 255, 255, 0.8), 0 0 24px rgba(var(--accent-rgb), 0.7);
|
|
z-index: 20;
|
|
transform: translateX(-50%);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.stage-handle {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
background: rgba(16, 22, 35, 0.95);
|
|
border: 2px solid #ffffff;
|
|
box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.7), 0 6px 20px rgba(0, 0, 0, 0.7);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 3px;
|
|
color: #ffffff;
|
|
font-size: 11px;
|
|
cursor: ew-resize;
|
|
pointer-events: auto;
|
|
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
|
}
|
|
|
|
.stage-handle:hover,
|
|
.stage-viewport:active .stage-handle {
|
|
transform: translate(-50%, -50%) scale(1.15);
|
|
box-shadow: 0 0 26px var(--accent), 0 8px 30px rgba(0, 0, 0, 0.9);
|
|
}
|
|
|
|
/* Side by Side Mode */
|
|
.stage-viewport.mode-side {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 12px;
|
|
padding: 14px;
|
|
cursor: default;
|
|
}
|
|
|
|
.stage-viewport.mode-side .viewport-layer {
|
|
position: relative;
|
|
inset: auto;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: rgba(0, 0, 0, 0.35);
|
|
border: 1px solid var(--border-1);
|
|
border-radius: var(--r-md);
|
|
}
|
|
|
|
.stage-viewport.mode-side .layer-after {
|
|
clip-path: none !important;
|
|
}
|
|
|
|
.stage-viewport.mode-side .stage-divider {
|
|
display: none;
|
|
}
|
|
|
|
/* Blink Mode */
|
|
.stage-viewport.mode-blink .layer-after {
|
|
clip-path: none !important;
|
|
}
|
|
|
|
.stage-viewport.mode-blink .stage-divider {
|
|
display: none;
|
|
}
|
|
|
|
/* Controls Slider Bar */
|
|
.slider-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 10px;
|
|
padding: 10px 16px;
|
|
background: rgba(0, 0, 0, 0.32);
|
|
border-top: 1px solid var(--border-1);
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.range-slider {
|
|
flex: 1;
|
|
max-width: 480px;
|
|
min-width: 160px;
|
|
accent-color: var(--accent);
|
|
cursor: pointer;
|
|
height: 6px;
|
|
}
|
|
|
|
.studio-footer {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 10px 16px;
|
|
background: rgba(0, 0, 0, 0.18);
|
|
border-top: 1px solid var(--border-1);
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
|
|
/* ── Carousel Strip ─────────────────────────────────── */
|
|
.carousel-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.carousel-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 4px;
|
|
}
|
|
|
|
.carousel-header-title {
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
color: var(--text-2);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.carousel-nav-btns {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.carousel-strip {
|
|
display: flex;
|
|
align-items: stretch;
|
|
gap: 10px;
|
|
overflow-x: auto;
|
|
padding: 6px 2px 14px;
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
.carousel-strip::-webkit-scrollbar {
|
|
height: 7px;
|
|
}
|
|
|
|
.carousel-strip::-webkit-scrollbar-track {
|
|
background: rgba(255, 255, 255, 0.03);
|
|
border-radius: var(--r-full);
|
|
}
|
|
|
|
.carousel-strip::-webkit-scrollbar-thumb {
|
|
background: rgba(255, 255, 255, 0.15);
|
|
border-radius: var(--r-full);
|
|
}
|
|
|
|
.carousel-card {
|
|
flex: 0 0 160px;
|
|
background: var(--bg-surface);
|
|
border: 1px solid var(--border-1);
|
|
border-radius: var(--r-md);
|
|
padding: 8px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.16s ease;
|
|
position: relative;
|
|
}
|
|
|
|
.carousel-card:hover {
|
|
border-color: var(--border-2);
|
|
transform: translateY(-2px);
|
|
background: var(--bg-elevated);
|
|
}
|
|
|
|
.carousel-card.active {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.35), 0 0 0 1px var(--accent);
|
|
background: var(--bg-elevated);
|
|
}
|
|
|
|
.carousel-thumb-wrap {
|
|
width: 100%;
|
|
height: 94px;
|
|
background: #020408;
|
|
border-radius: var(--r-sm);
|
|
overflow: hidden;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
position: relative;
|
|
}
|
|
|
|
.carousel-thumb-img {
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.carousel-card-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
font-size: 11px;
|
|
color: var(--text-3);
|
|
font-family: var(--font-mono);
|
|
}
|
|
|
|
.carousel-card-title {
|
|
font-size: 11.5px;
|
|
font-weight: 600;
|
|
color: var(--text-1);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* ── Grid Mode ──────────────────────────────────────── */
|
|
.gallery-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
|
|
gap: 16px;
|
|
width: 100%;
|
|
}
|
|
|
|
.grid-card {
|
|
background: var(--bg-surface);
|
|
border: 1px solid var(--glass-border);
|
|
border-radius: var(--r-lg);
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.grid-card:hover {
|
|
border-color: rgba(255, 255, 255, 0.2);
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
|
|
}
|
|
|
|
.grid-card-stage {
|
|
position: relative;
|
|
height: 240px;
|
|
background: #04060a;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.grid-card-info {
|
|
padding: 12px 14px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
background: rgba(0, 0, 0, 0.2);
|
|
border-top: 1px solid var(--border-1);
|
|
}
|
|
|
|
/* ── Toasts ─────────────────────────────────────────── */
|
|
#toast-container {
|
|
position: fixed;
|
|
bottom: 24px;
|
|
right: 24px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
z-index: 9999;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.toast {
|
|
pointer-events: auto;
|
|
padding: 10px 18px;
|
|
background: rgba(16, 22, 35, 0.95);
|
|
backdrop-filter: blur(16px);
|
|
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
border-radius: var(--r-md);
|
|
color: #fff;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
}
|
|
|
|
@keyframes toastIn {
|
|
from { opacity: 0; transform: translateY(12px) scale(0.96); }
|
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
}
|
|
|
|
/* ── Modal / Overlay ────────────────────────────────── */
|
|
.modal-overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(0, 0, 0, 0.75);
|
|
backdrop-filter: blur(12px);
|
|
-webkit-backdrop-filter: blur(12px);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 1000;
|
|
padding: 20px;
|
|
}
|
|
|
|
.modal-card {
|
|
background: var(--bg-surface);
|
|
border: 1px solid var(--border-2);
|
|
border-radius: var(--r-lg);
|
|
width: min(580px, 95vw);
|
|
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid var(--border-1);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 20px;
|
|
overflow-y: auto;
|
|
max-height: 70vh;
|
|
}
|
|
|
|
.modal-footer {
|
|
padding: 14px 20px;
|
|
border-top: 1px solid var(--border-1);
|
|
background: rgba(0, 0, 0, 0.2);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
gap: 10px;
|
|
}
|
|
|
|
/* ── Empty State ────────────────────────────────────── */
|
|
.empty-wrap {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 60vh;
|
|
gap: 16px;
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 48px;
|
|
color: var(--text-3);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
/* ── Responsive ─────────────────────────────────────── */
|
|
@media (max-width: 768px) {
|
|
.topbar {
|
|
padding: 0 12px;
|
|
height: 54px;
|
|
}
|
|
.brand-sub, .carousel-card-title {
|
|
display: none;
|
|
}
|
|
.stage-viewport {
|
|
height: 50vh;
|
|
min-height: 320px;
|
|
}
|
|
.carousel-card {
|
|
flex: 0 0 120px;
|
|
}
|
|
.carousel-thumb-wrap {
|
|
height: 72px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ── Top Navigation Bar ───────────────────────────────── -->
|
|
<header class="topbar">
|
|
<div class="brand-section">
|
|
<a href="/" class="brand-badge" title="Go to Phoenix Suite">
|
|
<div class="brand-icon"><i class="fa-solid fa-layer-group"></i></div>
|
|
<div>
|
|
<span class="brand-name">PHOENIX</span>
|
|
<span class="brand-sub">Comparison Studio</span>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="title-section" id="title-section">
|
|
<span class="comparison-title" id="comp-title">Loading comparison...</span>
|
|
<div id="stats-pill-container" style="display:flex; gap:6px;"></div>
|
|
</div>
|
|
|
|
<div class="actions-section">
|
|
<button class="btn btn-ghost btn-sm" id="btn-toggle-view" onclick="Studio.toggleViewMode()">
|
|
<i class="fa-solid fa-table-cells"></i> <span id="toggle-view-text">Grid View</span>
|
|
</button>
|
|
<button class="btn btn-ghost btn-sm" onclick="Studio.downloadAllZip()">
|
|
<i class="fa-solid fa-file-zipper"></i> ZIP
|
|
</button>
|
|
<button class="btn btn-primary btn-sm" id="btn-copy-share" onclick="Studio.copyShareLink()">
|
|
<i class="fa-solid fa-share-nodes"></i> Copy Link
|
|
</button>
|
|
<button class="btn btn-ghost btn-icon btn-sm" onclick="Studio.toggleFullscreen()" title="Fullscreen mode (F)">
|
|
<i class="fa-solid fa-expand"></i>
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- ── Main Workspace ───────────────────────────────────── -->
|
|
<main class="workspace" id="main-workspace">
|
|
<!-- Loaded via Studio.render() -->
|
|
<div class="empty-wrap" id="loading-state">
|
|
<i class="fa-solid fa-spinner fa-spin empty-icon" style="color:var(--accent);"></i>
|
|
<h3>Loading visual comparison snapshot...</h3>
|
|
<p style="color:var(--text-3); font-size:12px;">Fetching batch results and high-resolution assets</p>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- ── Toast Notifications ──────────────────────────────── -->
|
|
<div id="toast-container"></div>
|
|
|
|
<!-- ── Comparison Studio Logic ──────────────────────────── -->
|
|
<script>
|
|
const Studio = {
|
|
data: null,
|
|
currentIndex: 0,
|
|
mode: 'split', // 'split' | 'side' | 'blink'
|
|
splitPos: 50,
|
|
viewMode: 'studio', // 'studio' | 'grid'
|
|
zoomLevel: 1,
|
|
autoBlinkInterval: null,
|
|
isBlinkShowingAfter: true,
|
|
|
|
resolveAssetUrl(url) {
|
|
if (!url) return '';
|
|
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('data:') || url.startsWith('blob:')) {
|
|
return url;
|
|
}
|
|
const prefix = window.location.pathname.includes('/tool/bulk-api-tester') ? '/tool/bulk-api-tester' : '';
|
|
if (url.startsWith('/') && !url.startsWith(prefix)) {
|
|
return prefix + url;
|
|
}
|
|
return url;
|
|
},
|
|
|
|
init() {
|
|
// 1. Check for pre-injected data
|
|
const injected = document.getElementById('comparison-initial-data');
|
|
if (injected && injected.textContent.trim()) {
|
|
try {
|
|
this.data = JSON.parse(injected.textContent);
|
|
this.onDataLoaded();
|
|
return;
|
|
} catch(e) {
|
|
console.error("Failed to parse pre-injected comparison data", e);
|
|
}
|
|
}
|
|
|
|
// 2. Extract comparison ID from URL
|
|
const id = this.extractIdFromURL();
|
|
if (!id) {
|
|
this.renderError("Missing Comparison ID", "Please verify the link or URL query parameters.");
|
|
return;
|
|
}
|
|
|
|
// 3. Fetch from backend API
|
|
this.fetchComparison(id);
|
|
this.bindKeyboardShortcuts();
|
|
},
|
|
|
|
extractIdFromURL() {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
if (urlParams.get('id')) return urlParams.get('id');
|
|
const path = window.location.pathname;
|
|
const match = path.match(/\/compare\/([a-zA-Z0-9_\-]+)/);
|
|
if (match && match[1]) return match[1];
|
|
return null;
|
|
},
|
|
|
|
async fetchComparison(id) {
|
|
try {
|
|
// Determine prefix if under gateway proxy
|
|
const basePath = window.location.pathname.includes('/tool/bulk-api-tester') ? '/tool/bulk-api-tester' : '';
|
|
const res = await fetch(`${basePath}/api/comparison/${id}`);
|
|
if (!res.ok) {
|
|
throw new Error(`HTTP ${res.status}: Comparison not found or expired`);
|
|
}
|
|
this.data = await res.json();
|
|
this.onDataLoaded();
|
|
} catch(e) {
|
|
this.renderError("Comparison Not Found", e.message);
|
|
}
|
|
},
|
|
|
|
onDataLoaded() {
|
|
if (!this.data || !this.data.items || this.data.items.length === 0) {
|
|
this.renderError("No Results in Comparison", "This comparison session contains no result items.");
|
|
return;
|
|
}
|
|
|
|
// Update Page Title and Header
|
|
document.title = `${this.data.title || 'Visual Comparison'} · Phoenix`;
|
|
const compTitleEl = document.getElementById('comp-title');
|
|
if (compTitleEl) compTitleEl.textContent = this.data.title || 'Batch Results Comparison';
|
|
|
|
const statsContainer = document.getElementById('stats-pill-container');
|
|
if (statsContainer) {
|
|
statsContainer.innerHTML = `
|
|
<span class="meta-pill"><i class="fa-solid fa-list-check"></i> ${this.data.total} Items</span>
|
|
${this.data.successCount > 0 ? `<span class="meta-pill success"><i class="fa-solid fa-check"></i> ${this.data.successCount} OK</span>` : ''}
|
|
${this.data.errorCount > 0 ? `<span class="meta-pill error"><i class="fa-solid fa-triangle-exclamation"></i> ${this.data.errorCount} Failed</span>` : ''}
|
|
${this.data.avgLatency > 0 ? `<span class="meta-pill"><i class="fa-solid fa-gauge-high"></i> ${this.data.avgLatency}ms</span>` : ''}
|
|
`;
|
|
}
|
|
|
|
this.render();
|
|
},
|
|
|
|
render() {
|
|
const workspace = document.getElementById('main-workspace');
|
|
if (!workspace || !this.data) return;
|
|
|
|
if (this.viewMode === 'grid') {
|
|
this.renderGridView(workspace);
|
|
} else {
|
|
this.renderStudioView(workspace);
|
|
}
|
|
},
|
|
|
|
renderStudioView(workspace) {
|
|
const item = this.data.items[this.currentIndex];
|
|
if (!item) return;
|
|
|
|
const isImage = (item.contentType || '').toLowerCase().includes('image') || item.hasAfter;
|
|
const beforeSrc = item.beforeImage ? this.resolveAssetUrl(item.beforeImage) : '';
|
|
const afterSrc = item.afterImage ? this.resolveAssetUrl(item.afterImage) : '';
|
|
const finalFilename = item.outputFilename || `result_${item.index}.png`;
|
|
const inputFilename = item.inputFilename || 'Original Input';
|
|
const statusClass = (typeof item.status === 'number' && item.status >= 200 && item.status < 300) || String(item.status).startsWith('2') ? 'success' : 'error';
|
|
|
|
let stageContentHTML = '';
|
|
|
|
if (isImage) {
|
|
stageContentHTML = `
|
|
<div class="stage-viewport mode-${this.mode}" id="studio-stage"
|
|
onmousedown="Studio.handleMouseDown(event)"
|
|
ontouchstart="Studio.handleTouchStart(event)">
|
|
|
|
<!-- BEFORE Layer -->
|
|
<div class="viewport-layer layer-before">
|
|
${beforeSrc ? `
|
|
<img src="${beforeSrc}" class="stage-img" id="img-before" alt="Original Input" draggable="false" style="transform:scale(${this.zoomLevel})" />
|
|
<div class="floating-tag tag-before"><i class="fa-solid fa-arrow-left"></i> BEFORE: ${this.escapeHTML(inputFilename)}</div>
|
|
` : `
|
|
<div style="color:var(--text-3); font-size:12px; display:flex; flex-direction:column; align-items:center; gap:8px;">
|
|
<i class="fa-solid fa-image" style="font-size:24px;"></i>
|
|
<span>No Reference Input Image Recorded</span>
|
|
</div>
|
|
`}
|
|
</div>
|
|
|
|
<!-- AFTER Layer -->
|
|
<div class="viewport-layer layer-after" id="layer-after" style="clip-path: polygon(${this.splitPos}% 0, 100% 0, 100% 100%, ${this.splitPos}% 100%);">
|
|
${afterSrc ? `
|
|
<img src="${afterSrc}" class="stage-img" id="img-after" alt="Processed Output" draggable="false" style="transform:scale(${this.zoomLevel})" />
|
|
<div class="floating-tag tag-after">AFTER: ${this.escapeHTML(finalFilename)} <i class="fa-solid fa-arrow-right"></i></div>
|
|
` : `
|
|
<div style="color:var(--text-3); font-size:12px;">No Output Image</div>
|
|
`}
|
|
</div>
|
|
|
|
<!-- Draggable Divider -->
|
|
<div class="stage-divider" id="stage-divider" style="left: ${this.splitPos}%;">
|
|
<div class="stage-handle">
|
|
<i class="fa-solid fa-caret-left"></i>
|
|
<i class="fa-solid fa-grip-lines-vertical" style="font-size:9px; opacity:0.5;"></i>
|
|
<i class="fa-solid fa-caret-right"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Split Slider Control Bar -->
|
|
<div class="slider-bar" id="studio-slider-bar" style="display:${this.mode === 'split' ? 'flex' : 'none'};">
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setSplit(0)">100% Original</button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setSplit(25)">25%</button>
|
|
<input type="range" class="range-slider" id="split-range" min="0" max="100" value="${this.splitPos}" oninput="Studio.setSplit(this.value)">
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setSplit(50)">50% Split</button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setSplit(75)">75%</button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setSplit(100)">100% Result</button>
|
|
<span class="meta-pill" id="split-badge" style="font-weight:700;">${Math.round(this.splitPos)}%</span>
|
|
</div>
|
|
`;
|
|
} else {
|
|
let prettyText = item.textContent || '';
|
|
try {
|
|
if (prettyText.trim().startsWith('{')) prettyText = JSON.stringify(JSON.parse(prettyText), null, 2);
|
|
} catch(e) {}
|
|
|
|
stageContentHTML = `
|
|
<div style="padding:20px; max-height:64vh; overflow:auto; background:#04060a;">
|
|
<pre style="font-family:var(--font-mono); font-size:12px; color:var(--cyan); line-height:1.5;">${this.escapeHTML(prettyText)}</pre>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
workspace.innerHTML = `
|
|
<div class="studio-card">
|
|
<!-- Studio Header Toolbar -->
|
|
<div class="studio-toolbar">
|
|
<div style="display:flex; align-items:center; gap:12px;">
|
|
<span style="font-family:var(--font-display); font-weight:700; font-size:15px; color:var(--text-1);">
|
|
Result #${item.index} of ${this.data.total}
|
|
</span>
|
|
<span class="meta-pill ${statusClass}">${item.status}</span>
|
|
<span class="meta-pill"><i class="fa-regular fa-clock"></i> ${item.latency}ms</span>
|
|
</div>
|
|
|
|
${isImage ? `
|
|
<div class="mode-segmented">
|
|
<button class="mode-btn ${this.mode === 'split' ? 'active' : ''}" onclick="Studio.setMode('split')">
|
|
<i class="fa-solid fa-arrows-split-up-and-left"></i> Split Slider
|
|
</button>
|
|
<button class="mode-btn ${this.mode === 'side' ? 'active' : ''}" onclick="Studio.setMode('side')">
|
|
<i class="fa-solid fa-table-columns"></i> Side-by-Side
|
|
</button>
|
|
<button class="mode-btn ${this.mode === 'blink' ? 'active' : ''}" onclick="Studio.setMode('blink')">
|
|
<i class="fa-solid fa-bolt"></i> Blink Diff
|
|
</button>
|
|
</div>
|
|
` : ''}
|
|
|
|
<div style="display:flex; align-items:center; gap:8px;">
|
|
${isImage ? `
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setZoom(1)" title="Reset Zoom">Fit</button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.setZoom(2)" title="Zoom 2x">2x</button>
|
|
` : ''}
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.prevItem()" title="Previous Result (Left Arrow)">
|
|
<i class="fa-solid fa-chevron-left"></i>
|
|
</button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.nextItem()" title="Next Result (Right Arrow)">
|
|
<i class="fa-solid fa-chevron-right"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Stage Viewport -->
|
|
${stageContentHTML}
|
|
|
|
<!-- Studio Footer Actions -->
|
|
<div class="studio-footer">
|
|
<div style="display:flex; align-items:center; gap:10px; font-size:11.5px; color:var(--text-2);">
|
|
<span><b style="color:var(--text-1);">${this.escapeHTML(inputFilename)}</b> → <b style="color:var(--cyan);">${this.escapeHTML(finalFilename)}</b></span>
|
|
</div>
|
|
<div style="display:flex; align-items:center; gap:8px;">
|
|
${beforeSrc ? `
|
|
<button class="btn btn-ghost btn-sm" onclick="Studio.downloadImage('${beforeSrc}', '${this.escapeHTML(inputFilename)}')">
|
|
<i class="fa-solid fa-download"></i> Download Before
|
|
</button>
|
|
` : ''}
|
|
${afterSrc ? `
|
|
<button class="btn btn-primary btn-sm" onclick="Studio.downloadImage('${afterSrc}', '${this.escapeHTML(finalFilename)}')">
|
|
<i class="fa-solid fa-arrow-down"></i> Download After
|
|
</button>
|
|
` : ''}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Carousel Strip Strip Navigation -->
|
|
<div class="carousel-container">
|
|
<div class="carousel-header">
|
|
<div class="carousel-header-title">
|
|
<i class="fa-solid fa-images"></i>
|
|
<span>Results Sequence (${this.data.total})</span>
|
|
</div>
|
|
<div class="carousel-nav-btns">
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.scrollCarousel(-300)"><i class="fa-solid fa-arrow-left"></i></button>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.scrollCarousel(300)"><i class="fa-solid fa-arrow-right"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="carousel-strip" id="carousel-strip">
|
|
${this.data.items.map((it, idx) => `
|
|
<div class="carousel-card ${idx === this.currentIndex ? 'active' : ''}" onclick="Studio.selectItem(${idx})">
|
|
<div class="carousel-thumb-wrap">
|
|
${it.afterImage ? `<img src="${this.resolveAssetUrl(it.afterImage)}" class="carousel-thumb-img" loading="lazy" />` : `<i class="fa-solid fa-file-code" style="color:var(--text-3); font-size:24px;"></i>`}
|
|
</div>
|
|
<div class="carousel-card-title" title="${this.escapeHTML(it.outputFilename || it.inputFilename || '')}">
|
|
${this.escapeHTML(it.outputFilename || it.inputFilename || `Result #${it.index}`)}
|
|
</div>
|
|
<div class="carousel-card-meta">
|
|
<span>#${it.index}</span>
|
|
<span style="color:${String(it.status).startsWith('2') ? 'var(--success)' : 'var(--danger)'}; font-weight:700;">${it.status}</span>
|
|
<span>${it.latency}ms</span>
|
|
</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
</div>
|
|
`;
|
|
},
|
|
|
|
renderGridView(workspace) {
|
|
workspace.innerHTML = `
|
|
<div class="gallery-grid">
|
|
${this.data.items.map((it, idx) => `
|
|
<div class="grid-card">
|
|
<div class="grid-card-stage" onclick="Studio.selectItemAndOpenStudio(${idx})" style="cursor:pointer;" title="Click to view full comparison">
|
|
${it.afterImage ? `<img src="${this.resolveAssetUrl(it.afterImage)}" style="max-width:100%; max-height:100%; object-fit:contain;" loading="lazy" />` : `<i class="fa-solid fa-file-code" style="color:var(--text-3); font-size:32px;"></i>`}
|
|
</div>
|
|
<div class="grid-card-info">
|
|
<div style="display:flex; justify-content:space-between; align-items:center;">
|
|
<span style="font-weight:700; font-size:13px;">#${it.index} · ${this.escapeHTML(it.outputFilename || it.inputFilename || 'Result')}</span>
|
|
<span class="meta-pill ${String(it.status).startsWith('2') ? 'success' : 'error'}">${it.status}</span>
|
|
</div>
|
|
<div style="display:flex; justify-content:space-between; align-items:center; font-size:11.5px; color:var(--text-3);">
|
|
<span>${it.latency}ms</span>
|
|
<button class="btn btn-ghost btn-xs" onclick="Studio.selectItemAndOpenStudio(${idx})">
|
|
<i class="fa-solid fa-expand"></i> Studio View
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
`;
|
|
},
|
|
|
|
selectItem(idx) {
|
|
if (idx < 0 || idx >= this.data.items.length) return;
|
|
this.currentIndex = idx;
|
|
this.render();
|
|
this.scrollActiveThumbnailIntoView();
|
|
},
|
|
|
|
selectItemAndOpenStudio(idx) {
|
|
this.currentIndex = idx;
|
|
this.viewMode = 'studio';
|
|
document.getElementById('toggle-view-text').textContent = 'Grid View';
|
|
this.render();
|
|
this.scrollActiveThumbnailIntoView();
|
|
},
|
|
|
|
prevItem() {
|
|
if (this.currentIndex > 0) {
|
|
this.selectItem(this.currentIndex - 1);
|
|
} else {
|
|
this.selectItem(this.data.items.length - 1);
|
|
}
|
|
},
|
|
|
|
nextItem() {
|
|
if (this.currentIndex < this.data.items.length - 1) {
|
|
this.selectItem(this.currentIndex + 1);
|
|
} else {
|
|
this.selectItem(0);
|
|
}
|
|
},
|
|
|
|
scrollCarousel(amount) {
|
|
const strip = document.getElementById('carousel-strip');
|
|
if (strip) strip.scrollBy({ left: amount, behavior: 'smooth' });
|
|
},
|
|
|
|
scrollActiveThumbnailIntoView() {
|
|
setTimeout(() => {
|
|
const strip = document.getElementById('carousel-strip');
|
|
const active = strip ? strip.querySelector('.carousel-card.active') : null;
|
|
if (active && strip) {
|
|
const stripRect = strip.getBoundingClientRect();
|
|
const activeRect = active.getBoundingClientRect();
|
|
if (activeRect.left < stripRect.left || activeRect.right > stripRect.right) {
|
|
active.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
|
|
}
|
|
}
|
|
}, 60);
|
|
},
|
|
|
|
setMode(mode) {
|
|
this.mode = mode;
|
|
if (this.autoBlinkInterval) {
|
|
clearInterval(this.autoBlinkInterval);
|
|
this.autoBlinkInterval = null;
|
|
}
|
|
this.render();
|
|
|
|
if (mode === 'blink') {
|
|
const stage = document.getElementById('studio-stage');
|
|
if (stage) {
|
|
this.isBlinkShowingAfter = true;
|
|
stage.onclick = () => {
|
|
this.isBlinkShowingAfter = !this.isBlinkShowingAfter;
|
|
const layer = document.getElementById('layer-after');
|
|
if (layer) layer.style.opacity = this.isBlinkShowingAfter ? '1' : '0';
|
|
};
|
|
}
|
|
}
|
|
},
|
|
|
|
setSplit(val) {
|
|
val = Math.max(0, Math.min(100, parseFloat(val) || 50));
|
|
this.splitPos = val;
|
|
const layer = document.getElementById('layer-after');
|
|
const divider = document.getElementById('stage-divider');
|
|
const badge = document.getElementById('split-badge');
|
|
const range = document.getElementById('split-range');
|
|
|
|
if (layer) layer.style.clipPath = `polygon(${val}% 0, 100% 0, 100% 100%, ${val}% 100%)`;
|
|
if (divider) divider.style.left = `${val}%`;
|
|
if (badge) badge.textContent = `${Math.round(val)}%`;
|
|
if (range && range.value != val) range.value = val;
|
|
},
|
|
|
|
setZoom(level) {
|
|
this.zoomLevel = level;
|
|
const before = document.getElementById('img-before');
|
|
const after = document.getElementById('img-after');
|
|
if (before) before.style.transform = `scale(${level})`;
|
|
if (after) after.style.transform = `scale(${level})`;
|
|
this.toast(`Zoom set to ${level}x`, 'info');
|
|
},
|
|
|
|
toggleViewMode() {
|
|
this.viewMode = this.viewMode === 'studio' ? 'grid' : 'studio';
|
|
const btnText = document.getElementById('toggle-view-text');
|
|
if (btnText) btnText.textContent = this.viewMode === 'studio' ? 'Grid View' : 'Studio View';
|
|
this.render();
|
|
},
|
|
|
|
toggleFullscreen() {
|
|
if (!document.fullscreenElement) {
|
|
document.documentElement.requestFullscreen().catch(() => {});
|
|
} else {
|
|
document.exitFullscreen().catch(() => {});
|
|
}
|
|
},
|
|
|
|
handleMouseDown(e) {
|
|
if (this.mode !== 'split') return;
|
|
e.preventDefault();
|
|
const stage = document.getElementById('studio-stage');
|
|
if (!stage) return;
|
|
|
|
const update = (moveEv) => {
|
|
const rect = stage.getBoundingClientRect();
|
|
if (rect.width <= 0) return;
|
|
const x = moveEv.clientX - rect.left;
|
|
this.setSplit((x / rect.width) * 100);
|
|
};
|
|
|
|
update(e);
|
|
|
|
const onMove = (ev) => update(ev);
|
|
const onUp = () => {
|
|
window.removeEventListener('mousemove', onMove);
|
|
window.removeEventListener('mouseup', onUp);
|
|
};
|
|
|
|
window.addEventListener('mousemove', onMove);
|
|
window.addEventListener('mouseup', onUp);
|
|
},
|
|
|
|
handleTouchStart(e) {
|
|
if (this.mode !== 'split') return;
|
|
const stage = document.getElementById('studio-stage');
|
|
if (!stage || !e.touches || !e.touches[0]) return;
|
|
|
|
const update = (touchEv) => {
|
|
if (!touchEv.touches || !touchEv.touches[0]) return;
|
|
const rect = stage.getBoundingClientRect();
|
|
if (rect.width <= 0) return;
|
|
const x = touchEv.touches[0].clientX - rect.left;
|
|
this.setSplit((x / rect.width) * 100);
|
|
};
|
|
|
|
update(e);
|
|
|
|
const onMove = (ev) => update(ev);
|
|
const onEnd = () => {
|
|
window.removeEventListener('touchmove', onMove);
|
|
window.removeEventListener('touchend', onEnd);
|
|
};
|
|
|
|
window.addEventListener('touchmove', onMove, { passive: true });
|
|
window.addEventListener('touchend', onEnd);
|
|
},
|
|
|
|
bindKeyboardShortcuts() {
|
|
window.addEventListener('keydown', (e) => {
|
|
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
|
|
|
if (e.key === 'ArrowLeft') {
|
|
e.preventDefault();
|
|
this.prevItem();
|
|
} else if (e.key === 'ArrowRight') {
|
|
e.preventDefault();
|
|
this.nextItem();
|
|
} else if (e.key === '1') {
|
|
this.setMode('split');
|
|
} else if (e.key === '2') {
|
|
this.setMode('side');
|
|
} else if (e.key === '3') {
|
|
this.setMode('blink');
|
|
} else if (e.key === 'f' || e.key === 'F') {
|
|
this.toggleFullscreen();
|
|
} else if (e.key === ' ' && this.mode === 'blink') {
|
|
e.preventDefault();
|
|
this.isBlinkShowingAfter = !this.isBlinkShowingAfter;
|
|
const layer = document.getElementById('layer-after');
|
|
if (layer) layer.style.opacity = this.isBlinkShowingAfter ? '1' : '0';
|
|
}
|
|
});
|
|
},
|
|
|
|
async copyShareLink() {
|
|
const btn = document.getElementById('btn-copy-share');
|
|
const url = window.location.href;
|
|
try {
|
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
await navigator.clipboard.writeText(url);
|
|
} else {
|
|
const ta = document.createElement('textarea');
|
|
ta.value = url;
|
|
document.body.appendChild(ta);
|
|
ta.select();
|
|
document.execCommand('copy');
|
|
ta.remove();
|
|
}
|
|
|
|
if (btn) {
|
|
const orig = btn.innerHTML;
|
|
btn.innerHTML = `<i class="fa-solid fa-check"></i> Copied!`;
|
|
btn.classList.add('btn-success');
|
|
setTimeout(() => {
|
|
btn.innerHTML = orig;
|
|
btn.classList.remove('btn-success');
|
|
}, 2200);
|
|
}
|
|
this.toast('Comparison link copied to clipboard!', 'success');
|
|
} catch(e) {
|
|
this.toast('Failed to copy link', 'error');
|
|
}
|
|
},
|
|
|
|
downloadImage(url, filename) {
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = filename || 'image.png';
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
a.remove();
|
|
this.toast(`Downloading ${filename}`, 'info');
|
|
},
|
|
|
|
async downloadAllZip() {
|
|
if (!this.data || !this.data.items || !window.JSZip) {
|
|
return this.toast("JSZip library not available", "error");
|
|
}
|
|
|
|
this.toast("Packaging results into ZIP...", "info");
|
|
const zip = new JSZip();
|
|
const folder = zip.folder("comparison_results");
|
|
|
|
let count = 0;
|
|
for (const item of this.data.items) {
|
|
const afterUrl = item.afterImage ? this.resolveAssetUrl(item.afterImage) : '';
|
|
if (afterUrl) {
|
|
try {
|
|
const blob = await fetch(afterUrl).then(r => r.blob());
|
|
const fname = item.outputFilename || `result_${item.index}.png`;
|
|
folder.file(fname, blob);
|
|
count++;
|
|
} catch(e) {
|
|
console.error("ZIP download item error", e);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count === 0) {
|
|
return this.toast("No image files to package", "warning");
|
|
}
|
|
|
|
const content = await zip.generateAsync({ type: "blob" });
|
|
const a = document.createElement('a');
|
|
a.href = URL.createObjectURL(content);
|
|
a.download = `comparison_${this.data.id || 'batch'}.zip`;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
a.remove();
|
|
this.toast(`Downloaded ZIP with ${count} files`, 'success');
|
|
},
|
|
|
|
toast(msg, type = 'info') {
|
|
const container = document.getElementById('toast-container');
|
|
if (!container) return;
|
|
|
|
const t = document.createElement('div');
|
|
t.className = 'toast';
|
|
const icon = type === 'success' ? 'fa-circle-check' : (type === 'error' ? 'fa-circle-exclamation' : 'fa-circle-info');
|
|
const color = type === 'success' ? 'var(--success)' : (type === 'error' ? 'var(--danger)' : 'var(--cyan)');
|
|
t.innerHTML = `<i class="fa-solid ${icon}" style="color:${color};"></i><span>${this.escapeHTML(msg)}</span>`;
|
|
container.appendChild(t);
|
|
|
|
setTimeout(() => {
|
|
t.style.opacity = '0';
|
|
t.style.transform = 'translateY(8px)';
|
|
t.style.transition = 'all 0.25s ease';
|
|
setTimeout(() => t.remove(), 260);
|
|
}, 3000);
|
|
},
|
|
|
|
renderError(title, msg) {
|
|
const workspace = document.getElementById('main-workspace');
|
|
if (!workspace) return;
|
|
workspace.innerHTML = `
|
|
<div class="empty-wrap">
|
|
<i class="fa-solid fa-triangle-exclamation empty-icon" style="color:var(--danger);"></i>
|
|
<h2 style="font-family:var(--font-display);">${this.escapeHTML(title)}</h2>
|
|
<p style="color:var(--text-2); max-width:440px;">${this.escapeHTML(msg)}</p>
|
|
<a href="/tool/bulk-api-tester/" class="btn btn-primary btn-sm" style="margin-top:12px;">
|
|
<i class="fa-solid fa-arrow-left"></i> Return to Bulk API Tester
|
|
</a>
|
|
</div>
|
|
`;
|
|
},
|
|
|
|
escapeHTML(str) {
|
|
if (!str) return '';
|
|
return String(str).replace(/[&<>'"]/g, tag => ({
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
"'": ''',
|
|
'"': '"'
|
|
}[tag] || tag));
|
|
}
|
|
};
|
|
|
|
// Auto-initialize when DOM is ready
|
|
document.addEventListener('DOMContentLoaded', () => Studio.init());
|
|
</script>
|
|
</body>
|
|
</html>
|