Initial commit: unified dashboard suite state with Khira and Image Manipulator 3-file setup
This commit is contained in:
@@ -0,0 +1,767 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
||||
<title>JSON Infinity Studio — Documentation</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0a0e1a; --bg2: #111827; --bg3: #1a2236; --bg-card: #151d2e;
|
||||
--bg-hover: #1c2740; --bg-input: #0d1220; --accent: #6366f1; --accent2: #8b5cf6;
|
||||
--accent-glow: rgba(99,102,241,0.25); --success: #10b981; --warning: #f59e0b;
|
||||
--danger: #ef4444; --info: #06b6d4; --pink: #ec4899;
|
||||
--text: #f1f5f9; --text2: #94a3b8; --text3: #64748b; --text4: #475569;
|
||||
--border: #1e293b; --border2: #334155; --radius: 12px; --radius-sm: 8px;
|
||||
}
|
||||
* { margin:0; padding:0; box-sizing:border-box; }
|
||||
html { scroll-behavior: smooth; }
|
||||
body { font-family:'Inter',sans-serif; background:var(--bg); color:var(--text); line-height:1.7; -webkit-font-smoothing:antialiased; }
|
||||
::-webkit-scrollbar { width:6px; } ::-webkit-scrollbar-track { background:transparent; }
|
||||
::-webkit-scrollbar-thumb { background:var(--border2); border-radius:3px; }
|
||||
::selection { background:var(--accent); color:#fff; }
|
||||
|
||||
/* Layout */
|
||||
.docs-layout { display:grid; grid-template-columns:260px 1fr; min-height:100vh; }
|
||||
|
||||
/* Sidebar Nav */
|
||||
.docs-nav { background:var(--bg2); border-right:1px solid var(--border); position:sticky; top:0; height:100vh; overflow-y:auto; padding:0; }
|
||||
.nav-header { padding:20px 18px; border-bottom:1px solid var(--border); }
|
||||
.nav-header h1 { font-size:14px; font-weight:800; background:linear-gradient(135deg,var(--accent),var(--accent2)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
|
||||
.nav-header .subtitle { font-size:10px; color:var(--text3); text-transform:uppercase; letter-spacing:1.5px; margin-top:2px; }
|
||||
.nav-back { display:flex; align-items:center; gap:6px; padding:10px 18px; font-size:11px; color:var(--text3); text-decoration:none; border-bottom:1px solid var(--border); transition:all .15s; }
|
||||
.nav-back:hover { color:var(--accent); background:var(--bg-hover); }
|
||||
.nav-section { padding:14px 0 6px; }
|
||||
.nav-section-title { font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:1.2px; color:var(--text4); padding:0 18px; margin-bottom:4px; }
|
||||
.nav-link { display:flex; align-items:center; gap:8px; padding:6px 18px; font-size:12px; color:var(--text2); text-decoration:none; transition:all .15s; cursor:pointer; border-left:2px solid transparent; }
|
||||
.nav-link:hover { color:var(--text); background:var(--bg-hover); }
|
||||
.nav-link.active { color:var(--accent); border-left-color:var(--accent); background:rgba(99,102,241,0.06); font-weight:600; }
|
||||
.nav-link i { width:16px; text-align:center; font-size:10px; opacity:.7; }
|
||||
|
||||
/* Main Content */
|
||||
.docs-main { padding:40px 60px 80px; max-width:900px; }
|
||||
|
||||
/* Hero */
|
||||
.hero { margin-bottom:48px; padding:32px 36px; background:linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06)); border:1px solid rgba(99,102,241,0.15); border-radius:16px; }
|
||||
.hero h1 { font-size:32px; font-weight:800; background:linear-gradient(135deg,var(--accent),var(--accent2),var(--pink)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; margin-bottom:8px; }
|
||||
.hero p { font-size:14px; color:var(--text2); max-width:600px; }
|
||||
.hero .run-cmd { margin-top:14px; display:inline-flex; align-items:center; gap:8px; padding:8px 16px; background:var(--bg-input); border:1px solid var(--border2); border-radius:var(--radius-sm); font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--info); }
|
||||
|
||||
/* Section */
|
||||
.doc-section { margin-bottom:48px; scroll-margin-top:24px; }
|
||||
.doc-section > h2 { font-size:22px; font-weight:800; color:var(--text); margin-bottom:16px; display:flex; align-items:center; gap:10px; padding-bottom:10px; border-bottom:1px solid var(--border); }
|
||||
.doc-section > h2 .sec-num { font-size:13px; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; width:28px; height:28px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-weight:700; flex-shrink:0; }
|
||||
.doc-section > h3 { font-size:16px; font-weight:700; color:var(--text); margin:24px 0 10px; display:flex; align-items:center; gap:8px; }
|
||||
.doc-section > h3 i { color:var(--accent); font-size:13px; }
|
||||
.doc-section p { color:var(--text2); font-size:13px; margin-bottom:12px; }
|
||||
|
||||
/* Cards */
|
||||
.info-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:16px 20px; margin:14px 0; }
|
||||
.info-card.tip { border-left:3px solid var(--success); }
|
||||
.info-card.warn { border-left:3px solid var(--warning); }
|
||||
.info-card.note { border-left:3px solid var(--info); }
|
||||
.info-card .card-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:1px; margin-bottom:6px; }
|
||||
.info-card.tip .card-label { color:var(--success); }
|
||||
.info-card.warn .card-label { color:var(--warning); }
|
||||
.info-card.note .card-label { color:var(--info); }
|
||||
|
||||
/* Tables */
|
||||
.doc-table { width:100%; border-collapse:collapse; margin:14px 0; font-size:12px; }
|
||||
.doc-table th { background:var(--bg3); padding:10px 14px; text-align:left; font-weight:700; color:var(--text3); text-transform:uppercase; letter-spacing:.5px; font-size:10px; border-bottom:1px solid var(--border); }
|
||||
.doc-table td { padding:8px 14px; border-bottom:1px solid var(--border); color:var(--text2); }
|
||||
.doc-table tr:hover td { background:var(--bg-hover); }
|
||||
.doc-table code { font-family:'JetBrains Mono',monospace; font-size:11px; background:rgba(99,102,241,0.1); color:var(--accent); padding:2px 6px; border-radius:4px; }
|
||||
|
||||
/* Code */
|
||||
code { font-family:'JetBrains Mono',monospace; font-size:11px; background:rgba(99,102,241,0.1); color:var(--accent); padding:2px 6px; border-radius:4px; }
|
||||
pre { background:var(--bg-input); border:1px solid var(--border); border-radius:var(--radius-sm); padding:16px; margin:14px 0; overflow-x:auto; }
|
||||
pre code { background:none; padding:0; font-size:12px; color:var(--info); line-height:1.6; }
|
||||
|
||||
/* Step list */
|
||||
.steps { counter-reset:step; list-style:none; margin:14px 0; }
|
||||
.steps li { counter-increment:step; position:relative; padding:10px 14px 10px 48px; margin-bottom:6px; background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-sm); font-size:12px; color:var(--text2); transition:all .15s; }
|
||||
.steps li:hover { border-color:var(--accent); background:var(--bg-hover); }
|
||||
.steps li::before { content:counter(step); position:absolute; left:14px; top:10px; width:22px; height:22px; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; border-radius:6px; font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center; }
|
||||
|
||||
/* Feature grid */
|
||||
.feat-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0; }
|
||||
.feat-item { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-sm); padding:14px 16px; transition:all .15s; }
|
||||
.feat-item:hover { border-color:var(--accent); transform:translateY(-1px); }
|
||||
.feat-item .fi-icon { font-size:16px; margin-bottom:6px; }
|
||||
.feat-item .fi-title { font-size:12px; font-weight:700; color:var(--text); margin-bottom:3px; }
|
||||
.feat-item .fi-desc { font-size:11px; color:var(--text3); }
|
||||
|
||||
/* Badge */
|
||||
.badge { display:inline-flex; align-items:center; gap:4px; font-size:10px; padding:3px 10px; border-radius:100px; font-weight:600; }
|
||||
.badge-accent { background:rgba(99,102,241,0.12); color:var(--accent); }
|
||||
.badge-success { background:rgba(16,185,129,0.12); color:var(--success); }
|
||||
.badge-warning { background:rgba(245,158,11,0.12); color:var(--warning); }
|
||||
.badge-info { background:rgba(6,182,212,0.12); color:var(--info); }
|
||||
.badge-pink { background:rgba(236,72,153,0.12); color:var(--pink); }
|
||||
|
||||
/* Kbd */
|
||||
kbd { display:inline-flex; padding:2px 7px; background:var(--bg3); border:1px solid var(--border2); border-radius:4px; font-family:'JetBrains Mono',monospace; font-size:10px; color:var(--text2); box-shadow:0 1px 0 var(--border2); }
|
||||
|
||||
/* Diagram */
|
||||
.diagram { background:var(--bg-input); border:1px solid var(--border); border-radius:var(--radius-sm); padding:16px; font-family:'JetBrains Mono',monospace; font-size:11px; color:var(--text3); line-height:1.5; white-space:pre; overflow-x:auto; margin:14px 0; }
|
||||
|
||||
/* Quick ref */
|
||||
.qr-item { display:flex; gap:12px; padding:10px 14px; border-bottom:1px solid var(--border); font-size:12px; }
|
||||
.qr-item:last-child { border-bottom:none; }
|
||||
.qr-q { color:var(--text3); min-width:280px; font-weight:500; }
|
||||
.qr-a { color:var(--accent); font-weight:600; }
|
||||
|
||||
@media(max-width:768px) {
|
||||
.docs-layout { grid-template-columns:1fr; }
|
||||
.docs-nav { display:none; }
|
||||
.docs-main { padding:20px; }
|
||||
.feat-grid { grid-template-columns:1fr; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="docs-layout">
|
||||
<!-- Sidebar Navigation -->
|
||||
<nav class="docs-nav">
|
||||
<div class="nav-header">
|
||||
<h1><i class="fa-solid fa-infinity"></i> JSON Infinity Studio</h1>
|
||||
<div class="subtitle">Complete Documentation</div>
|
||||
</div>
|
||||
<a href="/" class="nav-back"><i class="fa-solid fa-arrow-left"></i> Back to Editor</a>
|
||||
|
||||
<div class="nav-section"><div class="nav-section-title">Getting Started</div>
|
||||
<a class="nav-link" href="#overview"><i class="fa-solid fa-cube"></i> Overview</a>
|
||||
<a class="nav-link" href="#getting-started"><i class="fa-solid fa-rocket"></i> Getting Started</a>
|
||||
<a class="nav-link" href="#interface"><i class="fa-solid fa-desktop"></i> Interface Layout</a>
|
||||
</div>
|
||||
<div class="nav-section"><div class="nav-section-title">Core Features</div>
|
||||
<a class="nav-link" href="#file-ops"><i class="fa-solid fa-file"></i> File Operations</a>
|
||||
<a class="nav-link" href="#tree-nav"><i class="fa-solid fa-sitemap"></i> Tree Navigation</a>
|
||||
<a class="nav-link" href="#context-menu"><i class="fa-solid fa-bars"></i> Context Menu</a>
|
||||
<a class="nav-link" href="#editors"><i class="fa-solid fa-pen-to-square"></i> Editor Views</a>
|
||||
<a class="nav-link" href="#inline-edit"><i class="fa-solid fa-i-cursor"></i> Inline Editing</a>
|
||||
</div>
|
||||
<div class="nav-section"><div class="nav-section-title">Power Features</div>
|
||||
<a class="nav-link" href="#bulk-edit"><i class="fa-solid fa-bolt"></i> Bulk Edit</a>
|
||||
<a class="nav-link" href="#bulk-append"><i class="fa-solid fa-layer-group"></i> Bulk Append</a>
|
||||
<a class="nav-link" href="#multi-cat"><i class="fa-solid fa-wand-magic-sparkles"></i> Multi-Category</a>
|
||||
<a class="nav-link" href="#distribution"><i class="fa-solid fa-shuffle"></i> Distribution Logic</a>
|
||||
</div>
|
||||
<div class="nav-section"><div class="nav-section-title">Utilities</div>
|
||||
<a class="nav-link" href="#schema"><i class="fa-solid fa-magnifying-glass-chart"></i> Schema Analysis</a>
|
||||
<a class="nav-link" href="#diff"><i class="fa-solid fa-code-compare"></i> Diff / Revert</a>
|
||||
<a class="nav-link" href="#undo"><i class="fa-solid fa-rotate-left"></i> Undo / Redo</a>
|
||||
<a class="nav-link" href="#raw"><i class="fa-solid fa-code"></i> Raw Editor</a>
|
||||
<a class="nav-link" href="#search"><i class="fa-solid fa-search"></i> Search</a>
|
||||
</div>
|
||||
<div class="nav-section"><div class="nav-section-title">Reference</div>
|
||||
<a class="nav-link" href="#shortcuts"><i class="fa-solid fa-keyboard"></i> Shortcuts</a>
|
||||
<a class="nav-link" href="#placeholders"><i class="fa-solid fa-hashtag"></i> Placeholders</a>
|
||||
<a class="nav-link" href="#api"><i class="fa-solid fa-plug"></i> API Reference</a>
|
||||
<a class="nav-link" href="#quick-ref"><i class="fa-solid fa-zap"></i> Quick Reference</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="docs-main">
|
||||
<!-- Hero -->
|
||||
<div class="hero">
|
||||
<h1>JSON Infinity Studio</h1>
|
||||
<p>A powerful, browser-based JSON editor with bulk operations, multi-category support, pattern generation, and random/cyclic distribution logic.</p>
|
||||
<div class="run-cmd"><i class="fa-solid fa-terminal"></i> python app.py → http://localhost:5000</div>
|
||||
</div>
|
||||
|
||||
<!-- 1. Overview -->
|
||||
<section class="doc-section" id="overview">
|
||||
<h2><span class="sec-num">1</span> Overview</h2>
|
||||
<p>JSON Infinity Studio excels at working with complex, deeply nested JSON files. It auto-detects the structure and renders the optimal editor for every node.</p>
|
||||
<div class="feat-grid">
|
||||
<div class="feat-item"><div class="fi-icon">🌲</div><div class="fi-title">Visual Tree Navigation</div><div class="fi-desc">Browse any JSON structure with an interactive sidebar tree</div></div>
|
||||
<div class="feat-item"><div class="fi-icon">📊</div><div class="fi-title">Table Editing</div><div class="fi-desc">Spreadsheet-like editor for arrays of objects</div></div>
|
||||
<div class="feat-item"><div class="fi-icon">⚡</div><div class="fi-title">Bulk Operations</div><div class="fi-desc">Add/remove/edit fields across hundreds of items at once</div></div>
|
||||
<div class="feat-item"><div class="fi-icon">🎯</div><div class="fi-title">Multi-Category</div><div class="fi-desc">Apply changes to many arrays simultaneously</div></div>
|
||||
<div class="feat-item"><div class="fi-icon">🔄</div><div class="fi-title">Pattern Generation</div><div class="fi-desc">Auto-generate values using {i}, {line}, and other placeholders</div></div>
|
||||
<div class="feat-item"><div class="fi-icon">🎲</div><div class="fi-title">Distribution Logic</div><div class="fi-desc">Random % or cyclic pattern assignment (free/paid, etc.)</div></div>
|
||||
</div>
|
||||
|
||||
<h3><i class="fa-solid fa-puzzle-piece"></i> Supported JSON Structures</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Schema</th><th>Example</th><th>Description</th></tr>
|
||||
<tr><td><span class="badge badge-success">flat_object</span></td><td><code>{"name":"App","v":"1.0"}</code></td><td>Simple key-value object</td></tr>
|
||||
<tr><td><span class="badge badge-info">category_container</span></td><td><code>{"Love":[…],"Birthday":[…]}</code></td><td>Object with all array values</td></tr>
|
||||
<tr><td><span class="badge badge-accent">nested_categories</span></td><td><code>{"9:16":{"Love":[…]}}</code></td><td>Two-level nesting, arrays at leaves</td></tr>
|
||||
<tr><td><span class="badge badge-pink">array_of_objects</span></td><td><code>[{"id":1},{"id":2}]</code></td><td>Flat list of objects</td></tr>
|
||||
<tr><td><span class="badge badge-warning">config_with_data</span></td><td><code>{"name":"App","items":[…]}</code></td><td>Primitives + arrays mixed</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Nested Categories JSON</h3>
|
||||
<p>This is the type of JSON this tool was built for — deeply nested, with arrays of uniform objects:</p>
|
||||
<pre><code>{
|
||||
"9:16": {
|
||||
"Love": [
|
||||
{ "id": 1, "thumbnail": "love_1.webp", "inapp": "free", "coordinates": "100:200:300:400" },
|
||||
{ "id": 2, "thumbnail": "love_2.webp", "inapp": "paid", "coordinates": "150:250:350:450" },
|
||||
{ "id": 3, "thumbnail": "love_3.webp", "inapp": "free", "coordinates": "200:300:400:500" }
|
||||
],
|
||||
"Birthday": [
|
||||
{ "id": 1, "thumbnail": "bday_1.webp", "inapp": "free", "coordinates": "80:160:320:480" }
|
||||
]
|
||||
},
|
||||
"1:1": {
|
||||
"Abstract": [
|
||||
{ "id": 1, "thumbnail": "abs_1.webp", "inapp": "paid", "coordinates": "0:0:500:500" }
|
||||
]
|
||||
}
|
||||
}</code></pre>
|
||||
<div class="info-card note"><div class="card-label">What This Opens As</div>The tree sidebar shows: 📁 9:16 → 📦 Love [3], 📦 Birthday [1] | 📁 1:1 → 📦 Abstract [1]. Clicking Love shows a 3-row table with columns: id, thumbnail, inapp, coordinates.</div>
|
||||
</section>
|
||||
|
||||
<!-- 2. Getting Started -->
|
||||
<section class="doc-section" id="getting-started">
|
||||
<h2><span class="sec-num">2</span> Getting Started</h2>
|
||||
<h3><i class="fa-solid fa-play"></i> Starting the Application</h3>
|
||||
<pre><code>cd /path/to/appender
|
||||
python app.py
|
||||
# → Server at http://0.0.0.0:5000</code></pre>
|
||||
|
||||
<h3><i class="fa-solid fa-plus"></i> Creating a New JSON</h3>
|
||||
<ol class="steps">
|
||||
<li>Click <strong>"+ New"</strong> in the sidebar</li>
|
||||
<li>Choose a template: Empty Object, Array of Objects, Nested Categories, Config, or Paste JSON</li>
|
||||
<li>Name the file → Click <strong>Confirm</strong></li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-upload"></i> Loading an Existing JSON</h3>
|
||||
<ol class="steps">
|
||||
<li>Click <strong>"↑ Load"</strong> in the sidebar</li>
|
||||
<li>Select any <code>.json</code> file</li>
|
||||
<li>The tree structure appears — click any node to start editing</li>
|
||||
</ol>
|
||||
|
||||
<div class="info-card tip"><div class="card-label">💡 Important</div>All edits are made on a working copy. The original file is <strong>never</strong> modified. Use <strong>Revert</strong> to restore the original at any time.</div>
|
||||
</section>
|
||||
|
||||
<!-- 3. Interface Layout -->
|
||||
<section class="doc-section" id="interface">
|
||||
<h2><span class="sec-num">3</span> Interface Layout</h2>
|
||||
<div class="diagram">┌──────────────────────────────────────────────────────────────┐
|
||||
│ SIDEBAR (272px) │ TOP BAR │
|
||||
│ ┌────────────────────┐ │ [Multi-Cat] [Diff] [Revert] │
|
||||
│ │ JSON Infinity ∞ │ │ [Undo] [Redo] [Raw] [Save] [DL] │
|
||||
│ ├────────────────────┤ ├──────────────────────────────────│
|
||||
│ │ [+ New] [↑ Load] │ │ CONTENT AREA │
|
||||
│ ├────────────────────┤ │ Renders based on selected node: │
|
||||
│ │ 🔍 Search JSON │ │ • Object Editor │
|
||||
│ ├────────────────────┤ │ • Table Editor (arrays) │
|
||||
│ │ DETECTED SCHEMA │ │ • List Editor (primitives) │
|
||||
│ │ 🏗️ Nested Categories│ │ • Primitive Editor │
|
||||
│ ├────────────────────┤ │ │
|
||||
│ │ 📁 category1 │ │ │
|
||||
│ │ 📦 subcategory [5] │ │ │
|
||||
│ └────────────────────┘ ├──────────────────────────────────│
|
||||
│ │ STATUS BAR filename · modified │
|
||||
└──────────────────────────────────────────────────────────────┘</div>
|
||||
</section>
|
||||
|
||||
<!-- 4. File Operations -->
|
||||
<section class="doc-section" id="file-ops">
|
||||
<h2><span class="sec-num">4</span> File Operations</h2>
|
||||
<table class="doc-table">
|
||||
<tr><th>Action</th><th>How</th><th>Details</th></tr>
|
||||
<tr><td><strong>Create New</strong></td><td>Sidebar → "New"</td><td>Choose template, name file</td></tr>
|
||||
<tr><td><strong>Upload File</strong></td><td>Sidebar → "Load"</td><td>Select any .json file</td></tr>
|
||||
<tr><td><strong>Save Session</strong></td><td>Top bar → Save or <kbd>Ctrl</kbd>+<kbd>S</kbd></td><td>Saves to <code>saved_json/</code> dir + refreshes view</td></tr>
|
||||
<tr><td><strong>Download</strong></td><td>Top bar → Download</td><td>Downloads <code>updated_<name>.json</code></td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 5. Tree Navigation -->
|
||||
<section class="doc-section" id="tree-nav">
|
||||
<h2><span class="sec-num">5</span> Tree Navigation</h2>
|
||||
<p>The sidebar tree shows every node with color-coded icons and item count badges.</p>
|
||||
<table class="doc-table">
|
||||
<tr><th>Icon</th><th>Type</th><th>Interaction</th></tr>
|
||||
<tr><td>📁</td><td>Object</td><td>Click to open, right-click for menu</td></tr>
|
||||
<tr><td>📦</td><td>Array</td><td>Click to view table/list, shows item count</td></tr>
|
||||
<tr><td>🔤</td><td>String</td><td>Click to edit value</td></tr>
|
||||
<tr><td>#️⃣</td><td>Number</td><td>Click to edit with +/- stepper</td></tr>
|
||||
<tr><td>🔘</td><td>Boolean</td><td>Click to toggle</td></tr>
|
||||
<tr><td>🔗</td><td>URL</td><td>Click to edit, external link icon</td></tr>
|
||||
<tr><td>🎯</td><td>Coordinate</td><td>x:y:w:h pattern detected</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 6. Context Menu -->
|
||||
<section class="doc-section" id="context-menu">
|
||||
<h2><span class="sec-num">6</span> Context Menu (Right-Click)</h2>
|
||||
<p>Right-click any node in the tree for these operations:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--accent)">For Objects</div>Add Child (Object/Array/String/Number/Boolean)</div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--info)">For Arrays</div>Add Item (Object/String/Number), <strong>Bulk Append</strong></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">For All Nodes</div>Rename, Duplicate, Move Up/Down, Analyze Schema</div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--danger)">Destructive</div>Delete (with confirmation prompt)</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 7. Editor Views -->
|
||||
<section class="doc-section" id="editors">
|
||||
<h2><span class="sec-num">7</span> Editor Views</h2>
|
||||
<p>The editor auto-detects the node type and renders the optimal view.</p>
|
||||
|
||||
<h3><i class="fa-solid fa-folder-open"></i> Object Editor</h3>
|
||||
<p>Shows all key-value pairs with type badges, inline editables, toggle switches for booleans, +/- steppers for numbers, and navigation buttons for nested structures.</p>
|
||||
<pre><code>// Clicking node "9:16" shows the Object Editor:
|
||||
// ┌──────────────┬──────────────────┬────────┐
|
||||
// │ KEY │ VALUE │ TYPE │
|
||||
// ├──────────────┼──────────────────┼────────┤
|
||||
// │ Love │ → array (3) │ array │
|
||||
// │ Birthday │ → array (1) │ array │
|
||||
// └──────────────┴──────────────────┴────────┘</code></pre>
|
||||
|
||||
<h3><i class="fa-solid fa-table"></i> Table Editor (Arrays of Objects)</h3>
|
||||
<p>Spreadsheet-like table with sticky header, double-click editing, checkbox booleans, and URL links.</p>
|
||||
<pre><code>// Clicking "Love" (an array) shows the Table Editor:
|
||||
// ┌────┬───────────────┬────────┬─────────────────────┐
|
||||
// │ id │ thumbnail │ inapp │ coordinates │
|
||||
// ├────┼───────────────┼────────┼─────────────────────┤
|
||||
// │ 1 │ love_1.webp │ free │ 100:200:300:400 │
|
||||
// │ 2 │ love_2.webp │ paid │ 150:250:350:450 │
|
||||
// │ 3 │ love_3.webp │ free │ 200:300:400:500 │
|
||||
// └────┴───────────────┴────────┴─────────────────────┘</code></pre>
|
||||
<table class="doc-table">
|
||||
<tr><th>Button</th><th>Action</th></tr>
|
||||
<tr><td><span class="badge badge-accent">Add Col</span></td><td>Add a new column to all items</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Remove Col</span></td><td>Remove a column from all items</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Rename Col</span></td><td>Rename a column across all items</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Bulk Edit</span></td><td>Per-field bulk edit modal</td></tr>
|
||||
<tr><td><span class="badge badge-pink">Bulk Append</span></td><td>Generate and append new items</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-list"></i> List Editor</h3>
|
||||
<p>For arrays of primitives. Example — a tags array:</p>
|
||||
<pre><code>// Clicking a node like "tags": ["sunset", "beach", "nature"]
|
||||
// ┌────┬─────────┬────────┐
|
||||
// │ # │ Value │ Type │
|
||||
// ├────┼─────────┼────────┤
|
||||
// │ 0 │ sunset │ string │
|
||||
// │ 1 │ beach │ string │
|
||||
// │ 2 │ nature │ string │
|
||||
// └────┴─────────┴────────┘</code></pre>
|
||||
|
||||
<h3><i class="fa-solid fa-pen"></i> Primitive Editor</h3>
|
||||
<p>For individual values — type selector + input. Example: clicking <code>"name": "My App"</code> shows a text input with value "My App" and a type dropdown set to "string".</p>
|
||||
</section>
|
||||
|
||||
<!-- 8. Inline Editing -->
|
||||
<section class="doc-section" id="inline-edit">
|
||||
<h2><span class="sec-num">8</span> Inline Editing</h2>
|
||||
<table class="doc-table">
|
||||
<tr><th>Action</th><th>Gesture</th><th>Save/Cancel</th></tr>
|
||||
<tr><td>Edit table cell</td><td><strong>Double-click</strong> any cell</td><td><kbd>Enter</kbd> save · <kbd>Esc</kbd> cancel</td></tr>
|
||||
<tr><td>Rename field key</td><td><strong>Double-click</strong> key name in Object Editor</td><td><kbd>Enter</kbd> save · <kbd>Esc</kbd> cancel</td></tr>
|
||||
<tr><td>Toggle boolean</td><td><strong>Click</strong> checkbox/toggle</td><td>Saves immediately</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 9. Bulk Edit -->
|
||||
<section class="doc-section" id="bulk-edit">
|
||||
<h2><span class="sec-num">9</span> Bulk Edit (Per-Field Toggle)</h2>
|
||||
<p>Table Editor toolbar → <strong>"Bulk Edit"</strong>. Edit multiple fields simultaneously, each with its own mode.</p>
|
||||
|
||||
<ol class="steps">
|
||||
<li>Navigate to an array of objects → Table view appears</li>
|
||||
<li>Click <strong>"Bulk Edit"</strong> → modal opens with toggleable field cards</li>
|
||||
<li><strong>Toggle ON</strong> the fields to edit (switch turns green → "editing")</li>
|
||||
<li>Choose a <strong>Mode</strong> for each enabled field + configure settings</li>
|
||||
<li>Click <strong>"Apply Changes"</strong></li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-sliders"></i> Available Modes</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Mode</th><th>Description</th><th>Example</th></tr>
|
||||
<tr><td><span class="badge badge-accent">Set Value</span></td><td>Set all items to the same value</td><td><code>"free"</code></td></tr>
|
||||
<tr><td><span class="badge badge-accent">Pattern {i}</span></td><td>Use counter in a pattern</td><td><code>thumb_{i}.webp</code> → thumb_1, thumb_2…</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Sequence</span></td><td>Sequential numbers</td><td>1, 2, 3, 4…</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Find & Replace</span></td><td>Text find-and-replace</td><td>http: → https:</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Regex</span></td><td>Regex find-and-replace</td><td><code>(\d+)</code> → <code>item_{i}</code></td></tr>
|
||||
<tr><td><span class="badge badge-accent">Increment</span></td><td>Add fixed amount to numbers</td><td>+10 to all</td></tr>
|
||||
<tr><td><span class="badge badge-accent">Prefix/Suffix</span></td><td>Add text before/after</td><td>Prefix: <code>new_</code></td></tr>
|
||||
<tr><td><span class="badge badge-warning">Conditional</span></td><td>Set IF condition matches</td><td>IF inapp=free THEN premium_{i}</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Full Example: Before → After</h3>
|
||||
<p>Given this array at <code>9:16/Love</code>, apply Bulk Edit with thumbnail=Pattern and inapp=Set:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--warning)">Before</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "old_1.jpg", "inapp": "free" },
|
||||
{ "id": 2, "thumbnail": "old_2.jpg", "inapp": "free" },
|
||||
{ "id": 3, "thumbnail": "old_3.jpg", "inapp": "paid" }
|
||||
]</code></pre></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">After (thumbnail=Pattern, inapp=Set "premium")</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "https://cdn.com/v2/thumb_1.webp", "inapp": "premium" },
|
||||
{ "id": 2, "thumbnail": "https://cdn.com/v2/thumb_2.webp", "inapp": "premium" },
|
||||
{ "id": 3, "thumbnail": "https://cdn.com/v2/thumb_3.webp", "inapp": "premium" }
|
||||
]</code></pre></div>
|
||||
</div>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Conditional Mode</h3>
|
||||
<p>IF <code>inapp</code> equals <code>"free"</code> THEN set <code>thumbnail</code> to <code>"free_thumb_{i}.webp"</code>:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--warning)">Before</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "t1.webp", "inapp": "free" },
|
||||
{ "id": 2, "thumbnail": "t2.webp", "inapp": "paid" },
|
||||
{ "id": 3, "thumbnail": "t3.webp", "inapp": "free" }
|
||||
]</code></pre></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">After</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "free_thumb_1.webp", "inapp": "free" },
|
||||
{ "id": 2, "thumbnail": "t2.webp", "inapp": "paid" },
|
||||
{ "id": 3, "thumbnail": "free_thumb_2.webp", "inapp": "free" }
|
||||
]</code></pre></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 10. Bulk Append -->
|
||||
<section class="doc-section" id="bulk-append">
|
||||
<h2><span class="sec-num">10</span> Bulk Append Panel</h2>
|
||||
<p>Table toolbar → <strong>"Bulk Append"</strong> or right-click → <strong>Bulk Append</strong>. Generates and appends new items.</p>
|
||||
|
||||
<h3><i class="fa-solid fa-play"></i> Basic Append</h3>
|
||||
<ol class="steps">
|
||||
<li>Navigate to an array (e.g., <code>9:16/Love</code>) and click <strong>Bulk Append</strong></li>
|
||||
<li>Existing columns appear with sample patterns</li>
|
||||
<li>Set <strong>Manual Count</strong> (e.g., 20)</li>
|
||||
<li>Edit patterns: <code>thumbnail</code> → <code>https://cdn.com/love_{i}.webp</code></li>
|
||||
<li>Click <strong>Preview</strong> → verify generated items</li>
|
||||
<li>Click <strong>Append 20 items</strong></li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-file-lines"></i> With Data File</h3>
|
||||
<ol class="steps">
|
||||
<li>Prepare a text file with one value per line (e.g., coordinates: <code>100:200:300:400</code>)</li>
|
||||
<li>Click <strong>Choose File</strong> → count auto-adjusts to line count</li>
|
||||
<li>Set the coordinates field to <code>{line}</code> — each item gets one line</li>
|
||||
<li>Preview → Append</li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-plus"></i> Adding & Removing Columns</h3>
|
||||
<p>Click <strong>"+ Add Column"</strong> to create new fields. Each row has a <strong>✕</strong> button to remove it.</p>
|
||||
|
||||
<h3><i class="fa-solid fa-sitemap"></i> Multi-Target Append</h3>
|
||||
<p>When your JSON has multiple arrays, a <strong>TARGET ARRAYS</strong> tree appears with checkboxes.</p>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Full Example: Append with Pattern + Random</h3>
|
||||
<p>Starting array <code>Love</code> has 2 items. Append 3 more with: <code>thumbnail</code>=Pattern <code>love_{i}.webp</code> (start 3), <code>inapp</code>=Random 70% free / 30% paid:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--warning)">Before (2 items)</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "love_1.webp", "inapp": "free" },
|
||||
{ "id": 2, "thumbnail": "love_2.webp", "inapp": "paid" }
|
||||
]</code></pre></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">After (2 + 3 = 5 items)</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "love_1.webp", "inapp": "free" },
|
||||
{ "id": 2, "thumbnail": "love_2.webp", "inapp": "paid" },
|
||||
{ "id": 3, "thumbnail": "love_3.webp", "inapp": "free" },
|
||||
{ "id": 4, "thumbnail": "love_4.webp", "inapp": "free" },
|
||||
{ "id": 5, "thumbnail": "love_5.webp", "inapp": "paid" }
|
||||
]</code></pre></div>
|
||||
</div>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Append with Data File</h3>
|
||||
<p>Upload a file with coordinates (one per line), pattern <code>{line}</code> on <code>coordinates</code> field:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--info)">Input File (coords.txt)</div><pre><code>100:200:300:400
|
||||
150:250:350:450
|
||||
200:300:400:500</code></pre></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">Generated Items</div><pre><code>[
|
||||
{ "id": 1, "thumbnail": "t_1.webp", "coordinates": "100:200:300:400" },
|
||||
{ "id": 2, "thumbnail": "t_2.webp", "coordinates": "150:250:350:450" },
|
||||
{ "id": 3, "thumbnail": "t_3.webp", "coordinates": "200:300:400:500" }
|
||||
]</code></pre></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 11. Multi-Category -->
|
||||
<section class="doc-section" id="multi-cat">
|
||||
<h2><span class="sec-num">11</span> Multi-Category Add Field + Append</h2>
|
||||
<p>Top bar → <strong>"Multi-Cat"</strong> button. Add fields and apply distributions across multiple arrays simultaneously.</p>
|
||||
|
||||
<h3><i class="fa-solid fa-check-double"></i> Add a Field to All Arrays</h3>
|
||||
<ol class="steps">
|
||||
<li>Click <strong>Multi-Cat</strong> → modal shows category tree + field list</li>
|
||||
<li>Click <strong>Select All</strong> to target all arrays</li>
|
||||
<li>Click <strong>Add Field</strong> → Name: <code>premium</code>, Value: <code>false</code>, Dist: Static</li>
|
||||
<li>Click <strong>Apply to Selected Targets</strong></li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-shuffle"></i> Add Field with Random Distribution</h3>
|
||||
<ol class="steps">
|
||||
<li>Add Field → Name: <code>inapp</code></li>
|
||||
<li>Set Dist to <strong>Random %</strong></li>
|
||||
<li>Primary: <code>free</code>, %: <code>70</code>, Secondary: <code>paid</code></li>
|
||||
<li>Apply → each item gets random "free" or "paid"</li>
|
||||
</ol>
|
||||
|
||||
<h3><i class="fa-solid fa-arrows-spin"></i> Add Field with Cyclic Pattern</h3>
|
||||
<ol class="steps">
|
||||
<li>Add Field → Name: <code>tier</code>, Dist: <strong>Cyclic</strong></li>
|
||||
<li>Pattern: <code>basic, basic, premium</code></li>
|
||||
<li>Apply → items cycle: basic, basic, premium, basic, basic, premium…</li>
|
||||
</ol>
|
||||
|
||||
<div class="info-card tip"><div class="card-label">💡 Optional: Append New Items</div>Toggle ON "Append new items" and set count to also add new items to each target array.</div>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Full Example: Multi-Cat Random on All Arrays</h3>
|
||||
<p>Add <code>inapp</code> with Random 70% free / 30% paid across <strong>all</strong> arrays in the JSON:</p>
|
||||
<div class="feat-grid">
|
||||
<div class="info-card"><div class="card-label" style="color:var(--warning)">Before (no inapp field)</div><pre><code>{
|
||||
"9:16": {
|
||||
"Love": [{ "id": 1, "thumbnail": "l1.webp" }],
|
||||
"Birthday": [{ "id": 1, "thumbnail": "b1.webp" }]
|
||||
},
|
||||
"1:1": {
|
||||
"Abstract": [{ "id": 1, "thumbnail": "a1.webp" }]
|
||||
}
|
||||
}</code></pre></div>
|
||||
<div class="info-card"><div class="card-label" style="color:var(--success)">After (inapp added everywhere)</div><pre><code>{
|
||||
"9:16": {
|
||||
"Love": [{ "id": 1, "thumbnail": "l1.webp", "inapp": "free" }],
|
||||
"Birthday": [{ "id": 1, "thumbnail": "b1.webp", "inapp": "paid" }]
|
||||
},
|
||||
"1:1": {
|
||||
"Abstract": [{ "id": 1, "thumbnail": "a1.webp", "inapp": "free" }]
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 12. Distribution Logic -->
|
||||
<section class="doc-section" id="distribution">
|
||||
<h2><span class="sec-num">12</span> Distribution Logic</h2>
|
||||
<p>Available on <strong>every field row</strong> in Bulk Append and Multi-Cat. Each field independently uses:</p>
|
||||
|
||||
<table class="doc-table">
|
||||
<tr><th>Mode</th><th>How It Works</th><th>Example Result</th></tr>
|
||||
<tr><td><span class="badge badge-accent">Static</span></td><td>Pattern with <code>{i}</code> replacement</td><td><code>img_1.webp</code>, <code>img_2.webp</code>, <code>img_3.webp</code>…</td></tr>
|
||||
<tr><td><span class="badge badge-success">Random %</span></td><td>Primary value (N% chance) or Secondary</td><td>70% <code>free</code> / 30% <code>paid</code> randomly</td></tr>
|
||||
<tr><td><span class="badge badge-warning">Cyclic</span></td><td>Repeats comma-separated values in order</td><td><code>free, free, paid</code> → free, free, paid, free, free, paid…</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-dice"></i> Random % Use Cases</h3>
|
||||
<div class="feat-grid">
|
||||
<div class="feat-item"><div class="fi-title">inapp: 70% free / 30% paid</div><div class="fi-desc">Monetization distribution</div></div>
|
||||
<div class="feat-item"><div class="fi-title">tier: 80% basic / 20% premium</div><div class="fi-desc">Access tier assignment</div></div>
|
||||
<div class="feat-item"><div class="fi-title">featured: 10% true / 90% false</div><div class="fi-desc">Highlight selection</div></div>
|
||||
<div class="feat-item"><div class="fi-title">visible: 50% public / 50% private</div><div class="fi-desc">Visibility control</div></div>
|
||||
</div>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Random % Output (6 items, 70% free)</h3>
|
||||
<pre><code>// Random %: Primary = "free", % = 70, Secondary = "paid"
|
||||
// Possible output for 6 items:
|
||||
[
|
||||
{ "id": 1, "thumbnail": "t_1.webp", "inapp": "free" }, // ← 70% chance
|
||||
{ "id": 2, "thumbnail": "t_2.webp", "inapp": "free" }, // ← 70% chance
|
||||
{ "id": 3, "thumbnail": "t_3.webp", "inapp": "paid" }, // ← 30% chance
|
||||
{ "id": 4, "thumbnail": "t_4.webp", "inapp": "free" }, // ← 70% chance
|
||||
{ "id": 5, "thumbnail": "t_5.webp", "inapp": "paid" }, // ← 30% chance
|
||||
{ "id": 6, "thumbnail": "t_6.webp", "inapp": "free" } // ← 70% chance
|
||||
]</code></pre>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Cyclic Pattern Output</h3>
|
||||
<pre><code>// Cyclic Pattern: "free, free, paid" — repeats endlessly
|
||||
[
|
||||
{ "id": 1, "inapp": "free" }, // cycle pos 0
|
||||
{ "id": 2, "inapp": "free" }, // cycle pos 1
|
||||
{ "id": 3, "inapp": "paid" }, // cycle pos 2
|
||||
{ "id": 4, "inapp": "free" }, // cycle pos 0 (restart)
|
||||
{ "id": 5, "inapp": "free" }, // cycle pos 1
|
||||
{ "id": 6, "inapp": "paid" } // cycle pos 2
|
||||
]</code></pre>
|
||||
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Mixed Distribution Across Fields</h3>
|
||||
<p>Append 4 items where <code>id</code>=Static pattern, <code>thumbnail</code>=Static pattern, <code>inapp</code>=Random 70/30, <code>tier</code>=Cyclic:</p>
|
||||
<pre><code>// id: Static "{i}" | thumbnail: Static "img_{i}.webp"
|
||||
// inapp: Random 70% free / 30% paid | tier: Cyclic "basic, basic, premium"
|
||||
[
|
||||
{ "id": "1", "thumbnail": "img_1.webp", "inapp": "free", "tier": "basic" },
|
||||
{ "id": "2", "thumbnail": "img_2.webp", "inapp": "free", "tier": "basic" },
|
||||
{ "id": "3", "thumbnail": "img_3.webp", "inapp": "paid", "tier": "premium" },
|
||||
{ "id": "4", "thumbnail": "img_4.webp", "inapp": "free", "tier": "basic" }
|
||||
]</code></pre>
|
||||
</section>
|
||||
|
||||
<!-- 13. Schema Analysis -->
|
||||
<section class="doc-section" id="schema">
|
||||
<h2><span class="sec-num">13</span> Schema Analysis</h2>
|
||||
<p>Right-click → <strong>Analyze Schema</strong> or the 🔍 button. Shows everything about a node's structure:</p>
|
||||
<pre><code>// Schema analysis of "9:16/Love" array:
|
||||
// ┌────────────────────────────────────────────────┐
|
||||
// │ Schema: array_of_objects | 3 items │
|
||||
// ├──────────────┬──────────┬───────────────────────┤
|
||||
// │ Field │ Type │ Sample │
|
||||
// ├──────────────┼──────────┼───────────────────────┤
|
||||
// │ id │ number │ 1 │
|
||||
// │ thumbnail │ string │ love_1.webp │
|
||||
// │ inapp │ string │ free (2), paid (1) │
|
||||
// │ coordinates │ string │ 100:200:300:400 │
|
||||
// └──────────────┴──────────┴───────────────────────┘</code></pre>
|
||||
<div class="info-card note"><div class="card-label">Use Case</div>Before bulk operations, analyze the schema to understand field types, find nullable fields, and check type consistency. The <code>inapp</code> sample shows "free (2), paid (1)" — confirming the distribution before you modify it.</div>
|
||||
</section>
|
||||
|
||||
<!-- 14. Diff / Revert -->
|
||||
<section class="doc-section" id="diff">
|
||||
<h2><span class="sec-num">14</span> Diff / Compare / Revert</h2>
|
||||
<table class="doc-table">
|
||||
<tr><th>Action</th><th>Button</th><th>Shows</th></tr>
|
||||
<tr><td><strong>Compare</strong></td><td>Top bar → "Diff"</td><td>Added keys, removed keys, value changes, array size changes, type changes</td></tr>
|
||||
<tr><td><strong>Revert</strong></td><td>Top bar → "Revert"</td><td>Restores original data (pushes current to undo stack first)</td></tr>
|
||||
</table>
|
||||
<h3><i class="fa-solid fa-code"></i> Example: Diff Output</h3>
|
||||
<pre><code>// After adding 3 items to Love and adding an "inapp" field to Abstract:
|
||||
//
|
||||
// CHANGES DETECTED:
|
||||
// ────────────────────────────────────────
|
||||
// 9:16/Love array size: 3 → 6 (+3 items)
|
||||
// 9:16/Love/0 value changed: thumbnail "old.jpg" → "love_1.webp"
|
||||
// 1:1/Abstract/0 field added: "inapp" = "free"
|
||||
// ────────────────────────────────────────</code></pre>
|
||||
</section>
|
||||
|
||||
<!-- 15. Undo / Redo -->
|
||||
<section class="doc-section" id="undo">
|
||||
<h2><span class="sec-num">15</span> Undo / Redo</h2>
|
||||
<p>Every operation is recorded (max 50 steps). Works with ALL operations: edits, deletes, bulk ops, appends, renames, moves.</p>
|
||||
<table class="doc-table">
|
||||
<tr><th>Action</th><th>Shortcut</th></tr>
|
||||
<tr><td>Undo</td><td><kbd>Ctrl</kbd>+<kbd>Z</kbd></td></tr>
|
||||
<tr><td>Redo</td><td><kbd>Ctrl</kbd>+<kbd>Y</kbd></td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 16. Raw Editor -->
|
||||
<section class="doc-section" id="raw">
|
||||
<h2><span class="sec-num">16</span> Raw JSON Editor</h2>
|
||||
<p>Click the <strong></></strong> code icon in the top bar. Edit the full JSON as formatted text. Click again to parse and apply. Invalid JSON shows an error.</p>
|
||||
</section>
|
||||
|
||||
<!-- 17. Search -->
|
||||
<section class="doc-section" id="search">
|
||||
<h2><span class="sec-num">17</span> Search</h2>
|
||||
<p>Sidebar search bar or <kbd>Ctrl</kbd>+<kbd>F</kbd>. Searches both keys and values. Results show match type, path, and preview. Click a result to navigate.</p>
|
||||
</section>
|
||||
|
||||
<!-- 18. Keyboard Shortcuts -->
|
||||
<section class="doc-section" id="shortcuts">
|
||||
<h2><span class="sec-num">18</span> Keyboard Shortcuts</h2>
|
||||
<table class="doc-table">
|
||||
<tr><th>Shortcut</th><th>Action</th></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>Z</kbd></td><td>Undo</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>Y</kbd></td><td>Redo</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>S</kbd></td><td>Save session + refresh view</td></tr>
|
||||
<tr><td><kbd>Ctrl</kbd>+<kbd>F</kbd></td><td>Focus search input</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 19. Placeholders -->
|
||||
<section class="doc-section" id="placeholders">
|
||||
<h2><span class="sec-num">19</span> Pattern Placeholders Reference</h2>
|
||||
<table class="doc-table">
|
||||
<tr><th>Placeholder</th><th>Description</th><th>Example</th><th>Output (3rd item)</th></tr>
|
||||
<tr><td><code>{i}</code></td><td>Counter (configurable start)</td><td><code>img_{i}.webp</code></td><td>img_3.webp</td></tr>
|
||||
<tr><td><code>{idx}</code></td><td>Zero-based index</td><td><code>item_{idx}</code></td><td>item_2</td></tr>
|
||||
<tr><td><code>{total}</code></td><td>Total item count</td><td><code>{idx}/{total}</code></td><td>2/50</td></tr>
|
||||
<tr><td><code>{line}</code></td><td>Line from uploaded file</td><td><code>{line}</code></td><td>100:200:300:400</td></tr>
|
||||
<tr><td><code>{coord}</code></td><td>Alias for {line}</td><td><code>{coord}</code></td><td>100:200:300:400</td></tr>
|
||||
<tr><td><code>{value}</code></td><td>Current field value (Bulk Edit)</td><td><code>v2_{value}</code></td><td>v2_old_val</td></tr>
|
||||
<tr><td><code>{field}</code></td><td>Another field by name</td><td><code>{id}_thumb</code></td><td>3_thumb</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- 20. API Reference -->
|
||||
<section class="doc-section" id="api">
|
||||
<h2><span class="sec-num">20</span> API Endpoints Reference</h2>
|
||||
<h3><i class="fa-solid fa-file"></i> File Operations</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Method</th><th>Endpoint</th><th>Description</th></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/upload</code></td><td>Upload JSON file (multipart)</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/create_new</code></td><td>Create from template/paste</td></tr>
|
||||
<tr><td><span class="badge badge-info">GET</span></td><td><code>/get_tree</code></td><td>Get sidebar tree</td></tr>
|
||||
<tr><td><span class="badge badge-info">GET</span></td><td><code>/get_data</code></td><td>Get full data + metadata</td></tr>
|
||||
<tr><td><span class="badge badge-info">GET</span></td><td><code>/download</code></td><td>Download current data</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/save</code></td><td>Save to disk</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-cube"></i> Node Operations</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Method</th><th>Endpoint</th><th>Description</th></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/get</code></td><td>Get node content</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/add</code></td><td>Add child</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/rename</code></td><td>Rename key</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/delete</code></td><td>Delete node</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/duplicate</code></td><td>Clone node</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/edit_value</code></td><td>Edit primitive value</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/edit_item</code></td><td>Edit array item</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/node/move</code></td><td>Reorder within parent</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-bolt"></i> Bulk Operations</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Method</th><th>Endpoint</th><th>Description</th></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/add_field</code></td><td>Add field to all items</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/remove_field</code></td><td>Remove field from all</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/edit_field</code></td><td>Edit field (many modes)</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/edit_multi_field</code></td><td>Edit multiple fields at once</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/rename_field</code></td><td>Rename field across all</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/bulk/add_field_multi</code></td><td>Multi-Cat add fields</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/preview_append</code></td><td>Generate preview items</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/commit_append</code></td><td>Append items to arrays</td></tr>
|
||||
</table>
|
||||
|
||||
<h3><i class="fa-solid fa-wrench"></i> Utilities</h3>
|
||||
<table class="doc-table">
|
||||
<tr><th>Method</th><th>Endpoint</th><th>Description</th></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/schema/analyze</code></td><td>Analyze schema at path</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/compare_original</code></td><td>Diff current vs original</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/revert_original</code></td><td>Revert to original</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/undo</code></td><td>Undo last operation</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/redo</code></td><td>Redo</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/search</code></td><td>Search keys + values</td></tr>
|
||||
<tr><td><span class="badge badge-info">GET</span></td><td><code>/raw/get</code></td><td>Get raw JSON string</td></tr>
|
||||
<tr><td><span class="badge badge-success">POST</span></td><td><code>/raw/set</code></td><td>Set from raw JSON</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<!-- Quick Reference -->
|
||||
<section class="doc-section" id="quick-ref">
|
||||
<h2><span class="sec-num">⚡</span> Quick Reference</h2>
|
||||
<div class="info-card" style="padding:0">
|
||||
<div class="qr-item"><div class="qr-q">"Add a field to every item in one array"</div><div class="qr-a">Table → Add Col</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"Add a field to ALL arrays in my JSON"</div><div class="qr-a">Multi-Cat → Select All → Add Field</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"Randomize inapp across all categories"</div><div class="qr-a">Multi-Cat → Random % → free/70%/paid</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"Append 50 items with auto-gen URLs"</div><div class="qr-a">Bulk Append → pattern {i} → count 50</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"Append from a coordinate file"</div><div class="qr-a">Bulk Append → upload file → {line}</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"Edit multiple fields with different rules"</div><div class="qr-a">Bulk Edit → toggle each → set modes</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"See what changed since loading"</div><div class="qr-a">Top bar → Diff</div></div>
|
||||
<div class="qr-item"><div class="qr-q">"I messed up, start over"</div><div class="qr-a">Top bar → Revert (undoable)</div></div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Highlight active nav link on scroll
|
||||
const sections = document.querySelectorAll('.doc-section');
|
||||
const navLinks = document.querySelectorAll('.nav-link');
|
||||
const observer = new IntersectionObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
navLinks.forEach(l => l.classList.remove('active'));
|
||||
const id = entry.target.id;
|
||||
const link = document.querySelector(`.nav-link[href="#${id}"]`);
|
||||
if (link) link.classList.add('active');
|
||||
}
|
||||
});
|
||||
}, { rootMargin: '-20% 0px -70% 0px' });
|
||||
sections.forEach(s => observer.observe(s));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,548 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
||||
<title>JSON Infinity Studio</title>
|
||||
<link rel="stylesheet" href="/static/style.css"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-layout">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="sidebar-logo"><i class="fa-solid fa-infinity"></i></div>
|
||||
<h1>JSON Infinity Studio</h1>
|
||||
</div>
|
||||
<div class="sidebar-actions">
|
||||
<button class="btn btn-primary btn-sm" style="flex:1" onclick="showCreateModal()"><i class="fa-solid fa-plus"></i> New</button>
|
||||
<button class="btn btn-ghost btn-sm" style="flex:1" onclick="document.getElementById('fileInput').click()"><i class="fa-solid fa-upload"></i> Load</button>
|
||||
<input type="file" id="fileInput" hidden accept=".json"/>
|
||||
</div>
|
||||
<div class="sidebar-search"><i class="fa-solid fa-search"></i><input type="text" placeholder="Search JSON..." id="searchInput" oninput="handleSearch(this.value)"/></div>
|
||||
<!-- Schema Summary Badge -->
|
||||
<div id="schemaSummary" style="padding:6px 12px;display:none">
|
||||
<div style="font-size:9px;text-transform:uppercase;letter-spacing:1px;color:var(--text-dim);margin-bottom:4px">DETECTED SCHEMA</div>
|
||||
<div id="schemaBadge" style="font-size:11px;color:var(--accent);font-weight:600;font-family:'JetBrains Mono',monospace"></div>
|
||||
</div>
|
||||
<div class="tree-container" id="treeRoot"></div>
|
||||
</div>
|
||||
<div class="main-content">
|
||||
<div class="top-bar">
|
||||
<div class="breadcrumb" id="breadcrumb">
|
||||
<span style="color:var(--text-muted)">Select or create a JSON</span>
|
||||
<span id="dirtyIndicator" class="dirty-dot" style="display:none" title="Unsaved changes">●</span>
|
||||
</div>
|
||||
<div class="top-actions">
|
||||
<button class="btn btn-ghost btn-sm" onclick="showMultiCatAddFieldModal()" title="Add fields across multiple categories"><i class="fa-solid fa-wand-magic-sparkles"></i> Multi-Cat</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="showCompareOriginal()" title="Compare with original"><i class="fa-solid fa-code-compare"></i> Diff</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="revertToOriginal()" title="Revert to original"><i class="fa-solid fa-clock-rotate-left"></i> Revert</button>
|
||||
<div style="width:1px;height:20px;background:var(--border);margin:0 4px"></div>
|
||||
<button class="btn-icon" onclick="doUndo()" title="Undo (Ctrl+Z)"><i class="fa-solid fa-rotate-left"></i></button>
|
||||
<button class="btn-icon" onclick="doRedo()" title="Redo (Ctrl+Y)"><i class="fa-solid fa-rotate-right"></i></button>
|
||||
<button class="btn-icon" onclick="toggleRawEditor()" title="Raw JSON"><i class="fa-solid fa-code"></i></button>
|
||||
<div style="width:1px;height:20px;background:var(--border);margin:0 4px"></div>
|
||||
<button class="btn btn-save btn-sm" onclick="saveSession()" title="Save Session & Refresh View (Ctrl+S)"><i class="fa-solid fa-floppy-disk"></i> Save</button>
|
||||
<button class="btn btn-success btn-sm" onclick="downloadFile()"><i class="fa-solid fa-download"></i> Download</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-area" id="contentArea">
|
||||
<div class="empty-state" id="emptyState">
|
||||
<i class="fa-solid fa-cubes"></i>
|
||||
<p>Create a new JSON or load an existing file to begin</p>
|
||||
<div style="display:flex;gap:8px;margin-top:8px">
|
||||
<button class="btn btn-primary" onclick="showCreateModal()"><i class="fa-solid fa-plus"></i> New JSON</button>
|
||||
<button class="btn btn-ghost" onclick="document.getElementById('fileInput').click()"><i class="fa-solid fa-upload"></i> Load File</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="editorArea" class="d-none"></div>
|
||||
<div id="rawEditorArea" class="d-none" style="height:100%;padding:0">
|
||||
<textarea class="input" id="rawTextarea" style="height:100%;border-radius:0;border:none;font-family:'JetBrains Mono',monospace;font-size:13px;resize:none"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-bar">
|
||||
<div class="status-left"><span id="statusPath">No file loaded</span><span id="statusDirty" style="color:var(--warning);display:none"> ● Modified</span><span id="statusCount"></span></div>
|
||||
<div class="status-right"><span id="undoCount"></span><span>Ctrl+Z Undo | Ctrl+S Save | Ctrl+F Search</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toast-container" id="toastContainer"></div>
|
||||
<div class="ctx-menu" id="ctxMenu" style="display:none"></div>
|
||||
|
||||
<script>
|
||||
// ── State ──
|
||||
let currentPath="",currentNode=null,treeData=[],previewData=[],rawMode=false,currentSchema=null;
|
||||
const D=document,$=s=>D.getElementById(s);
|
||||
const api=async(url,body,isForm)=>{
|
||||
const opts={method:"POST"};
|
||||
if(isForm){opts.body=body}else{opts.headers={"Content-Type":"application/json"};opts.body=JSON.stringify(body||{});}
|
||||
const r=await fetch(url,opts);return r.json();
|
||||
};
|
||||
|
||||
// ── Toast ──
|
||||
function toast(msg,type="success"){
|
||||
const t=D.createElement("div");t.className=`toast toast-${type}`;
|
||||
t.innerHTML=`<i class="fa-solid fa-${type==="success"?"check-circle":type==="error"?"exclamation-circle":"info-circle"}"></i>${msg}`;
|
||||
$("toastContainer").appendChild(t);
|
||||
setTimeout(()=>{t.style.animation="fadeOut .3s ease forwards";setTimeout(()=>t.remove(),300)},2500);
|
||||
}
|
||||
|
||||
// ── Dirty Tracking ──
|
||||
function updateDirtyUI(isDirty){
|
||||
$("dirtyIndicator").style.display=isDirty?"inline":"none";
|
||||
$("statusDirty").style.display=isDirty?"inline":"none";
|
||||
}
|
||||
async function checkDirty(){
|
||||
const r=await fetch("/saved_status").then(r=>r.json());
|
||||
updateDirtyUI(r.is_dirty);
|
||||
}
|
||||
|
||||
// ── File I/O ──
|
||||
$("fileInput").addEventListener("change",async e=>{
|
||||
const fd=new FormData();fd.append("file",e.target.files[0]);
|
||||
const r=await fetch("/upload",{method:"POST",body:fd}).then(r=>r.json());
|
||||
if(r.success){
|
||||
treeData=r.tree;renderTree(r.tree);toast("File loaded — working on a copy!");
|
||||
$("statusPath").textContent=e.target.files[0].name;
|
||||
if(r.schema) setSchemaInfo(r.schema);
|
||||
updateDirtyUI(false);hideEmpty();
|
||||
} else toast(r.error,"error");
|
||||
});
|
||||
|
||||
function showCreateModal(){
|
||||
showModal("Create New JSON",`
|
||||
<label class="label">File Name</label><input class="input" id="mdNewName" value="data.json">
|
||||
<label class="label mt-md">Template</label>
|
||||
<select class="input" id="mdTemplate">
|
||||
<option value="empty">Empty Object {}</option>
|
||||
<option value="array_of_objects">Array of Objects</option>
|
||||
<option value="nested">Nested Categories</option>
|
||||
<option value="config">Config Template</option>
|
||||
<option value="paste">Paste JSON</option>
|
||||
</select>
|
||||
<div id="mdPasteWrap" style="display:none" class="mt-md"><textarea class="input" id="mdPasteContent" rows="5" placeholder='{"key":"value"}'></textarea></div>`,
|
||||
async()=>{
|
||||
const tmpl=$("mdTemplate").value;
|
||||
const body={mode:tmpl==="paste"?"paste":"template",name:$("mdNewName").value,template:tmpl};
|
||||
if(tmpl==="paste")body.content=$("mdPasteContent").value;
|
||||
const r=await api("/create_new",body);
|
||||
if(r.success){treeData=r.tree;renderTree(r.tree);toast("Created!");$("statusPath").textContent=$("mdNewName").value;if(r.schema)setSchemaInfo(r.schema);updateDirtyUI(false);hideEmpty();}
|
||||
else toast(r.error,"error");
|
||||
});
|
||||
$("mdTemplate").onchange=()=>{$("mdPasteWrap").style.display=$("mdTemplate").value==="paste"?"block":"none";};
|
||||
}
|
||||
|
||||
function hideEmpty(){$("emptyState").style.display="none";$("editorArea").classList.remove("d-none");}
|
||||
|
||||
// ── Save Session / Download ──
|
||||
async function saveSession(){
|
||||
// Save = refresh the entire view so you can see all changes
|
||||
const treeR=await fetch("/get_tree").then(r=>r.json());
|
||||
if(treeR.tree){treeData=treeR.tree;renderTree(treeR.tree);}
|
||||
if(currentPath){await loadNode(currentPath);}
|
||||
// Also persist to disk in background so nothing is lost
|
||||
await api("/save");
|
||||
updateDirtyUI(false);
|
||||
toast("Session saved — view updated!");
|
||||
}
|
||||
function downloadFile(){window.location.href="/download";}
|
||||
|
||||
// ── Revert / Compare ──
|
||||
async function revertToOriginal(){
|
||||
if(!confirm("Revert ALL changes back to the original uploaded file? (You can still Undo this)")) return;
|
||||
const r=await api("/revert_original");
|
||||
if(r.success){refreshTree(r.tree);if(currentPath)loadNode(currentPath);toast(r.message,"info");updateDirtyUI(false);}
|
||||
else toast(r.error,"error");
|
||||
}
|
||||
async function showCompareOriginal(){
|
||||
const r=await api("/compare_original");
|
||||
if(!r.success){toast(r.error||"No original to compare","error");return;}
|
||||
const changes=r.changes||[];
|
||||
let bodyHtml=`<div style="max-height:400px;overflow-y:auto">`;
|
||||
if(changes.length===0) bodyHtml+=`<div style="padding:20px;text-align:center;color:var(--success)"><i class="fa-solid fa-check-circle"></i> No changes — data matches original</div>`;
|
||||
else{
|
||||
bodyHtml+=`<div style="padding:6px 10px;background:var(--bg-card);border-radius:var(--radius-sm);margin-bottom:8px;font-size:11px"><strong>${r.total_changes}</strong> change(s) detected</div>`;
|
||||
changes.forEach(c=>{
|
||||
let icon="fa-pen",color="var(--accent)",label="";
|
||||
if(c.type==="added"){icon="fa-plus";color="var(--success)";label=`<strong>Added:</strong> ${c.path}`;}
|
||||
else if(c.type==="removed"){icon="fa-minus";color="var(--danger)";label=`<strong>Removed:</strong> ${c.path}`;}
|
||||
else if(c.type==="value_changed"){icon="fa-pen";color="var(--warning)";label=`<strong>${c.path}</strong>: "${c.from}" → "${c.to}"`;}
|
||||
else if(c.type==="array_size_changed"){icon="fa-layer-group";color="var(--info)";label=`<strong>${c.path}</strong>: ${c.from} → ${c.to} items`;}
|
||||
else if(c.type==="type_changed"){icon="fa-shuffle";color="var(--warning)";label=`<strong>${c.path}</strong>: type ${c.from} → ${c.to}`;}
|
||||
bodyHtml+=`<div class="field-row" style="padding:4px 8px;font-size:11px"><i class="fa-solid ${icon}" style="color:${color};width:14px"></i> ${label}</div>`;
|
||||
});
|
||||
}
|
||||
bodyHtml+=`</div>`;
|
||||
showModal(`<i class="fa-solid fa-code-compare" style="color:var(--accent)"></i> Changes vs Original`,bodyHtml,()=>{});
|
||||
}
|
||||
|
||||
// ── Schema Info ──
|
||||
function setSchemaInfo(schema){
|
||||
currentSchema=schema;
|
||||
const el=$("schemaSummary"),badge=$("schemaBadge");
|
||||
el.style.display="block";
|
||||
const s=schema.schema||schema.type||"unknown";
|
||||
const map={
|
||||
"flat_object":"⚙️ Flat Object","category_container":"📂 Category Container",
|
||||
"nested_categories":"🏗️ Nested Categories","nested_objects":"🏢 Nested Objects",
|
||||
"config_with_data":"📋 Config + Data","config_with_sections":"⚙️ Config + Sections",
|
||||
"mixed_object":"🔀 Mixed Object","array_of_objects":"📊 Array of Objects",
|
||||
"array_of_arrays":"📦 Array of Arrays","mixed_array":"🔀 Mixed Array",
|
||||
"empty_array":"📭 Empty Array","object":"📁 Object","array":"📦 Array",
|
||||
"string":"📝 String","number":"🔢 Number","boolean":"✅ Boolean","null":"⊘ Null"
|
||||
};
|
||||
badge.textContent=map[s]||s;
|
||||
if(schema.key_count) badge.textContent+=` · ${schema.key_count} keys`;
|
||||
else if(schema.count!==undefined) badge.textContent+=` · ${schema.count} items`;
|
||||
}
|
||||
|
||||
// ── Tree ──
|
||||
function renderTree(nodes){
|
||||
const root=$("treeRoot");root.innerHTML="";
|
||||
if(!nodes||!nodes.length){root.innerHTML='<div style="padding:20px;text-align:center;color:var(--text-dim);font-size:12px">Empty — add a node via context menu</div>';return;}
|
||||
root.appendChild(buildTreeDOM(nodes));
|
||||
}
|
||||
function buildTreeDOM(nodes){
|
||||
const wrap=D.createElement("div");
|
||||
nodes.forEach(n=>{
|
||||
const row=D.createElement("div");row.className="tree-node"+(n.path===currentPath?" active":"");
|
||||
const hasKids=n.type==="object"&&n.children&&n.children.length>0;
|
||||
let html="";
|
||||
if(hasKids)html+=`<span class="tree-toggle open"><i class="fa-solid fa-chevron-right"></i></span>`;
|
||||
else html+='<span style="width:14px"></span>';
|
||||
const iconMap={object:"fa-folder text-warning",array:"fa-layer-group text-info",string:"fa-font",number:"fa-hashtag text-accent",boolean:"fa-toggle-on text-warning",null:"fa-ban text-muted",url:"fa-link text-pink",coordinate:"fa-crosshairs text-orange"};
|
||||
html+=`<span class="node-icon"><i class="fa-solid ${iconMap[n.type]||"fa-circle"}"></i></span>`;
|
||||
html+=`<span class="node-label">${n.key}</span>`;
|
||||
if(n.count!==undefined)html+=`<span class="node-badge">${n.count}</span>`;
|
||||
row.innerHTML=html;
|
||||
row.onclick=e=>{e.stopPropagation();if(n.type==="object"||n.type==="array")loadNode(n.path);if(hasKids){const ch=row.nextElementSibling;if(ch&&ch.classList.contains("tree-children"))ch.classList.toggle("collapsed");const tog=row.querySelector(".tree-toggle");if(tog)tog.classList.toggle("open");}};
|
||||
row.oncontextmenu=e=>{e.preventDefault();e.stopPropagation();showContextMenu(e,n);};
|
||||
wrap.appendChild(row);
|
||||
if(hasKids){const childDiv=D.createElement("div");childDiv.className="tree-children";childDiv.appendChild(buildTreeDOM(n.children));wrap.appendChild(childDiv);}
|
||||
});
|
||||
return wrap;
|
||||
}
|
||||
|
||||
// ── Context Menu ──
|
||||
function showContextMenu(e,node){
|
||||
const m=$("ctxMenu");let items=[];
|
||||
if(node.type==="object"){
|
||||
items.push({icon:"fa-plus",label:"Add Child (Object)",action:()=>addNodePrompt(node.path,"object")});
|
||||
items.push({icon:"fa-list",label:"Add Child (Array)",action:()=>addNodePrompt(node.path,"array")});
|
||||
items.push({icon:"fa-font",label:"Add Child (String)",action:()=>addNodePrompt(node.path,"string")});
|
||||
items.push({icon:"fa-hashtag",label:"Add Child (Number)",action:()=>addNodePrompt(node.path,"number")});
|
||||
items.push({icon:"fa-toggle-on",label:"Add Child (Boolean)",action:()=>addNodePrompt(node.path,"boolean")});
|
||||
items.push("sep");
|
||||
}
|
||||
if(node.type==="array"){
|
||||
items.push({icon:"fa-plus",label:"Add Item (Object)",action:()=>addArrayItem(node.path,"object")});
|
||||
items.push({icon:"fa-font",label:"Add Item (String)",action:()=>addArrayItem(node.path,"string")});
|
||||
items.push({icon:"fa-hashtag",label:"Add Item (Number)",action:()=>addArrayItem(node.path,"number")});
|
||||
items.push({icon:"fa-bolt",label:"Bulk Append",action:()=>{loadNode(node.path);setTimeout(()=>showAppendPanel(node.path),300);}});
|
||||
items.push("sep");
|
||||
}
|
||||
items.push({icon:"fa-pen",label:"Rename",action:()=>renamePrompt(node)});
|
||||
items.push({icon:"fa-copy",label:"Duplicate",action:()=>duplicateNode(node.path)});
|
||||
items.push({icon:"fa-arrows-up-down",label:"Move Up",action:()=>moveNode(node.path,"up")});
|
||||
items.push({icon:"fa-arrows-up-down",label:"Move Down",action:()=>moveNode(node.path,"down")});
|
||||
items.push("sep");
|
||||
items.push({icon:"fa-magnifying-glass-chart",label:"Analyze Schema",action:()=>analyzeSchema(node.path)});
|
||||
items.push("sep");
|
||||
items.push({icon:"fa-trash",label:"Delete",action:()=>deleteNode(node.path),danger:true});
|
||||
m.innerHTML=items.map(i=>i==="sep"?'<div class="ctx-sep"></div>':`<div class="ctx-item${i.danger?" danger":""}" onclick="this.action()"><i class="fa-solid ${i.icon}"></i>${i.label}</div>`).join("");
|
||||
m.querySelectorAll(".ctx-item").forEach((el,idx)=>{const item=items.filter(x=>x!=="sep")[idx];if(item)el.onclick=()=>{m.style.display="none";item.action();};});
|
||||
m.style.display="block";m.style.left=Math.min(e.clientX,window.innerWidth-200)+"px";m.style.top=Math.min(e.clientY,window.innerHeight-300)+"px";
|
||||
}
|
||||
D.addEventListener("click",()=>$("ctxMenu").style.display="none");
|
||||
|
||||
// ── Schema Analysis ──
|
||||
async function analyzeSchema(path){
|
||||
const r=await api("/schema/analyze",{path:path||""});
|
||||
if(!r.success){toast(r.error,"error");return;}
|
||||
const s=r.schema;
|
||||
let body=`<div style="max-height:400px;overflow-y:auto;font-size:12px">`;
|
||||
body+=`<div class="field-row" style="background:var(--bg-card);border-radius:var(--radius-sm);padding:8px 12px;margin-bottom:8px">
|
||||
<strong>Type:</strong> <span class="field-type-badge type-${s.type}">${s.type}</span>`;
|
||||
if(s.schema) body+=` | <strong>Schema:</strong> ${s.schema}`;
|
||||
if(s.count!==undefined) body+=` | <strong>Count:</strong> ${s.count}`;
|
||||
if(s.key_count!==undefined) body+=` | <strong>Keys:</strong> ${s.key_count}`;
|
||||
body+=`</div>`;
|
||||
if(s.fields){
|
||||
body+=`<div class="section-title"><i class="fa-solid fa-columns"></i> FIELDS</div>`;
|
||||
for(const[k,f] of Object.entries(s.fields)){
|
||||
const t=f.dominant_type||f.type||"unknown";
|
||||
body+=`<div class="field-row" style="padding:4px 8px"><span class="field-key">${k}</span><span class="field-type-badge type-${t}">${t}</span>`;
|
||||
if(f.type_distribution){body+=`<span style="font-size:9px;color:var(--text-dim);margin-left:6px">${Object.entries(f.type_distribution).map(([tt,c])=>`${tt}:${c}`).join(", ")}</span>`;}
|
||||
if(f.sample!==null&&f.sample!==undefined)body+=`<span style="font-size:10px;color:var(--text-muted);margin-left:8px;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${String(f.sample).substring(0,60)}</span>`;
|
||||
body+=`</div>`;
|
||||
}
|
||||
}
|
||||
if(s.columns){body+=`<div class="section-title mt-md"><i class="fa-solid fa-table"></i> COLUMNS</div><div style="display:flex;gap:4px;flex-wrap:wrap">${s.columns.map(c=>`<span class="chip">${c}</span>`).join("")}</div>`;}
|
||||
body+=`</div>`;
|
||||
showModal(`<i class="fa-solid fa-magnifying-glass-chart" style="color:var(--accent)"></i> Schema Analysis`,body,()=>{});
|
||||
}
|
||||
|
||||
// ── Node Operations ──
|
||||
async function loadNode(path){
|
||||
currentPath=path;const r=await api("/node/get",{path});
|
||||
if(r.error){toast(r.error,"error");return;}
|
||||
currentNode=r;updateBreadcrumb(path);renderEditor(r,path);checkDirty();
|
||||
D.querySelectorAll(".tree-node").forEach(n=>n.classList.remove("active"));
|
||||
D.querySelectorAll(".tree-node").forEach(n=>{if(n.querySelector(".node-label")?.textContent===path.split("/").pop())n.classList.add("active");});
|
||||
}
|
||||
function updateBreadcrumb(path){
|
||||
const parts=path.split("/");
|
||||
$("breadcrumb").innerHTML='<span onclick="loadNode(\'\')"><i class="fa-solid fa-home"></i></span>'+parts.map((p,i)=>`<span class="sep">/</span><span onclick="loadNode('${parts.slice(0,i+1).join("/")}')">${p}</span>`).join("");
|
||||
$("breadcrumb").innerHTML+=`<span id="dirtyIndicator" class="dirty-dot" style="display:${$("statusDirty")?.style.display==="inline"?"inline":"none"}" title="Unsaved changes">●</span>`;
|
||||
}
|
||||
|
||||
// ── Dynamic Editor Router ──
|
||||
// Auto-detects the JSON type and renders the right editor
|
||||
function renderEditor(data,path){
|
||||
const area=$("editorArea");area.classList.remove("d-none");$("emptyState").style.display="none";
|
||||
if(rawMode)return;
|
||||
|
||||
if(data.type==="object") renderObjectEditor(data,path);
|
||||
else if(data.type==="array"){
|
||||
if(data.view_mode==="table") renderTableEditor(data,path);
|
||||
else if(data.view_mode==="list") renderListEditor(data,path);
|
||||
else renderListEditor(data,path); // fallback
|
||||
}
|
||||
else renderPrimitiveEditor(data,path);
|
||||
}
|
||||
|
||||
// ── Object Editor (works for flat, config, nested objects) ──
|
||||
function renderObjectEditor(data,path){
|
||||
const area=$("editorArea");
|
||||
let html=`<div class="card slide-up"><div class="card-header"><span class="card-title"><i class="fa-solid fa-folder-open"></i> Object · ${data.fields.length} fields</span>
|
||||
<div><button class="btn btn-ghost btn-sm" onclick="showAddFieldModal('${path}')"><i class="fa-solid fa-plus"></i> Add Field</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="analyzeSchema('${path}')"><i class="fa-solid fa-magnifying-glass-chart"></i></button></div></div>`;
|
||||
data.fields.forEach(f=>{
|
||||
html+=`<div class="field-row"><span class="field-key" ondblclick="renameFieldInline(this,'${path}','${f.key}')">${f.key}</span><span class="field-type-badge type-${f.type||"string"}">${f.type}</span><div class="field-value">`;
|
||||
if(f.is_complex){
|
||||
html+=`<button class="btn btn-ghost btn-sm" onclick="loadNode('${path}/${f.key}')"><i class="fa-solid fa-arrow-right"></i> ${f.type} (${f.child_count} items)</button>`;
|
||||
} else {
|
||||
html+=renderFieldControl(f, path);
|
||||
}
|
||||
html+=`</div><button class="btn-icon btn-sm" onclick="deleteNode('${path}/${f.key}')" title="Delete"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div>`;
|
||||
});
|
||||
html+="</div>";area.innerHTML=html;
|
||||
}
|
||||
|
||||
// ── Dynamic Field Control (renders the right input for any type) ──
|
||||
function renderFieldControl(f, parentPath){
|
||||
const val=f.value;const key=f.key;const fPath=`${parentPath}/${key}`;
|
||||
|
||||
if(f.type==="boolean"){
|
||||
return `<label class="toggle-switch"><input type="checkbox" ${val?"checked":""} onchange="editValue('${fPath}',this.checked,'boolean')"/><span class="toggle-slider"></span></label>
|
||||
<span style="font-size:11px;margin-left:6px;color:${val?'var(--success)':'var(--text-dim)'}">${val}</span>`;
|
||||
}
|
||||
if(f.type==="null"){
|
||||
return `<span style="color:var(--text-dim);font-style:italic">null</span>
|
||||
<button class="btn btn-ghost btn-sm" style="margin-left:8px" onclick="editValue('${fPath}','','string')"><i class="fa-solid fa-pen"></i> Set Value</button>`;
|
||||
}
|
||||
if(f.type==="number"){
|
||||
return `<div style="display:flex;align-items:center;gap:4px">
|
||||
<button class="btn-icon btn-sm" onclick="editValue('${fPath}',${(val||0)-1},'number')"><i class="fa-solid fa-minus"></i></button>
|
||||
<input class="input input-sm" type="number" value="${val!==null&&val!==undefined?val:''}" style="width:100px;text-align:center"
|
||||
onchange="editValue('${fPath}',this.value,'number')"/>
|
||||
<button class="btn-icon btn-sm" onclick="editValue('${fPath}',${(val||0)+1},'number')"><i class="fa-solid fa-plus"></i></button>
|
||||
</div>`;
|
||||
}
|
||||
if(f.type==="url"||f.type==="string"&&typeof val==="string"&&(val.startsWith("http://")||val.startsWith("https://"))){
|
||||
return `<div style="display:flex;align-items:center;gap:6px;flex:1">
|
||||
<input class="input input-sm" value="${String(val||'').replace(/"/g,""")}" onchange="editValue('${fPath}',this.value,'string')" style="flex:1"/>
|
||||
<a href="${val}" target="_blank" class="btn-icon btn-sm" title="Open URL"><i class="fa-solid fa-external-link-alt" style="color:var(--info)"></i></a>
|
||||
</div>`;
|
||||
}
|
||||
if(f.type==="coordinate"){
|
||||
return `<input class="input input-sm font-mono" value="${String(val||'').replace(/"/g,""")}" onchange="editValue('${fPath}',this.value,'string')" style="font-size:11px;color:var(--accent)"/>`;
|
||||
}
|
||||
// Default string/unknown
|
||||
const strVal=val===null?"":val;
|
||||
const displayVal=String(strVal).replace(/"/g,""");
|
||||
if(typeof strVal==="string"&&strVal.length>100){
|
||||
return `<textarea class="input input-sm" style="min-height:50px;font-size:11px" onchange="editValue('${fPath}',this.value,'string')">${displayVal}</textarea>`;
|
||||
}
|
||||
return `<input class="input input-sm" value="${displayVal}" onchange="editValue('${fPath}',this.value,'${f.type||"string"}')"/>`;
|
||||
}
|
||||
|
||||
// ── Table Editor (for arrays of objects — any schema) ──
|
||||
function renderTableEditor(data,path){
|
||||
const area=$("editorArea"),cols=data.columns||[],colTypes=data.column_types||{};
|
||||
let html=`<div class="card slide-up"><div class="card-header"><span class="card-title"><i class="fa-solid fa-table"></i> Array · ${data.total} items · ${cols.length} columns</span>
|
||||
<div style="display:flex;gap:6px;flex-wrap:wrap">
|
||||
<button class="btn btn-ghost btn-sm" onclick="showBulkAddFieldModal('${path}')"><i class="fa-solid fa-columns"></i> Add Col</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="showBulkRemoveFieldModal('${path}','${cols.join(",")}')"><i class="fa-solid fa-minus"></i> Remove Col</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="showBulkRenameFieldModal('${path}','${cols.join(",")}')"><i class="fa-solid fa-i-cursor"></i> Rename Col</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="showBulkEditFieldModal('${path}','${cols.join(",")}')"><i class="fa-solid fa-pen"></i> Bulk Edit</button>
|
||||
<button class="btn btn-primary btn-sm" onclick="showAppendPanel('${path}')"><i class="fa-solid fa-bolt"></i> Bulk Append</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="analyzeSchema('${path}')"><i class="fa-solid fa-magnifying-glass-chart"></i></button>
|
||||
</div></div>`;
|
||||
html+=`<div class="data-table-wrap" style="max-height:50vh"><table class="data-table"><thead><tr><th class="row-idx">#</th>`;
|
||||
cols.forEach(c=>{const tc=colTypes[c]||"string";html+=`<th>${c} <span class="field-type-badge type-${tc}" style="font-size:8px">${tc}</span></th>`;});
|
||||
html+=`<th style="width:70px">Actions</th></tr></thead><tbody>`;
|
||||
(data.items||[]).forEach((item,idx)=>{
|
||||
html+=`<tr><td class="row-idx">${idx}</td>`;
|
||||
cols.forEach(c=>{
|
||||
const v=item[c];const ct=colTypes[c]||"string";
|
||||
html+=renderTableCell(v,ct,path,idx,c);
|
||||
});
|
||||
html+=`<td><div class="row-actions" style="opacity:1"><button class="btn-icon btn-sm" onclick="editItemModal('${path}',${idx})"><i class="fa-solid fa-pen"></i></button><button class="btn-icon btn-sm" onclick="deleteItem('${path}',${idx})"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div></td></tr>`;
|
||||
});
|
||||
html+=`</tbody></table></div></div><div id="appendPanelWrap"></div>`;
|
||||
area.innerHTML=html;$("statusCount").textContent=`${data.total} items`;
|
||||
}
|
||||
|
||||
// ── Dynamic Table Cell (renders each cell based on its detected type) ──
|
||||
function renderTableCell(v,colType,path,idx,col){
|
||||
if(v===null||v===undefined) return `<td class="cell-editable" style="color:var(--text-dim);font-style:italic" ondblclick="inlineEditCell(this,'${path}',${idx},'${col}')">null</td>`;
|
||||
|
||||
if(typeof v==="boolean") return `<td><input type="checkbox" ${v?"checked":""} onchange="inlineToggleBool('${path}',${idx},'${col}',this.checked)" style="accent-color:var(--accent);cursor:pointer" title="${v}"/></td>`;
|
||||
|
||||
if(typeof v==="object"&&v!==null){
|
||||
const preview=JSON.stringify(v).substring(0,40);
|
||||
return `<td class="cell-editable" style="font-size:10px;color:var(--text-muted);cursor:pointer" onclick="loadNode('${path}/${idx}/${col}')" title='${JSON.stringify(v).replace(/'/g,"'")}'>${Array.isArray(v)?`[${v.length}]`:`{${Object.keys(v).length}}`} <i class="fa-solid fa-arrow-right" style="font-size:8px"></i></td>`;
|
||||
}
|
||||
|
||||
const strV=String(v);
|
||||
if(typeof v==="string"&&(strV.startsWith("http://")||strV.startsWith("https://"))){
|
||||
return `<td class="cell-editable" ondblclick="inlineEditCell(this,'${path}',${idx},'${col}')">
|
||||
<div style="display:flex;align-items:center;width:100%">
|
||||
<span style="flex:1;word-break:break-all;margin-right:6px">${strV}</span>
|
||||
<a href="${v}" target="_blank" class="btn-icon btn-sm" style="color:var(--info);flex-shrink:0" onclick="event.stopPropagation()" title="Open Link"><i class="fa-solid fa-external-link-alt"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
}
|
||||
|
||||
const escaped=strV.replace(/"/g,""");
|
||||
// Show full string, let CSS handle wrapping/scroll if needed (user requested no "...")
|
||||
return `<td class="cell-editable" ondblclick="inlineEditCell(this,'${path}',${idx},'${col}')" style="word-break:break-all">${strV}</td>`;
|
||||
}
|
||||
|
||||
// ── Inline Boolean Toggle (for table cells) ──
|
||||
async function inlineToggleBool(path,idx,col,val){
|
||||
const r=await api("/node/get",{path});
|
||||
if(r.items){const item={...r.items[idx]};item[col]=val;await api("/node/edit_item",{path,index:idx,item});loadNode(path);toast("Updated");}
|
||||
}
|
||||
|
||||
// ── List Editor (for arrays of primitives, mixed arrays) ──
|
||||
function renderListEditor(data,path){
|
||||
const area=$("editorArea");
|
||||
let html=`<div class="card slide-up"><div class="card-header"><span class="card-title"><i class="fa-solid fa-list"></i> Array · ${data.total} items</span>
|
||||
<div><button class="btn btn-ghost btn-sm" onclick="addArrayItem('${path}','string')"><i class="fa-solid fa-plus"></i> String</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="addArrayItem('${path}','number')"><i class="fa-solid fa-plus"></i> Number</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="addArrayItem('${path}','object')"><i class="fa-solid fa-plus"></i> Object</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="analyzeSchema('${path}')"><i class="fa-solid fa-magnifying-glass-chart"></i></button></div></div>`;
|
||||
(data.items||[]).forEach((item,idx)=>{
|
||||
const itemType=typeof item;
|
||||
if(item===null){
|
||||
html+=`<div class="field-row"><span class="row-idx">${idx}</span><span class="field-type-badge type-null">null</span><div class="field-value"><span style="color:var(--text-dim);font-style:italic">null</span></div>
|
||||
<button class="btn-icon btn-sm" onclick="deleteItem('${path}',${idx})"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div>`;
|
||||
} else if(typeof item==="object"){
|
||||
const preview=JSON.stringify(item).substring(0,60);
|
||||
html+=`<div class="field-row" style="cursor:pointer" onclick="loadNode('${path}/${idx}')"><span class="row-idx">${idx}</span><span class="field-type-badge type-${Array.isArray(item)?"array":"object"}">${Array.isArray(item)?"array":"object"}</span><div class="field-value"><span style="font-size:11px;color:var(--text-muted)">${preview}${preview.length>=60?"...":""}</span></div>
|
||||
<button class="btn-icon btn-sm" onclick="event.stopPropagation();deleteItem('${path}',${idx})"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div>`;
|
||||
} else if(typeof item==="boolean"){
|
||||
html+=`<div class="field-row"><span class="row-idx">${idx}</span><span class="field-type-badge type-boolean">bool</span><div class="field-value"><label class="toggle-switch"><input type="checkbox" ${item?"checked":""} onchange="editArrayValue('${path}',${idx},this.checked?'true':'false')"/><span class="toggle-slider"></span></label><span style="margin-left:6px;font-size:11px">${item}</span></div>
|
||||
<button class="btn-icon btn-sm" onclick="deleteItem('${path}',${idx})"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div>`;
|
||||
} else {
|
||||
html+=`<div class="field-row"><span class="row-idx">${idx}</span><span class="field-type-badge type-${typeof item==="number"?"number":"string"}">${typeof item}</span><div class="field-value"><input class="input input-sm" value="${String(item).replace(/"/g,""")}" onchange="editArrayValue('${path}',${idx},this.value)"/></div>
|
||||
<button class="btn-icon btn-sm" onclick="deleteItem('${path}',${idx})"><i class="fa-solid fa-trash" style="color:var(--danger)"></i></button></div>`;
|
||||
}
|
||||
});
|
||||
html+="</div>";area.innerHTML=html;
|
||||
}
|
||||
|
||||
// ── Primitive Editor (for individual values) ──
|
||||
function renderPrimitiveEditor(data,path){
|
||||
const area=$("editorArea"),v=data.value===null?"":data.value,t=data.type;
|
||||
let html=`<div class="card slide-up"><div class="card-header"><span class="card-title">Value · <span class="field-type-badge type-${t}">${t}</span></span></div>`;
|
||||
|
||||
if(t==="boolean"){
|
||||
html+=`<div style="display:flex;align-items:center;gap:12px;padding:12px"><label class="toggle-switch"><input type="checkbox" ${v?"checked":""} onchange="editValue('${path}',this.checked,'boolean')"/><span class="toggle-slider"></span></label><span style="font-size:14px;font-weight:600">${v}</span></div>`;
|
||||
} else if(t==="null"){
|
||||
html+=`<div style="padding:20px;text-align:center"><span style="color:var(--text-dim);font-size:16px;font-style:italic">null</span><br>
|
||||
<button class="btn btn-primary btn-sm mt-md" onclick="editValue('${path}','','string')"><i class="fa-solid fa-pen"></i> Set a Value</button></div>`;
|
||||
} else if(t==="number"){
|
||||
html+=`<div style="display:flex;align-items:center;gap:8px;padding:12px">
|
||||
<button class="btn-icon" onclick="editValue('${path}',${(v||0)-1},'number')"><i class="fa-solid fa-minus"></i></button>
|
||||
<input class="input" type="number" id="primVal" value="${v!==null?v:''}" style="width:150px;text-align:center;font-size:18px"/>
|
||||
<button class="btn-icon" onclick="editValue('${path}',${(v||0)+1},'number')"><i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
<button class="btn btn-primary mt-sm" onclick="editValue('${path}',$('primVal').value,'number')">Save</button>`;
|
||||
} else {
|
||||
const strV=String(v||"").replace(/"/g,""");
|
||||
if(typeof v==="string"&&(v.startsWith("http://")||v.startsWith("https://"))){
|
||||
html+=`<input class="input" id="primVal" value="${strV}"/>
|
||||
<a href="${v}" target="_blank" style="color:var(--info);font-size:12px;margin-top:4px;display:inline-block"><i class="fa-solid fa-external-link-alt"></i> Open Link</a>`;
|
||||
} else if(typeof v==="string"&&v.length>200){
|
||||
html+=`<textarea class="input" id="primVal" rows="6" style="font-family:'JetBrains Mono',monospace;font-size:12px">${strV}</textarea>`;
|
||||
} else {
|
||||
html+=`<input class="input" id="primVal" value="${strV}"/>`;
|
||||
}
|
||||
html+=`<div style="margin-top:10px;display:flex;gap:6px">
|
||||
<select class="input" style="width:120px" id="primType"><option value="string">String</option><option value="number">Number</option><option value="boolean">Boolean</option><option value="null">Null</option></select>
|
||||
<button class="btn btn-primary" onclick="editValue('${path}',$('primVal').value,$('primType').value)">Save</button></div>`;
|
||||
}
|
||||
html+="</div>";area.innerHTML=html;
|
||||
if($("primType"))$("primType").value=t;
|
||||
}
|
||||
|
||||
// ── Inline Cell Edit ──
|
||||
function inlineEditCell(td,path,idx,col){
|
||||
const orig=td.textContent;td.innerHTML=`<input class="input input-sm" value="${orig.replace(/"/g,""")}" style="width:100%" autofocus>`;
|
||||
const inp=td.querySelector("input");inp.focus();inp.select();
|
||||
const save=async()=>{const r=await api("/node/get",{path});if(r.success||r.items){const item={...(r.items||[])[idx]};item[col]=inp.value;await api("/node/edit_item",{path,index:idx,item});loadNode(path);toast("Updated");}};
|
||||
inp.onblur=save;inp.onkeydown=e=>{if(e.key==="Enter")save();if(e.key==="Escape")td.textContent=orig;};
|
||||
}
|
||||
|
||||
// ── API Wrappers ──
|
||||
async function editValue(path,value,type){const r=await api("/node/edit_value",{path,value,value_type:type});if(r.success){toast("Updated");refreshTree(r.tree);if(currentPath)loadNode(currentPath);checkDirty();}else toast(r.error,"error");}
|
||||
async function editArrayValue(path,idx,value){const r=await api("/node/edit_item",{path,index:idx,item:value});if(r.success){toast("Updated");loadNode(path);checkDirty();}else toast(r.error,"error");}
|
||||
async function deleteNode(path){if(!confirm("Delete this node?"))return;const r=await api("/node/delete",{path});if(r.success){toast("Deleted");refreshTree(r.tree);checkDirty();const parent=path.split("/").slice(0,-1).join("/");if(parent)loadNode(parent);else{$("editorArea").innerHTML="";$("editorArea").classList.add("d-none");$("emptyState").style.display="";}}else toast(r.error,"error");}
|
||||
async function deleteItem(path,idx){if(!confirm(`Delete item #${idx}?`))return;const r=await api("/node/delete_item",{path,index:idx});if(r.success){toast("Deleted");refreshTree(r.tree);loadNode(path);checkDirty();}else toast(r.error,"error");}
|
||||
async function duplicateNode(path){const r=await api("/node/duplicate",{path});if(r.success){toast("Duplicated");refreshTree(r.tree);checkDirty();}else toast(r.error,"error");}
|
||||
async function moveNode(path,dir){const r=await api("/node/move",{path,direction:dir});if(r.success){refreshTree(r.tree);toast("Moved");checkDirty();}else toast(r.error,"error");}
|
||||
async function doUndo(){const r=await api("/undo");if(r.success){refreshTree(r.tree);if(currentPath)loadNode(currentPath);toast("Undone","info");checkDirty();}else toast(r.error,"error");}
|
||||
async function doRedo(){const r=await api("/redo");if(r.success){refreshTree(r.tree);if(currentPath)loadNode(currentPath);toast("Redone","info");checkDirty();}else toast(r.error,"error");}
|
||||
function refreshTree(tree){if(tree){treeData=tree;renderTree(tree);}}
|
||||
|
||||
// ── Add Node Prompts ──
|
||||
function addNodePrompt(parentPath,type){
|
||||
showModal("Add "+type.charAt(0).toUpperCase()+type.slice(1),`
|
||||
<label class="label">Key Name</label><input class="input" id="mdAddKey" autofocus>
|
||||
${type==="string"||type==="number"?`<label class="label mt-md">Value</label><input class="input" id="mdAddVal">`:""}`,
|
||||
async()=>{const body={path:parentPath,key:$("mdAddKey").value,value_type:type};if($("mdAddVal"))body.value=$("mdAddVal").value;const r=await api("/node/add",body);if(r.success){refreshTree(r.tree);toast("Added");if(currentPath)loadNode(currentPath);checkDirty();}else toast(r.error,"error");});
|
||||
}
|
||||
async function addArrayItem(path,type){const r=await api("/node/add",{path,value_type:type,value:type==="object"?"{}":type==="number"?"0":""});if(r.success){refreshTree(r.tree);loadNode(path);toast("Item added");checkDirty();}else toast(r.error,"error");}
|
||||
function renamePrompt(node){showModal("Rename",`<label class="label">New Name</label><input class="input" id="mdRename" value="${node.key}">`,async()=>{const r=await api("/node/rename",{path:node.path,new_name:$("mdRename").value});if(r.success){refreshTree(r.tree);toast("Renamed");checkDirty();}else toast(r.error,"error");});}
|
||||
function showAddFieldModal(path){
|
||||
showModal("Add Field",`<label class="label">Key</label><input class="input" id="mdFK">
|
||||
<label class="label mt-md">Type</label><select class="input" id="mdFT"><option value="string">String</option><option value="number">Number</option><option value="boolean">Boolean</option><option value="null">Null</option><option value="object">Object</option><option value="array">Array</option></select>
|
||||
<label class="label mt-md">Value</label><input class="input" id="mdFV">`,
|
||||
async()=>{const r=await api("/node/add",{path,key:$("mdFK").value,value_type:$("mdFT").value,value:$("mdFV").value||null});if(r.success){refreshTree(r.tree);loadNode(path);toast("Field added");checkDirty();}else toast(r.error,"error");});
|
||||
}
|
||||
|
||||
// ── Bulk Modals (simple ones) ──
|
||||
function showBulkAddFieldModal(path){
|
||||
showModal("Add Column to All Items",`<label class="label">Field Name</label><input class="input" id="mdBFK">
|
||||
<label class="label mt-md">Type</label><select class="input" id="mdBFT"><option value="string">String</option><option value="number">Number</option><option value="boolean">Boolean</option></select>
|
||||
<label class="label mt-md">Default Value</label><input class="input" id="mdBFV">`,
|
||||
async()=>{const r=await api("/bulk/add_field",{path,field_name:$("mdBFK").value,field_type:$("mdBFT").value,default_value:$("mdBFV").value});if(r.success){loadNode(path);toast(`Added to ${r.modified} items`);checkDirty();}else toast(r.error,"error");});
|
||||
}
|
||||
function showBulkRemoveFieldModal(path,colsStr){
|
||||
const cols=colsStr.split(",");
|
||||
showModal("Remove Column",`<label class="label">Select Field</label><select class="input" id="mdBRF">${cols.map(c=>`<option value="${c}">${c}</option>`).join("")}</select>`,
|
||||
async()=>{const r=await api("/bulk/remove_field",{path,field_name:$("mdBRF").value});if(r.success){refreshTree(r.tree);loadNode(path);toast(`Removed from ${r.modified} items`);checkDirty();}else toast(r.error,"error");});
|
||||
}
|
||||
function showBulkRenameFieldModal(path,colsStr){
|
||||
const cols=colsStr.split(",");
|
||||
showModal("Rename Column",`<label class="label">Current Name</label><select class="input" id="mdBRnOld">${cols.map(c=>`<option value="${c}">${c}</option>`).join("")}</select>
|
||||
<label class="label mt-md">New Name</label><input class="input" id="mdBRnNew">`,
|
||||
async()=>{const r=await api("/bulk/rename_field",{path,old_name:$("mdBRnOld").value,new_name:$("mdBRnNew").value});if(r.success){refreshTree(r.tree);loadNode(path);toast(`Renamed in ${r.modified} items`);checkDirty();}else toast(r.error,"error");});
|
||||
}
|
||||
</script>
|
||||
<script src="/static/bulk_edit.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,663 @@
|
||||
// ── Per-Field Toggle Bulk Edit Modal ──
|
||||
function showBulkEditFieldModal(path, colsStr) {
|
||||
const cols = colsStr.split(",");
|
||||
const modes = [
|
||||
{ v: "set", l: "Set Value" }, { v: "pattern", l: "Pattern {i}" },
|
||||
{ v: "sequence", l: "Sequence" }, { v: "find_replace", l: "Find & Replace" },
|
||||
{ v: "regex", l: "Regex" }, { v: "increment", l: "Increment" },
|
||||
{ v: "prefix_suffix", l: "Prefix/Suffix" }, { v: "conditional", l: "Conditional" }
|
||||
];
|
||||
const modeOpts = modes.map(m => `<option value="${m.v}">${m.l}</option>`).join("");
|
||||
const colOpts = cols.map(c => `<option value="${c}">${c}</option>`).join("");
|
||||
|
||||
let fieldsHtml = cols.map(c => `
|
||||
<div class="field-config" id="fc_${c}" data-field="${c}">
|
||||
<div class="field-config-header">
|
||||
<label class="toggle-switch">
|
||||
<input type="checkbox" onchange="toggleFieldConfig('${c}',this.checked)"/>
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
<span class="field-name">${c}</span>
|
||||
<span class="field-badge">unchanged</span>
|
||||
</div>
|
||||
<div class="field-config-body">
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:8px">
|
||||
<div><label class="label-sm">Mode</label><select class="input input-sm" id="fc_mode_${c}" onchange="updateFieldModeUI('${c}')">${modeOpts}</select></div>
|
||||
<div><label class="label-sm">Type</label><select class="input input-sm" id="fc_type_${c}"><option value="string">String</option><option value="number">Number</option></select></div>
|
||||
</div>
|
||||
<div id="fc_opts_${c}" class="mt-sm">
|
||||
<div id="fc_set_${c}"><label class="label-sm mt-sm">Value</label><input class="input input-sm" id="fc_val_${c}" placeholder="Enter value..."></div>
|
||||
<div id="fc_pattern_${c}" style="display:none"><label class="label-sm mt-sm">Pattern</label><input class="input input-sm" id="fc_pat_${c}" placeholder="e.g. image_{i}.webp">
|
||||
<label class="label-sm mt-sm">Start {i} at</label><input class="input input-sm" id="fc_patstart_${c}" type="number" value="1"></div>
|
||||
<div id="fc_sequence_${c}" style="display:none"><label class="label-sm mt-sm">Start #</label><input class="input input-sm" id="fc_seqstart_${c}" type="number" value="1"></div>
|
||||
<div id="fc_find_replace_${c}" style="display:none"><label class="label-sm mt-sm">Find</label><input class="input input-sm" id="fc_find_${c}"><label class="label-sm mt-sm">Replace</label><input class="input input-sm" id="fc_repl_${c}"></div>
|
||||
<div id="fc_regex_${c}" style="display:none"><label class="label-sm mt-sm">Regex</label><input class="input input-sm font-mono" id="fc_rxfind_${c}"><label class="label-sm mt-sm">Replace</label><input class="input input-sm font-mono" id="fc_rxrepl_${c}"><label class="label-sm mt-sm">Start {i}</label><input class="input input-sm" id="fc_rxstart_${c}" type="number" value="1"></div>
|
||||
<div id="fc_increment_${c}" style="display:none"><label class="label-sm mt-sm">Increment By</label><input class="input input-sm" id="fc_inc_${c}" type="number" value="1"></div>
|
||||
<div id="fc_prefix_suffix_${c}" style="display:none"><label class="label-sm mt-sm">Prefix</label><input class="input input-sm" id="fc_pfx_${c}"><label class="label-sm mt-sm">Suffix</label><input class="input input-sm" id="fc_sfx_${c}"></div>
|
||||
<div id="fc_conditional_${c}" style="display:none">
|
||||
<div style="padding:8px;background:var(--bg-input);border-radius:6px;margin-top:6px">
|
||||
<label class="label-sm" style="color:var(--warning)">IF condition:</label>
|
||||
<div style="display:grid;grid-template-columns:1fr auto 1fr;gap:4px;margin-top:4px">
|
||||
<select class="input input-sm" id="fc_condfield_${c}">${colOpts}</select>
|
||||
<select class="input input-sm" id="fc_condop_${c}"><option value="equals">equals</option><option value="not_equals">≠</option><option value="contains">contains</option><option value="starts_with">starts</option><option value="ends_with">ends</option></select>
|
||||
<input class="input input-sm" id="fc_condval_${c}" placeholder="value">
|
||||
</div>
|
||||
</div>
|
||||
<label class="label-sm mt-sm">THEN set to</label><input class="input input-sm" id="fc_condnew_${c}" placeholder="e.g. premium_{i}">
|
||||
<label class="label-sm mt-sm">Start {i}</label><input class="input input-sm" id="fc_condstart_${c}" type="number" value="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`).join("");
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "modal-overlay";
|
||||
overlay.innerHTML = `<div class="modal-box modal-wide"><h3><i class="fa-solid fa-bolt" style="color:var(--accent)"></i> Per-Field Bulk Edit</h3>
|
||||
<div style="padding:8px 12px;background:var(--bg-card);border-radius:var(--radius-sm);margin-bottom:12px;font-size:11px;color:var(--text-muted)">
|
||||
<i class="fa-solid fa-info-circle text-info"></i> Toggle switches ON for fields you want to edit. Each field gets its own mode and settings.
|
||||
<br><strong class="text-accent">Placeholders:</strong> <code class="font-mono text-accent">{i}</code> counter · <code class="font-mono text-accent">{idx}</code> index · <code class="font-mono text-accent">{total}</code> total · <code class="font-mono text-accent">{value}</code> current · <code class="font-mono text-accent">{field_name}</code> other field
|
||||
</div>
|
||||
<div id="fieldConfigList">${fieldsHtml}</div>
|
||||
<div class="modal-actions"><button class="btn btn-ghost" id="mdCancel">Cancel</button><button class="btn btn-primary" id="mdConfirm"><i class="fa-solid fa-check"></i> Apply Changes</button></div></div>`;
|
||||
document.body.appendChild(overlay);
|
||||
overlay.querySelector("#mdCancel").onclick = () => overlay.remove();
|
||||
overlay.addEventListener("click", e => { if (e.target === overlay) overlay.remove(); });
|
||||
overlay.querySelector("#mdConfirm").onclick = async () => {
|
||||
const fields = {};
|
||||
cols.forEach(c => {
|
||||
const el = document.getElementById("fc_" + c);
|
||||
const chk = el.querySelector("input[type=checkbox]");
|
||||
if (!chk.checked) return;
|
||||
const mode = document.getElementById("fc_mode_" + c).value;
|
||||
const cfg = { enabled: true, mode, value_type: document.getElementById("fc_type_" + c).value };
|
||||
if (mode === "set") cfg.new_value = document.getElementById("fc_val_" + c).value;
|
||||
else if (mode === "pattern") { cfg.new_value = document.getElementById("fc_pat_" + c).value; cfg.start_counter = document.getElementById("fc_patstart_" + c).value; }
|
||||
else if (mode === "sequence") cfg.start_counter = document.getElementById("fc_seqstart_" + c).value;
|
||||
else if (mode === "find_replace") { cfg.find_text = document.getElementById("fc_find_" + c).value; cfg.replace_text = document.getElementById("fc_repl_" + c).value; }
|
||||
else if (mode === "regex") { cfg.find_text = document.getElementById("fc_rxfind_" + c).value; cfg.replace_text = document.getElementById("fc_rxrepl_" + c).value; cfg.start_counter = document.getElementById("fc_rxstart_" + c).value; }
|
||||
else if (mode === "increment") cfg.increment_by = document.getElementById("fc_inc_" + c).value;
|
||||
else if (mode === "prefix_suffix") { cfg.prefix = document.getElementById("fc_pfx_" + c).value; cfg.suffix = document.getElementById("fc_sfx_" + c).value; }
|
||||
else if (mode === "conditional") { cfg.condition_field = document.getElementById("fc_condfield_" + c).value; cfg.condition_op = document.getElementById("fc_condop_" + c).value; cfg.condition_value = document.getElementById("fc_condval_" + c).value; cfg.new_value = document.getElementById("fc_condnew_" + c).value; cfg.start_counter = document.getElementById("fc_condstart_" + c).value; }
|
||||
fields[c] = cfg;
|
||||
});
|
||||
if (Object.keys(fields).length === 0) { toast("Enable at least one field", "error"); return; }
|
||||
const r = await api("/bulk/edit_multi_field", { path, fields });
|
||||
if (r.success) { loadNode(path); toast(`Edited ${r.modified} items`); overlay.remove(); }
|
||||
else toast(r.error, "error");
|
||||
};
|
||||
}
|
||||
|
||||
function toggleFieldConfig(field, checked) {
|
||||
const el = document.getElementById("fc_" + field);
|
||||
if (checked) { el.classList.add("active"); el.querySelector(".field-badge").textContent = "editing"; el.querySelector(".field-badge").style.color = "var(--success)"; }
|
||||
else { el.classList.remove("active"); el.querySelector(".field-badge").textContent = "unchanged"; el.querySelector(".field-badge").style.color = ""; }
|
||||
}
|
||||
|
||||
function updateFieldModeUI(field) {
|
||||
const mode = document.getElementById("fc_mode_" + field).value;
|
||||
const allModes = ["set", "pattern", "sequence", "find_replace", "regex", "increment", "prefix_suffix", "conditional"];
|
||||
allModes.forEach(m => { const el = document.getElementById("fc_" + m + "_" + field); if (el) el.style.display = m === mode ? "block" : "none"; });
|
||||
}
|
||||
|
||||
// ── Edit Item Modal ──
|
||||
function editItemModal(path, idx) {
|
||||
api("/node/get", { path }).then(data => {
|
||||
if (!data.items) return;
|
||||
const item = data.items[idx], cols = data.columns || Object.keys(item);
|
||||
let fields = cols.map(c => `<label class="label mt-sm">${c}</label><input class="input" id="mdEI_${c}" value="${item[c] !== null && item[c] !== undefined ? String(item[c]).replace(/"/g, """) : ""}">`).join("");
|
||||
showModal(`Edit Item #${idx}`, fields, async () => {
|
||||
const newItem = {}; cols.forEach(c => newItem[c] = document.getElementById(`mdEI_${c}`).value);
|
||||
const r = await api("/node/edit_item", { path, index: idx, item: newItem });
|
||||
if (r.success) { loadNode(path); toast("Updated"); } else toast(r.error, "error");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ── Multi-Category Add Field + Append Modal ──
|
||||
let _mcFieldCounter = 0;
|
||||
async function showMultiCatAddFieldModal() {
|
||||
const discovery = await api("/discover_arrays", {});
|
||||
if (!discovery.success) { toast("No data loaded", "error"); return; }
|
||||
const catTree = discovery.category_tree || [];
|
||||
const allArrays = discovery.arrays || [];
|
||||
if (allArrays.length === 0) { toast("No arrays found in JSON", "error"); return; }
|
||||
_mcFieldCounter = 0;
|
||||
|
||||
function buildCatTreeHtml(nodes, indent) {
|
||||
let h = "";
|
||||
for (const n of nodes) {
|
||||
const isArr = n.is_array === true;
|
||||
const pad = indent * 18;
|
||||
const icon = isArr ? "fa-layer-group text-info" : "fa-folder text-warning";
|
||||
const badge = isArr ? `<span class="cat-count">${n.count}</span>` : "";
|
||||
const fields = (n.sample_fields || []).length ? `<span style="font-size:9px;color:var(--text-dim);margin-left:4px">[${n.sample_fields.slice(0,3).join(", ")}${n.sample_fields.length>3?"...":""}]</span>` : "";
|
||||
|
||||
if (isArr) {
|
||||
h += `<div class="cat-tree-item" style="margin-left:${pad}px">
|
||||
<input type="checkbox" class="mc-target" value="${n.path}" data-fields='${JSON.stringify(n.sample_fields||[])}'>
|
||||
<i class="fa-solid ${icon}" style="font-size:11px;width:14px"></i>
|
||||
<span style="flex:1">${n.key}</span>${badge}${fields}</div>`;
|
||||
} else {
|
||||
h += `<div class="cat-tree-item" style="margin-left:${pad}px;font-weight:700;color:var(--text-primary)">
|
||||
<input type="checkbox" class="mc-cat-toggle" onchange="toggleCatChildren(this)">
|
||||
<i class="fa-solid ${icon}" style="font-size:11px;width:14px"></i>
|
||||
<span style="flex:1">${n.key}</span></div>`;
|
||||
}
|
||||
if (n.children && n.children.length > 0) {
|
||||
h += `<div class="mc-cat-group">${buildCatTreeHtml(n.children, indent + 1)}</div>`;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
const treeHtml = buildCatTreeHtml(catTree, 0);
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "modal-overlay";
|
||||
overlay.innerHTML = `<div class="modal-box modal-wide" style="width:860px;max-width:96vw">
|
||||
<h3><i class="fa-solid fa-wand-magic-sparkles" style="color:var(--accent)"></i> Multi-Category Add Field + Append</h3>
|
||||
<div style="padding:8px 12px;background:var(--bg-card);border-radius:var(--radius-sm);margin-bottom:12px;font-size:11px;color:var(--text-muted)">
|
||||
<i class="fa-solid fa-info-circle text-info"></i> Select <strong>categories/subcategories</strong> to target, define fields to add/modify, then optionally append new items.
|
||||
<br><strong class="text-accent">Placeholders:</strong> <code class="font-mono text-accent">{i}</code> counter · <code class="font-mono text-accent">{idx}</code> index · <code class="font-mono text-accent">{total}</code> total
|
||||
</div>
|
||||
|
||||
<div style="display:grid;grid-template-columns:280px 1fr;gap:14px">
|
||||
<!-- Left: Category Tree -->
|
||||
<div>
|
||||
<div class="section-title"><i class="fa-solid fa-sitemap"></i> TARGET CATEGORIES</div>
|
||||
<div class="card" style="margin:0;max-height:380px;overflow-y:auto;padding:8px">
|
||||
<div class="cat-tree-item" style="border-bottom:1px solid var(--border);padding-bottom:6px;margin-bottom:4px">
|
||||
<input type="checkbox" id="mcSelAll" onchange="document.querySelectorAll('.mc-target,.mc-cat-toggle').forEach(c=>c.checked=this.checked);document.querySelectorAll('.mc-cat-toggle').forEach(c=>toggleCatChildren(c))">
|
||||
<strong>Select All</strong><span class="cat-count">${allArrays.length} arrays</span>
|
||||
</div>
|
||||
${treeHtml}
|
||||
</div>
|
||||
<div style="font-size:10px;color:var(--text-dim);margin-top:4px"><span id="mcSelectedCount">0</span> arrays selected</div>
|
||||
</div>
|
||||
|
||||
<!-- Right: Field Definitions -->
|
||||
<div>
|
||||
<div class="section-title"><i class="fa-solid fa-columns"></i> FIELDS TO ADD/MODIFY</div>
|
||||
<div id="mcFieldList" style="max-height:250px;overflow-y:auto"></div>
|
||||
<button class="btn btn-ghost btn-sm mt-sm" onclick="addMcField()"><i class="fa-solid fa-plus"></i> Add Field</button>
|
||||
|
||||
<div style="margin-top:14px;border-top:1px solid var(--border);padding-top:12px">
|
||||
<div class="section-title"><i class="fa-solid fa-plus-circle"></i> ALSO APPEND NEW ITEMS (optional)</div>
|
||||
<div style="display:flex;gap:10px;align-items:center">
|
||||
<label class="toggle-switch">
|
||||
<input type="checkbox" id="mcAppendToggle">
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
<span style="font-size:12px;font-weight:600">Append new items to each target</span>
|
||||
</div>
|
||||
<div id="mcAppendOpts" style="display:none;margin-top:8px">
|
||||
<label class="label-sm">Number of items to append per target</label>
|
||||
<input class="input input-sm" type="number" id="mcAppendCount" value="10" style="width:100px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-ghost" id="mcCancel">Cancel</button>
|
||||
<button class="btn btn-primary" id="mcApply"><i class="fa-solid fa-check"></i> Apply to Selected Targets</button>
|
||||
</div>
|
||||
</div>`;
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
overlay.querySelector("#mcAppendToggle").onchange = function() {
|
||||
overlay.querySelector("#mcAppendOpts").style.display = this.checked ? "block" : "none";
|
||||
};
|
||||
|
||||
overlay.addEventListener("change", () => {
|
||||
const count = overlay.querySelectorAll(".mc-target:checked").length;
|
||||
overlay.querySelector("#mcSelectedCount").textContent = count;
|
||||
});
|
||||
|
||||
addMcField();
|
||||
|
||||
overlay.querySelector("#mcCancel").onclick = () => overlay.remove();
|
||||
overlay.addEventListener("click", e => { if (e.target === overlay) overlay.remove(); });
|
||||
|
||||
overlay.querySelector("#mcApply").onclick = async () => {
|
||||
const targetPaths = [];
|
||||
overlay.querySelectorAll(".mc-target:checked").forEach(cb => targetPaths.push(cb.value));
|
||||
if (targetPaths.length === 0) { toast("Select at least one target array", "error"); return; }
|
||||
|
||||
const fieldRows = document.querySelectorAll(".mc-field-row");
|
||||
const fieldDefs = [];
|
||||
for (const row of fieldRows) {
|
||||
const name = row.querySelector(".mc-f-name").value.trim();
|
||||
if (!name) continue;
|
||||
const distMode = row.querySelector(".mc-f-dist").value;
|
||||
const def = {
|
||||
name,
|
||||
type: row.querySelector(".mc-f-type").value,
|
||||
value: row.querySelector(".mc-f-val").value,
|
||||
use_pattern: row.querySelector(".mc-f-pattern").checked,
|
||||
start: parseInt(row.querySelector(".mc-f-start").value || 1),
|
||||
dist_mode: distMode
|
||||
};
|
||||
if (distMode === "random") {
|
||||
def.dist_rand_primary = row.querySelector(".mc-f-rand-prim").value;
|
||||
def.dist_rand_secondary = row.querySelector(".mc-f-rand-sec").value;
|
||||
def.dist_rand_pct = parseInt(row.querySelector(".mc-f-rand-pct").value || 50);
|
||||
} else if (distMode === "cyclic") {
|
||||
def.dist_pattern = row.querySelector(".mc-f-cyclic-pat").value;
|
||||
}
|
||||
fieldDefs.push(def);
|
||||
}
|
||||
if (fieldDefs.length === 0) { toast("Add at least one field", "error"); return; }
|
||||
|
||||
const targets = targetPaths.map(p => ({ path: p, fields: fieldDefs }));
|
||||
const body = { targets };
|
||||
if (document.getElementById("mcAppendToggle").checked) {
|
||||
body.append_items = true;
|
||||
body.append_count = parseInt(document.getElementById("mcAppendCount").value || 0);
|
||||
}
|
||||
|
||||
const r = await api("/bulk/add_field_multi", body);
|
||||
if (r.success) {
|
||||
toast(`Modified ${r.modified} fields across ${r.targets} targets` + (r.appended > 0 ? `, appended ${r.appended} items` : ""));
|
||||
refreshTree(r.tree);
|
||||
if (currentPath) loadNode(currentPath);
|
||||
overlay.remove();
|
||||
} else toast(r.error, "error");
|
||||
};
|
||||
}
|
||||
|
||||
function addMcField() {
|
||||
_mcFieldCounter++;
|
||||
const id = _mcFieldCounter;
|
||||
const row = document.createElement("div");
|
||||
row.className = "mc-field-row field-config active";
|
||||
row.style.cssText = "padding:8px 10px;margin-bottom:6px";
|
||||
row.innerHTML = `
|
||||
<div style="display:grid;grid-template-columns:1fr 80px 1fr 40px 60px 90px 28px;gap:6px;align-items:end">
|
||||
<div><label class="label-sm">Field Name</label><input class="input input-sm mc-f-name" placeholder="e.g. thumbnail"></div>
|
||||
<div><label class="label-sm">Type</label><select class="input input-sm mc-f-type"><option value="string">String</option><option value="number">Number</option><option value="boolean">Bool</option></select></div>
|
||||
<div><label class="label-sm">Value / Pattern</label><input class="input input-sm mc-f-val" placeholder="e.g. thumb_{i}.webp"></div>
|
||||
<div style="text-align:center"><label class="label-sm" title="Use pattern placeholders like {i}">{i}?</label><input type="checkbox" class="mc-f-pattern" checked style="margin-top:4px;accent-color:var(--accent)"></div>
|
||||
<div><label class="label-sm">Start #</label><input class="input input-sm mc-f-start" type="number" value="1"></div>
|
||||
<div><label class="label-sm">Dist</label><select class="input input-sm mc-f-dist" onchange="toggleMcFieldDist(this)"><option value="static">Static</option><option value="random">Random %</option><option value="cyclic">Cyclic</option></select></div>
|
||||
<div><button class="btn-icon btn-sm" onclick="this.closest('.mc-field-row').remove()" title="Remove"><i class="fa-solid fa-times" style="color:var(--danger)"></i></button></div>
|
||||
</div>
|
||||
<div class="mc-f-dist-opts" style="display:none;margin-top:6px;padding:6px 8px;background:var(--bg-input);border-radius:6px">
|
||||
<div class="mc-f-random-opts" style="display:none">
|
||||
<div style="display:grid;grid-template-columns:1fr 60px 1fr;gap:6px;align-items:end">
|
||||
<div><label class="label-sm">Primary</label><input class="input input-sm mc-f-rand-prim" value="free" placeholder="e.g. free"></div>
|
||||
<div><label class="label-sm">%</label><input class="input input-sm mc-f-rand-pct" type="number" value="70" style="text-align:center"></div>
|
||||
<div><label class="label-sm">Secondary</label><input class="input input-sm mc-f-rand-sec" value="paid" placeholder="e.g. paid"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mc-f-cyclic-opts" style="display:none">
|
||||
<label class="label-sm">Cyclic Pattern (comma-separated)</label>
|
||||
<input class="input input-sm mc-f-cyclic-pat" placeholder="free, free, paid" value="">
|
||||
</div>
|
||||
</div>`;
|
||||
document.getElementById("mcFieldList").appendChild(row);
|
||||
}
|
||||
|
||||
function toggleMcFieldDist(sel) {
|
||||
const row = sel.closest(".mc-field-row");
|
||||
const mode = sel.value;
|
||||
const optsWrap = row.querySelector(".mc-f-dist-opts");
|
||||
const randomOpts = row.querySelector(".mc-f-random-opts");
|
||||
const cyclicOpts = row.querySelector(".mc-f-cyclic-opts");
|
||||
|
||||
if (mode === "static") {
|
||||
optsWrap.style.display = "none";
|
||||
} else {
|
||||
optsWrap.style.display = "block";
|
||||
randomOpts.style.display = mode === "random" ? "block" : "none";
|
||||
cyclicOpts.style.display = mode === "cyclic" ? "block" : "none";
|
||||
}
|
||||
// When using distribution, disable pattern checkbox and value field
|
||||
const patternCb = row.querySelector(".mc-f-pattern");
|
||||
const valInput = row.querySelector(".mc-f-val");
|
||||
if (mode !== "static") {
|
||||
patternCb.checked = false;
|
||||
patternCb.disabled = true;
|
||||
valInput.disabled = true;
|
||||
valInput.style.opacity = "0.4";
|
||||
} else {
|
||||
patternCb.disabled = false;
|
||||
valInput.disabled = false;
|
||||
valInput.style.opacity = "1";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCatChildren(checkbox) {
|
||||
const group = checkbox.closest(".cat-tree-item").nextElementSibling;
|
||||
if (group && group.classList.contains("mc-cat-group")) {
|
||||
group.querySelectorAll(".mc-target").forEach(cb => cb.checked = checkbox.checked);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Multi-Category Append Panel ──
|
||||
let _apFieldCounter = 0;
|
||||
async function showAppendPanel(path) {
|
||||
const anal = await api("/analyze_category", { path });
|
||||
if (!anal.success) return;
|
||||
const fields = anal.fields, samples = anal.samples, inappOpts = anal.inapp_options;
|
||||
|
||||
const discovery = await api("/discover_arrays", {});
|
||||
const allArrays = discovery.success ? discovery.arrays : [];
|
||||
const catTree = discovery.success ? (discovery.category_tree || []) : [];
|
||||
_apFieldCounter = 0;
|
||||
|
||||
const wrap = document.getElementById("appendPanelWrap") || document.getElementById("editorArea");
|
||||
|
||||
// Build field rows HTML with per-field distribution
|
||||
let fHtml = "";
|
||||
fields.forEach((f, fi) => {
|
||||
_apFieldCounter++;
|
||||
const fid = _apFieldCounter;
|
||||
let v = samples[f] || "";
|
||||
if (f === "coordinates") v = "{line}";
|
||||
else if (typeof v === "string" && v.includes("http")) v = v.replace(/(\d+)(?=\.\w+$)/, "{i}");
|
||||
fHtml += _buildAppendFieldRow(fid, f, v, false);
|
||||
});
|
||||
|
||||
// Build hierarchical category tree for multi-target
|
||||
let catHtml = "";
|
||||
if (allArrays.length > 1) {
|
||||
function buildAppendTree(nodes, indent) {
|
||||
let h = "";
|
||||
for (const n of nodes) {
|
||||
const pad = indent * 16;
|
||||
if (n.is_array) {
|
||||
h += `<div class="cat-tree-item" style="margin-left:${pad}px">
|
||||
<input type="checkbox" class="ap-target" value="${n.path}" ${n.path === path ? "checked" : ""}>
|
||||
<i class="fa-solid fa-layer-group text-info" style="font-size:10px;width:14px"></i>
|
||||
<span>${n.key}</span><span class="cat-count">${n.count}</span></div>`;
|
||||
} else {
|
||||
h += `<div class="cat-tree-item" style="margin-left:${pad}px;font-weight:700;color:var(--text-primary)">
|
||||
<input type="checkbox" class="ap-cat-toggle" onchange="let g=this.closest('.cat-tree-item').nextElementSibling;if(g)g.querySelectorAll('.ap-target').forEach(c=>c.checked=this.checked)">
|
||||
<i class="fa-solid fa-folder text-warning" style="font-size:10px;width:14px"></i>
|
||||
<span>${n.key}</span></div>`;
|
||||
}
|
||||
if (n.children && n.children.length) {
|
||||
h += `<div class="ap-cat-group">${buildAppendTree(n.children, indent + 1)}</div>`;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
catHtml = `<div class="card" style="margin:0"><div class="section-title"><i class="fa-solid fa-sitemap"></i> TARGET ARRAYS (multi-select)</div>
|
||||
<div class="cat-tree" id="apCatTree">
|
||||
<div class="cat-tree-item" style="border-bottom:1px solid var(--border);padding-bottom:4px;margin-bottom:4px">
|
||||
<input type="checkbox" id="apSelAll" onchange="toggleAllTargets(this.checked)"><strong>Select All</strong><span class="cat-count">${allArrays.length}</span>
|
||||
</div>
|
||||
${buildAppendTree(catTree, 0)}
|
||||
</div></div>`;
|
||||
}
|
||||
|
||||
let panelHtml = `<div class="card slide-up" id="appendCard"><div class="card-header"><span class="card-title"><i class="fa-solid fa-bolt"></i> Bulk Append to ${path.split("/").pop()}</span>
|
||||
<button class="btn-icon btn-sm" onclick="document.getElementById('appendCard').remove()"><i class="fa-solid fa-times"></i></button></div>
|
||||
<div class="append-panel">
|
||||
<div class="card" style="margin:0"><div class="section-title"><i class="fa-solid fa-file-lines"></i> DATA FILE (optional)</div>
|
||||
<input type="file" class="input input-sm" id="apDataFile"><div id="apFileStatus" style="color:var(--success);font-size:11px;margin-top:4px"></div>
|
||||
<div class="section-title mt-md"><i class="fa-solid fa-sliders"></i> COUNT</div>
|
||||
<div style="display:flex;gap:8px"><div><label class="label-sm">Manual Count</label><input class="input input-sm" type="number" id="apManualCount" value="10"></div>
|
||||
<div><label class="label-sm">Limit</label><input class="input input-sm" type="number" id="apLimit" value="0" placeholder="0=all"></div></div>
|
||||
<div style="text-align:center;font-size:12px;margin-top:6px;color:var(--info)">Generating <strong id="apTotal">0</strong> items</div>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;gap:14px">
|
||||
${catHtml}
|
||||
<div class="card" style="margin:0"><div class="section-title"><i class="fa-solid fa-wand-magic-sparkles"></i> FIELD PATTERNS <span style="font-size:9px;color:var(--text-dim);font-weight:400">— per-field distribution supported</span></div>
|
||||
<div style="padding:4px 8px;background:var(--bg-card);border-radius:var(--radius-sm);margin-bottom:8px;font-size:10px;color:var(--text-muted)">
|
||||
Each field can be: <strong>Static</strong> (pattern with {i}), <strong>Random %</strong> (e.g. 70% free / 30% paid), or <strong>Cyclic</strong> (e.g. free, free, paid).
|
||||
</div>
|
||||
<div id="apFieldsContainer">${fHtml}</div>
|
||||
<button class="btn btn-ghost btn-sm mt-sm" onclick="addAppendField()"><i class="fa-solid fa-plus"></i> Add Column</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="full-width" style="display:flex;gap:8px"><button class="btn btn-primary" style="flex:1" onclick="doPreviewAppend('${path}')"><i class="fa-solid fa-eye"></i> Preview</button></div>
|
||||
<div class="full-width" id="apPreviewWrap" style="display:none"><div class="preview-box"><pre id="apPreviewJSON"></pre></div>
|
||||
<div style="display:flex;gap:8px;margin-top:8px"><button class="btn btn-success" style="flex:1" onclick="doCommitAppend('${path}')"><i class="fa-solid fa-check"></i> Append <span id="apPreviewCount"></span> items</button></div></div>
|
||||
</div></div>`;
|
||||
|
||||
if (document.getElementById("appendPanelWrap")) document.getElementById("appendPanelWrap").innerHTML = panelHtml;
|
||||
else wrap.innerHTML += panelHtml;
|
||||
|
||||
// Events
|
||||
document.getElementById("apDataFile").addEventListener("change", e => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = ev => {
|
||||
const lines = ev.target.result.split("\n").filter(l => l.trim() && !l.startsWith("#"));
|
||||
document.getElementById("apFileStatus").textContent = lines.length + " lines found";
|
||||
document.getElementById("apManualCount").value = lines.length;
|
||||
updateAppendTotal();
|
||||
};
|
||||
reader.readAsText(e.target.files[0]);
|
||||
});
|
||||
|
||||
const updateAppendTotal = () => {
|
||||
const mc = parseInt(document.getElementById("apManualCount").value || 0);
|
||||
const lim = parseInt(document.getElementById("apLimit").value || 0);
|
||||
document.getElementById("apTotal").textContent = lim > 0 ? Math.min(mc, lim) : mc;
|
||||
};
|
||||
document.getElementById("apManualCount").oninput = updateAppendTotal;
|
||||
document.getElementById("apLimit").oninput = updateAppendTotal;
|
||||
updateAppendTotal();
|
||||
}
|
||||
|
||||
function _buildAppendFieldRow(fid, fieldName, defaultPattern, isNew) {
|
||||
return `<div class="ap-field-row" data-field="${fieldName}" data-fid="${fid}" style="display:flex;flex-wrap:wrap;gap:6px;align-items:end;padding:6px 0;border-bottom:1px solid var(--border)">
|
||||
<span style="min-width:90px;font-weight:600;font-size:11px;color:var(--accent);font-family:'JetBrains Mono',monospace;align-self:center">${isNew ? `<input class="input input-sm ap-f-name" value="${fieldName}" placeholder="field_name" style="width:80px;font-weight:600;color:var(--accent)">` : fieldName}</span>
|
||||
<input class="input input-sm ap-f-pattern" name="pattern_${fieldName}" value="${defaultPattern}" style="flex:1;min-width:120px" placeholder="Pattern or value...">
|
||||
<input class="input input-sm ap-f-start" name="start_${fieldName}" type="number" value="1" style="width:55px;text-align:center">
|
||||
<select class="input input-sm ap-f-dist" style="width:90px" onchange="toggleApFieldDist(this)">
|
||||
<option value="static">Static</option>
|
||||
<option value="random">Random %</option>
|
||||
<option value="cyclic">Cyclic</option>
|
||||
</select>
|
||||
<button class="btn-icon btn-sm" onclick="this.closest('.ap-field-row').remove()" title="Remove"><i class="fa-solid fa-times" style="color:var(--danger)"></i></button>
|
||||
<div class="ap-f-dist-wrap" style="display:none;width:100%;padding:6px 8px;background:var(--bg-input);border-radius:6px;margin-top:2px">
|
||||
<div class="ap-f-random-opts" style="display:none">
|
||||
<div style="display:grid;grid-template-columns:1fr 55px 1fr;gap:6px;align-items:end">
|
||||
<div><label class="label-sm">Primary</label><input class="input input-sm ap-f-rand-prim" value="free" placeholder="e.g. free"></div>
|
||||
<div><label class="label-sm">%</label><input class="input input-sm ap-f-rand-pct" type="number" value="70" style="text-align:center"></div>
|
||||
<div><label class="label-sm">Secondary</label><input class="input input-sm ap-f-rand-sec" value="paid" placeholder="e.g. paid"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ap-f-cyclic-opts" style="display:none">
|
||||
<label class="label-sm">Cyclic Pattern (comma-separated)</label>
|
||||
<input class="input input-sm ap-f-cyclic-pat" placeholder="free, free, paid" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function addAppendField() {
|
||||
_apFieldCounter++;
|
||||
const fid = _apFieldCounter;
|
||||
const container = document.getElementById("apFieldsContainer");
|
||||
const tmp = document.createElement("div");
|
||||
tmp.innerHTML = _buildAppendFieldRow(fid, "new_field", "", true);
|
||||
container.appendChild(tmp.firstElementChild);
|
||||
// Focus the name input
|
||||
const nameInp = container.lastElementChild.querySelector(".ap-f-name");
|
||||
if (nameInp) { nameInp.value = ""; nameInp.focus(); }
|
||||
}
|
||||
|
||||
function toggleApFieldDist(sel) {
|
||||
const row = sel.closest(".ap-field-row");
|
||||
const mode = sel.value;
|
||||
const wrap = row.querySelector(".ap-f-dist-wrap");
|
||||
const randomOpts = row.querySelector(".ap-f-random-opts");
|
||||
const cyclicOpts = row.querySelector(".ap-f-cyclic-opts");
|
||||
const patternInput = row.querySelector(".ap-f-pattern");
|
||||
|
||||
if (mode === "static") {
|
||||
wrap.style.display = "none";
|
||||
patternInput.disabled = false;
|
||||
patternInput.style.opacity = "1";
|
||||
} else {
|
||||
wrap.style.display = "block";
|
||||
randomOpts.style.display = mode === "random" ? "block" : "none";
|
||||
cyclicOpts.style.display = mode === "cyclic" ? "block" : "none";
|
||||
patternInput.disabled = true;
|
||||
patternInput.style.opacity = "0.4";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAllTargets(checked) {
|
||||
document.querySelectorAll(".ap-target").forEach(cb => cb.checked = checked);
|
||||
}
|
||||
|
||||
async function doPreviewAppend(path) {
|
||||
const fd = new FormData();
|
||||
const cf = document.getElementById("apDataFile").files[0];
|
||||
if (cf) fd.append("data_file", cf);
|
||||
|
||||
const mc = parseInt(document.getElementById("apManualCount").value || 10);
|
||||
const lim = parseInt(document.getElementById("apLimit").value || 0);
|
||||
fd.append("manual_count", mc);
|
||||
fd.append("limit_count", lim > 0 ? Math.min(mc, lim) : mc);
|
||||
|
||||
// Collect field order, patterns, starts, and per-field distributions
|
||||
const fieldRows = document.querySelectorAll("#apFieldsContainer .ap-field-row");
|
||||
const fieldOrder = [];
|
||||
const fieldDistributions = {};
|
||||
|
||||
fieldRows.forEach(row => {
|
||||
const nameEl = row.querySelector(".ap-f-name");
|
||||
const fieldName = nameEl ? nameEl.value.trim() : row.dataset.field;
|
||||
if (!fieldName) return;
|
||||
|
||||
// Update name attributes on dynamic fields
|
||||
const patInput = row.querySelector(".ap-f-pattern");
|
||||
const startInput = row.querySelector(".ap-f-start");
|
||||
if (patInput) patInput.name = `pattern_${fieldName}`;
|
||||
if (startInput) startInput.name = `start_${fieldName}`;
|
||||
|
||||
fieldOrder.push(fieldName);
|
||||
fd.append(`pattern_${fieldName}`, patInput ? patInput.value : "");
|
||||
fd.append(`start_${fieldName}`, startInput ? startInput.value : "1");
|
||||
|
||||
const distMode = row.querySelector(".ap-f-dist").value;
|
||||
if (distMode !== "static") {
|
||||
const distEntry = { mode: distMode };
|
||||
if (distMode === "random") {
|
||||
distEntry.rand_primary = row.querySelector(".ap-f-rand-prim").value;
|
||||
distEntry.rand_secondary = row.querySelector(".ap-f-rand-sec").value;
|
||||
distEntry.rand_pct = parseInt(row.querySelector(".ap-f-rand-pct").value || 50);
|
||||
} else if (distMode === "cyclic") {
|
||||
distEntry.pattern = row.querySelector(".ap-f-cyclic-pat").value;
|
||||
}
|
||||
fieldDistributions[fieldName] = distEntry;
|
||||
}
|
||||
});
|
||||
|
||||
fd.append("field_order", fieldOrder.join(","));
|
||||
fd.append("field_distributions", JSON.stringify(fieldDistributions));
|
||||
|
||||
// No longer need legacy dist fields — per-field handles it all
|
||||
fd.append("dist_field", "");
|
||||
fd.append("dist_mode", "static");
|
||||
|
||||
const r = await api("/preview_append", fd, true);
|
||||
if (r.success) {
|
||||
previewData = r.preview;
|
||||
document.getElementById("apPreviewWrap").style.display = "block";
|
||||
document.getElementById("apPreviewJSON").textContent = JSON.stringify(r.preview.slice(0, 5), null, 2) + (r.total_count > 5 ? "\n..." : "");
|
||||
document.getElementById("apPreviewCount").textContent = r.total_count;
|
||||
if (r.file_lines) document.getElementById("apFileStatus").textContent = r.file_lines + " lines loaded";
|
||||
} else toast(r.error, "error");
|
||||
}
|
||||
|
||||
async function doCommitAppend(path) {
|
||||
const targets = [];
|
||||
document.querySelectorAll(".ap-target:checked").forEach(cb => targets.push(cb.value));
|
||||
if (targets.length === 0) targets.push(path);
|
||||
|
||||
const r = await api("/commit_append", { path, target_paths: targets, items: previewData });
|
||||
if (r.success) {
|
||||
toast(`Appended ${r.count} items to ${r.targets} target(s)!`);
|
||||
refreshTree(r.tree);
|
||||
loadNode(path);
|
||||
const ac = document.getElementById("appendCard");
|
||||
if (ac) ac.remove();
|
||||
} else toast(r.error, "error");
|
||||
}
|
||||
|
||||
// ── Raw Editor ──
|
||||
async function toggleRawEditor() {
|
||||
rawMode = !rawMode;
|
||||
if (rawMode) {
|
||||
const r = await fetch("/raw/get").then(r => r.json());
|
||||
document.getElementById("rawTextarea").value = r.raw;
|
||||
document.getElementById("rawEditorArea").classList.remove("d-none");
|
||||
document.getElementById("editorArea").classList.add("d-none");
|
||||
document.getElementById("emptyState").style.display = "none";
|
||||
} else {
|
||||
const r = await api("/raw/set", { content: document.getElementById("rawTextarea").value });
|
||||
if (r.success) { refreshTree(r.tree); toast("JSON updated"); }
|
||||
else { toast(r.error, "error"); return; }
|
||||
document.getElementById("rawEditorArea").classList.add("d-none");
|
||||
document.getElementById("editorArea").classList.remove("d-none");
|
||||
if (currentPath) loadNode(currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Search ──
|
||||
let searchTimeout;
|
||||
function handleSearch(q) {
|
||||
clearTimeout(searchTimeout);
|
||||
if (!q.trim()) { renderTree(treeData); return; }
|
||||
searchTimeout = setTimeout(async () => {
|
||||
const r = await api("/search", { query: q });
|
||||
if (r.results && r.results.length) {
|
||||
const area = document.getElementById("editorArea");
|
||||
area.classList.remove("d-none");
|
||||
document.getElementById("emptyState").style.display = "none";
|
||||
let html = `<div class="card slide-up"><div class="card-header"><span class="card-title"><i class="fa-solid fa-search"></i> ${r.results.length} results</span></div>`;
|
||||
r.results.forEach(res => {
|
||||
html += `<div class="field-row" style="cursor:pointer" onclick="loadNode('${res.path.split("/").slice(0, -1).join("/")}')">
|
||||
<span class="field-type-badge type-${res.match_type === "key" ? "string" : "number"}">${res.match_type}</span>
|
||||
<span style="font-weight:600;font-size:11px;color:var(--accent);font-family:'JetBrains Mono',monospace">${res.path}</span>
|
||||
<span style="flex:1;font-size:11px;color:var(--text-muted)">${res.preview}</span></div>`;
|
||||
});
|
||||
html += "</div>";
|
||||
area.innerHTML = html;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// ── Modal System ──
|
||||
function showModal(title, bodyHtml, onConfirm) {
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "modal-overlay";
|
||||
overlay.innerHTML = `<div class="modal-box"><h3><i class="fa-solid fa-pen-to-square" style="color:var(--accent)"></i> ${title}</h3><div id="mdBody">${bodyHtml}</div>
|
||||
<div class="modal-actions"><button class="btn btn-ghost" id="mdCancel">Cancel</button><button class="btn btn-primary" id="mdConfirm">Confirm</button></div></div>`;
|
||||
document.body.appendChild(overlay);
|
||||
overlay.querySelector("#mdCancel").onclick = () => overlay.remove();
|
||||
overlay.querySelector("#mdConfirm").onclick = async () => { await onConfirm(); overlay.remove(); };
|
||||
overlay.addEventListener("click", e => { if (e.target === overlay) overlay.remove(); });
|
||||
setTimeout(() => { const inp = overlay.querySelector("input:not([type=hidden]):not([type=checkbox])"); if (inp) inp.focus(); }, 50);
|
||||
}
|
||||
|
||||
function renameFieldInline(el, path, key) {
|
||||
const orig = el.textContent;
|
||||
el.contentEditable = true; el.focus();
|
||||
const sel = window.getSelection(); sel.selectAllChildren(el);
|
||||
el.onblur = async () => {
|
||||
el.contentEditable = false;
|
||||
if (el.textContent !== orig) {
|
||||
const r = await api("/node/rename", { path: path + "/" + key, new_name: el.textContent });
|
||||
if (r.success) { refreshTree(r.tree); loadNode(path); toast("Renamed"); }
|
||||
else { el.textContent = orig; toast(r.error, "error"); }
|
||||
}
|
||||
};
|
||||
el.onkeydown = e => { if (e.key === "Enter") { e.preventDefault(); el.blur(); } if (e.key === "Escape") { el.textContent = orig; el.blur(); } };
|
||||
}
|
||||
|
||||
// ── Keyboard Shortcuts ──
|
||||
document.addEventListener("keydown", e => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "z") { e.preventDefault(); doUndo(); }
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "y") { e.preventDefault(); doRedo(); }
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "s") { e.preventDefault(); saveSession(); }
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "f") { e.preventDefault(); document.getElementById("searchInput").focus(); }
|
||||
});
|
||||
@@ -0,0 +1,801 @@
|
||||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap");
|
||||
|
||||
:root {
|
||||
--bg-primary: #0a0e1a;
|
||||
--bg-secondary: #111827;
|
||||
--bg-tertiary: #1a2236;
|
||||
--bg-card: #151d2e;
|
||||
--bg-card-hover: #1c2740;
|
||||
--bg-input: #0d1220;
|
||||
--bg-elevated: #1e293b;
|
||||
--accent: #6366f1;
|
||||
--accent-hover: #4f46e5;
|
||||
--accent-glow: rgba(99, 102, 241, 0.25);
|
||||
--accent-subtle: rgba(99, 102, 241, 0.08);
|
||||
--accent2: #8b5cf6;
|
||||
--accent2-glow: rgba(139, 92, 246, 0.2);
|
||||
--success: #10b981;
|
||||
--success-glow: rgba(16, 185, 129, 0.2);
|
||||
--warning: #f59e0b;
|
||||
--warning-glow: rgba(245, 158, 11, 0.15);
|
||||
--danger: #ef4444;
|
||||
--danger-glow: rgba(239, 68, 68, 0.15);
|
||||
--info: #06b6d4;
|
||||
--info-glow: rgba(6, 182, 212, 0.15);
|
||||
--pink: #ec4899;
|
||||
--orange: #fb923c;
|
||||
--text-primary: #f1f5f9;
|
||||
--text-secondary: #94a3b8;
|
||||
--text-muted: #64748b;
|
||||
--text-dim: #475569;
|
||||
--border: #1e293b;
|
||||
--border-light: #334155;
|
||||
--border-focus: #6366f1;
|
||||
--glass: rgba(21, 29, 46, 0.85);
|
||||
--glass-border: rgba(148, 163, 184, 0.08);
|
||||
--radius: 12px;
|
||||
--radius-sm: 8px;
|
||||
--radius-xs: 6px;
|
||||
--radius-pill: 100px;
|
||||
--shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
--shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
|
||||
--shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
|
||||
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--transition-fast: all 0.15s ease;
|
||||
}
|
||||
|
||||
*, *::before, *::after {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Inter", -apple-system, sans-serif;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* Scrollbar */
|
||||
::-webkit-scrollbar { width: 5px; height: 5px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
|
||||
::selection { background: var(--accent); color: white; }
|
||||
|
||||
/* === LAYOUT === */
|
||||
.app-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 272px 1fr;
|
||||
grid-template-rows: 1fr;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* === SIDEBAR === */
|
||||
.sidebar {
|
||||
background: var(--bg-secondary);
|
||||
border-right: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.sidebar-header {
|
||||
padding: 14px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.sidebar-logo {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
color: white;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 8px var(--accent-glow);
|
||||
}
|
||||
.sidebar-header h1 {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.3px;
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
.sidebar-actions {
|
||||
padding: 8px 10px;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.sidebar-search {
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
position: relative;
|
||||
}
|
||||
.sidebar-search i {
|
||||
position: absolute;
|
||||
left: 18px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--text-dim);
|
||||
font-size: 11px;
|
||||
pointer-events: none;
|
||||
}
|
||||
.sidebar-search input {
|
||||
width: 100%;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xs);
|
||||
padding: 7px 10px 7px 30px;
|
||||
color: var(--text-primary);
|
||||
font-size: 12px;
|
||||
outline: none;
|
||||
transition: var(--transition);
|
||||
font-family: inherit;
|
||||
}
|
||||
.sidebar-search input:focus {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-glow);
|
||||
}
|
||||
.sidebar-search input::placeholder { color: var(--text-dim); }
|
||||
|
||||
/* Tree */
|
||||
.tree-container { flex: 1; overflow-y: auto; padding: 6px; }
|
||||
.tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 5px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
transition: var(--transition-fast);
|
||||
gap: 7px;
|
||||
user-select: none;
|
||||
}
|
||||
.tree-node:hover { background: var(--bg-card-hover); color: var(--text-primary); }
|
||||
.tree-node.active {
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
||||
color: white;
|
||||
box-shadow: 0 2px 8px var(--accent-glow);
|
||||
}
|
||||
.tree-node .node-icon { font-size: 11px; width: 14px; text-align: center; flex-shrink: 0; }
|
||||
.tree-node .node-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
|
||||
.tree-node .node-badge {
|
||||
font-size: 9px;
|
||||
background: rgba(255,255,255,0.07);
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--radius-pill);
|
||||
color: var(--text-dim);
|
||||
font-weight: 600;
|
||||
}
|
||||
.tree-node.active .node-badge { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.9); }
|
||||
.tree-children { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 2px; }
|
||||
.tree-children.collapsed { display: none; }
|
||||
.tree-toggle { font-size: 9px; width: 14px; text-align: center; transition: transform 0.2s; cursor: pointer; color: var(--text-dim); }
|
||||
.tree-toggle.open { transform: rotate(90deg); }
|
||||
|
||||
/* === MAIN CONTENT === */
|
||||
.main-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
/* Top Bar */
|
||||
.top-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--bg-secondary);
|
||||
min-height: 46px;
|
||||
gap: 12px;
|
||||
}
|
||||
.breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
.breadcrumb span { cursor: pointer; transition: var(--transition-fast); }
|
||||
.breadcrumb span:hover { color: var(--accent); }
|
||||
.breadcrumb .sep { color: var(--text-dim); font-size: 10px; }
|
||||
.top-actions { display: flex; gap: 5px; align-items: center; }
|
||||
|
||||
/* Content Area */
|
||||
.content-area { flex: 1; overflow-y: auto; padding: 20px; }
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
color: var(--text-dim);
|
||||
gap: 14px;
|
||||
}
|
||||
.empty-state i { font-size: 52px; opacity: 0.15; }
|
||||
.empty-state p { font-size: 14px; color: var(--text-muted); }
|
||||
|
||||
/* === BUTTONS === */
|
||||
.btn {
|
||||
padding: 6px 14px;
|
||||
border-radius: var(--radius-xs);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: var(--transition);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: inherit;
|
||||
letter-spacing: 0.01em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
||||
color: white;
|
||||
box-shadow: 0 2px 8px var(--accent-glow);
|
||||
}
|
||||
.btn-primary:hover { filter: brightness(1.15); box-shadow: 0 4px 16px var(--accent-glow); transform: translateY(-1px); }
|
||||
.btn-success { background: var(--success); color: white; }
|
||||
.btn-success:hover { filter: brightness(1.15); box-shadow: 0 2px 12px var(--success-glow); }
|
||||
.btn-danger { background: var(--danger); color: white; }
|
||||
.btn-danger:hover { filter: brightness(1.1); }
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border-light);
|
||||
}
|
||||
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-dim); }
|
||||
.btn-sm { padding: 4px 10px; font-size: 11px; }
|
||||
.btn-xs { padding: 3px 8px; font-size: 10px; }
|
||||
.btn-icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: var(--radius-xs);
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
}
|
||||
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-light); }
|
||||
|
||||
/* === CARDS === */
|
||||
.card {
|
||||
background: var(--glass);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--radius);
|
||||
padding: 16px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
animation: fadeIn 0.2s ease;
|
||||
}
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 14px;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.card-title {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.8px;
|
||||
color: var(--text-muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.card-title i { color: var(--accent); }
|
||||
|
||||
/* === DATA TABLE === */
|
||||
.data-table-wrap {
|
||||
overflow: auto;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
.data-table th {
|
||||
background: var(--bg-tertiary);
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-size: 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
.data-table td {
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text-secondary);
|
||||
max-width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 11px;
|
||||
}
|
||||
.data-table tr:hover td { background: var(--bg-card-hover); color: var(--text-primary); }
|
||||
.data-table .row-actions { display: flex; gap: 4px; opacity: 0; transition: var(--transition-fast); }
|
||||
.data-table tr:hover .row-actions { opacity: 1; }
|
||||
.cell-editable { cursor: pointer; border-radius: 3px; }
|
||||
.cell-editable:hover { background: var(--accent-subtle); outline: 1px solid var(--accent); }
|
||||
.row-idx { color: var(--text-dim); font-size: 10px; width: 36px; text-align: center; font-family: "JetBrains Mono", monospace; }
|
||||
|
||||
/* === FIELD ROW (Object Editor) === */
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.field-row:last-child { border-bottom: none; }
|
||||
.field-key {
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
min-width: 120px;
|
||||
cursor: pointer;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
}
|
||||
.field-value { flex: 1; }
|
||||
.field-type-badge {
|
||||
font-size: 9px;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-pill);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.3px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.type-string { background: rgba(16, 185, 129, 0.1); color: var(--success); }
|
||||
.type-number { background: rgba(99, 102, 241, 0.1); color: var(--accent); }
|
||||
.type-boolean { background: var(--warning-glow); color: var(--warning); }
|
||||
.type-null { background: rgba(100, 116, 139, 0.1); color: var(--text-dim); }
|
||||
.type-object { background: var(--accent2-glow); color: var(--accent2); }
|
||||
.type-array { background: var(--info-glow); color: var(--info); }
|
||||
.type-url { background: rgba(236, 72, 153, 0.1); color: var(--pink); }
|
||||
.type-coordinate { background: rgba(251, 146, 60, 0.1); color: var(--orange); }
|
||||
.type-color { background: rgba(139, 92, 246, 0.1); color: var(--accent2); }
|
||||
|
||||
/* === INPUTS === */
|
||||
.input {
|
||||
width: 100%;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xs);
|
||||
padding: 8px 12px;
|
||||
color: var(--text-primary);
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
transition: var(--transition);
|
||||
}
|
||||
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
|
||||
.input::placeholder { color: var(--text-dim); }
|
||||
.input-sm { padding: 5px 8px; font-size: 11px; }
|
||||
select.input { cursor: pointer; appearance: auto; }
|
||||
textarea.input {
|
||||
resize: vertical;
|
||||
min-height: 60px;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* === TOGGLE SWITCH === */
|
||||
.toggle-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 38px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.toggle-switch input { opacity: 0; width: 0; height: 0; }
|
||||
.toggle-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
inset: 0;
|
||||
background: var(--border-light);
|
||||
border-radius: var(--radius-pill);
|
||||
transition: var(--transition);
|
||||
}
|
||||
.toggle-slider::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background: var(--text-muted);
|
||||
border-radius: 50%;
|
||||
transition: var(--transition);
|
||||
}
|
||||
.toggle-switch input:checked + .toggle-slider {
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent2));
|
||||
box-shadow: 0 0 8px var(--accent-glow);
|
||||
}
|
||||
.toggle-switch input:checked + .toggle-slider::before {
|
||||
transform: translateX(18px);
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* === CONTEXT MENU === */
|
||||
.ctx-menu {
|
||||
position: fixed;
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border-light);
|
||||
border-radius: var(--radius);
|
||||
padding: 4px;
|
||||
box-shadow: var(--shadow);
|
||||
z-index: 9999;
|
||||
min-width: 190px;
|
||||
animation: scaleIn 0.12s ease;
|
||||
}
|
||||
.ctx-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 7px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
border-radius: var(--radius-xs);
|
||||
transition: var(--transition-fast);
|
||||
font-weight: 500;
|
||||
}
|
||||
.ctx-item:hover { background: var(--accent); color: white; }
|
||||
.ctx-item i { width: 16px; text-align: center; font-size: 11px; }
|
||||
.ctx-sep { height: 1px; background: var(--border); margin: 3px 8px; }
|
||||
.ctx-item.danger { color: var(--danger); }
|
||||
.ctx-item.danger:hover { background: var(--danger); color: white; }
|
||||
|
||||
/* === TOAST === */
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 99999;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.toast {
|
||||
padding: 10px 18px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
box-shadow: var(--shadow);
|
||||
animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 240px;
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
|
||||
.toast-error { background: linear-gradient(135deg, #dc2626, #ef4444); }
|
||||
.toast-info { background: linear-gradient(135deg, #4f46e5, #6366f1); }
|
||||
|
||||
/* === MODAL === */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
backdrop-filter: blur(6px);
|
||||
z-index: 9998;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: fadeIn 0.15s ease;
|
||||
}
|
||||
.modal-box {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-light);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
width: 620px;
|
||||
max-width: 94vw;
|
||||
max-height: 85vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: var(--shadow);
|
||||
animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
.modal-box h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-top: 18px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* Wide modal for bulk edit */
|
||||
.modal-box.modal-wide {
|
||||
width: 780px;
|
||||
max-width: 96vw;
|
||||
}
|
||||
|
||||
/* === FIELD CONFIG CARD (per-field toggle in bulk edit) === */
|
||||
.field-config {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 10px 14px;
|
||||
margin-bottom: 8px;
|
||||
transition: var(--transition);
|
||||
}
|
||||
.field-config.active {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 2px var(--accent-glow);
|
||||
background: var(--bg-card-hover);
|
||||
}
|
||||
.field-config-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.field-config-header .field-name {
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
flex: 1;
|
||||
}
|
||||
.field-config-header .field-badge {
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--accent-subtle);
|
||||
color: var(--accent);
|
||||
}
|
||||
.field-config-body {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: none;
|
||||
}
|
||||
.field-config.active .field-config-body { display: block; }
|
||||
|
||||
/* === APPEND PANEL === */
|
||||
.append-panel {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 14px;
|
||||
}
|
||||
.append-panel .full-width { grid-column: 1/-1; }
|
||||
.preview-box {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 12px;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
.preview-box pre {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 11px;
|
||||
color: var(--info);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* === CATEGORY TREE PICKER === */
|
||||
.cat-tree { max-height: 280px; overflow-y: auto; }
|
||||
.cat-tree-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 5px 8px;
|
||||
border-radius: var(--radius-xs);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
color: var(--text-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.cat-tree-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
|
||||
.cat-tree-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
|
||||
.cat-tree-item .cat-count {
|
||||
font-size: 10px;
|
||||
color: var(--text-dim);
|
||||
background: var(--bg-tertiary);
|
||||
padding: 1px 7px;
|
||||
border-radius: var(--radius-pill);
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-weight: 600;
|
||||
}
|
||||
.cat-tree-children { margin-left: 20px; }
|
||||
|
||||
/* === STATUS BAR === */
|
||||
.status-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 5px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
background: var(--bg-secondary);
|
||||
font-size: 10px;
|
||||
color: var(--text-dim);
|
||||
font-weight: 500;
|
||||
}
|
||||
.status-bar .status-left,
|
||||
.status-bar .status-right { display: flex; align-items: center; gap: 12px; }
|
||||
|
||||
/* === TABS === */
|
||||
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 16px; }
|
||||
.tab {
|
||||
padding: 8px 16px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
transition: var(--transition);
|
||||
}
|
||||
.tab:hover { color: var(--text-primary); }
|
||||
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
|
||||
|
||||
/* === LABEL === */
|
||||
.label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.label-sm { font-size: 10px; margin-bottom: 3px; text-transform: none; letter-spacing: 0; }
|
||||
|
||||
/* === SECTION TITLE IN PANELS === */
|
||||
.section-title {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.8px;
|
||||
color: var(--text-dim);
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.section-title i { color: var(--accent); font-size: 10px; }
|
||||
|
||||
/* === CHIP / TAG === */
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 11px;
|
||||
padding: 3px 10px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border);
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
font-weight: 500;
|
||||
}
|
||||
.chip:hover { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
|
||||
|
||||
/* === ANIMATIONS === */
|
||||
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(100px); opacity: 0; }
|
||||
to { transform: translateX(0); opacity: 1; }
|
||||
}
|
||||
@keyframes slideUp {
|
||||
from { transform: translateY(12px); opacity: 0; }
|
||||
to { transform: translateY(0); opacity: 1; }
|
||||
}
|
||||
@keyframes fadeOut { to { opacity: 0; transform: translateX(60px); } }
|
||||
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
||||
|
||||
.fade-in { animation: fadeIn 0.2s ease; }
|
||||
.slide-up { animation: slideUp 0.25s ease; }
|
||||
.d-none { display: none !important; }
|
||||
|
||||
/* === HELPER === */
|
||||
.text-accent { color: var(--accent); }
|
||||
.text-muted { color: var(--text-muted); }
|
||||
.text-success { color: var(--success); }
|
||||
.text-warning { color: var(--warning); }
|
||||
.text-danger { color: var(--danger); }
|
||||
.text-info { color: var(--info); }
|
||||
.text-pink { color: var(--pink); }
|
||||
.text-orange { color: var(--orange); }
|
||||
.text-primary { color: var(--text-primary); }
|
||||
.gap-sm { gap: 6px; }
|
||||
.gap-md { gap: 10px; }
|
||||
.mt-sm { margin-top: 6px; }
|
||||
.mt-md { margin-top: 12px; }
|
||||
.mb-sm { margin-bottom: 6px; }
|
||||
.flex { display: flex; }
|
||||
.flex-1 { flex: 1; }
|
||||
.items-center { align-items: center; }
|
||||
.justify-between { justify-content: space-between; }
|
||||
.flex-wrap { flex-wrap: wrap; }
|
||||
.font-mono { font-family: "JetBrains Mono", monospace; }
|
||||
|
||||
/* === SAVE BUTTON & DIRTY INDICATOR === */
|
||||
.btn-save {
|
||||
background: linear-gradient(135deg, #3b82f6, #2563eb);
|
||||
color: #fff;
|
||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
||||
font-weight: 600;
|
||||
}
|
||||
.btn-save:hover {
|
||||
background: linear-gradient(135deg, #2563eb, #1d4ed8);
|
||||
box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
.dirty-dot {
|
||||
color: var(--warning);
|
||||
font-size: 16px;
|
||||
margin-left: 6px;
|
||||
animation: pulse-dot 1.5s ease-in-out infinite;
|
||||
}
|
||||
@keyframes pulse-dot {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.3; }
|
||||
}
|
||||
|
||||
/* === MULTI-CAT GROUPS === */
|
||||
.mc-cat-group, .ap-cat-group { padding-left: 0; }
|
||||
|
||||
/* === TYPE BADGES EXTRA === */
|
||||
.type-coordinate { background: rgba(251, 146, 60, 0.12); color: var(--orange); }
|
||||
.type-url { background: rgba(236, 72, 153, 0.12); color: var(--pink); }
|
||||
.type-unknown { background: rgba(100, 116, 139, 0.12); color: var(--text-muted); }
|
||||
|
||||
/* === SCHEMA SUMMARY === */
|
||||
#schemaSummary {
|
||||
border-top: 1px solid var(--border);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user