-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
377 lines (349 loc) · 20.9 KB
/
Copy pathindex.html
File metadata and controls
377 lines (349 loc) · 20.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TabSQL</title>
<link rel="shortcut icon" href="icons/icon_256.png" type="image/png">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #002b36;
--surface: #073642;
--border: #586e75;
--accent: #268bd2;
--text: #839496;
--muted: #586e75;
--hover: #0d3843;
--win-icon: #b58900;
--tab-icon: #2aa198;
--note-icon:#859900;
--search-hl:#2d2400;
--red: #dc322f;
--dup-url: #dc322f;
--saved-tab:#859900;
--focus-bg: #003d4f;
--indent: 16px;
--row-h: 28px;
}
body { background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, sans-serif;
overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
#toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#search { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
color: var(--text); padding: 3px 8px; font-size: 12px; }
#search:focus { outline: none; border-color: var(--accent); }
.btn { background: var(--hover); border: 1px solid var(--border); color: var(--text);
border-radius: 4px; padding: 3px 8px; cursor: pointer; font-size: 11px; white-space: nowrap; }
.btn:hover { background: var(--border); }
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#tree-area { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }
#tree { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0; min-height: 0; }
#status { font-size: 11px; color: var(--muted); padding: 3px 8px; background: var(--surface);
border-top: 1px solid var(--border); flex-shrink: 0; }
/* SQL panel */
#sql-panel { height: 300px; display: flex; flex-direction: column; flex-shrink: 0;
border-top: 2px solid var(--accent); background: var(--bg); }
#sql-panel.hidden { display: none; }
#sql-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px;
background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#sql-bar span.label { font-size: 11px; color: var(--accent); font-weight: 600; }
#sql-quick { width: 180px; background: var(--bg); border: 1px solid var(--border); color: var(--text);
border-radius: 4px; padding: 2px 6px; font-size: 11px; }
#sql-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
#sql-input { flex-shrink: 0; background: var(--surface); border: none;
border-bottom: 1px solid var(--border); color: var(--text);
font: 12px/1.4 'JetBrains Mono','Consolas',monospace;
padding: 6px 8px; height: 72px; resize: none; outline: none; }
#sql-results { flex: 1; overflow: auto; font-size: 12px; }
#sql-results table { width: 100%; border-collapse: collapse; }
#sql-results th { background: var(--surface); color: var(--accent); text-align: left;
padding: 4px 8px; position: sticky; top: 0; border-bottom: 1px solid var(--border);
font-size: 11px; }
#sql-results td { padding: 3px 8px; border-bottom: 1px solid var(--surface);
max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sql-results tr:hover td { background: var(--hover); }
.sql-null { color: var(--muted); font-style: italic; }
.node { display: flex; align-items: center; min-height: var(--row-h);
padding: 1px 4px; cursor: pointer; user-select: none; }
.node:hover { background: var(--hover); }
.node.selected { background: #0f4055; }
.toggle { width: 14px; flex-shrink: 0; color: var(--muted); font-size: 10px; text-align: center; }
.icon { width: 16px; flex-shrink: 0; font-size: 12px; margin: 0 3px; }
.dup-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dup-url); margin: 0 3px 0 0; flex-shrink: 0; }
.saved-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--saved-tab); margin: 0 3px 0 0; flex-shrink: 0; }
.pin-indicator { font-size: 10px; flex-shrink: 0; margin: 0 2px 0 0; line-height: 1; }
.label-group { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 3px; overflow: hidden; }
.label { flex: 1 1 100px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label.muted { color: var(--muted); }
.badge { font-size: 10px; color: var(--muted); margin-left: 4px; flex-shrink: 0; }
.favicon { width: 14px; height: 14px; object-fit: contain; margin: 0 3px; flex-shrink: 0; }
.node[data-type="win"] .label { font-weight: 500; color: var(--win-icon); }
.node[data-type="group"] .label { font-weight: 600; color: var(--accent); }
.node[data-type="textnote"] .label { color: var(--note-icon); font-style: italic; }
.node[data-type="split"] { border-top: 1px solid var(--border); margin: 2px 0; height: 1px; }
.node.open-tab .label { color: var(--tab-icon); }
.node.focus-active { background: var(--focus-bg); }
.node.focus-active:hover { background: var(--focus-bg); filter: brightness(1.15); }
.node.collapsed > .children { display: none; }
.children { /* indented by JS via padding-left on child nodes */ }
/* Action buttons (save/delete) — shown on hover */
.actions { display: none; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0; }
.node:hover .actions { display: flex; }
.act { background: none; border: none; cursor: pointer; color: var(--muted);
font-size: 11px; padding: 1px 4px; border-radius: 2px; line-height: 1; }
.act:hover { color: var(--text); background: var(--border); }
.act-del:hover { color: var(--red); }
.act-save:hover { color: var(--accent); }
/* Drag & drop */
.node.dragging { opacity: .35; }
.node.drag-over { outline: 1px solid var(--accent); background: rgba(38,139,210,.15); }
/* Context menu */
#ctx { position: fixed; background: var(--surface); border: 1px solid var(--border);
border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.5); z-index: 999;
min-width: 160px; padding: 4px 0; }
#ctx.hidden { display: none; }
.ctx-item { padding: 6px 14px; cursor: pointer; font-size: 12px; }
.ctx-item:hover { background: var(--hover); }
.ctx-sep { border-top: 1px solid var(--border); margin: 3px 0; }
mark.search-hl { background: var(--search-hl); color: inherit; border-radius: 2px; padding: 0 1px; }
/* Note rows */
.note-row { display: flex; align-items: center; font-size: 11px; color: var(--muted); min-height: 18px; }
.note-row.empty { display: none; }
.note-bar { color: var(--border); margin-right: 5px; font-size: 14px; line-height: 1;
flex-shrink: 0; user-select: none; }
.note-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.note-input { flex: 1; background: var(--surface); border: 1px solid var(--accent); color: var(--text);
border-radius: 3px; padding: 1px 6px; font-size: 11px; min-width: 0; outline: none; }
/* Resize handle */
#sql-resize { height: 5px; background: var(--border); cursor: row-resize; flex-shrink: 0; }
#sql-resize:hover, #sql-resize.dragging { background: var(--accent); opacity: .8; }
/* Tag chips */
.tag-chips { display: flex; gap: 3px; flex-shrink: 0; align-items: center; }
.tag-chip { font-size: 9px; padding: 1px 5px; border-radius: 8px; color: var(--text); white-space: nowrap;
opacity: .9; font-weight: 600; flex-shrink: 0; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
/* Tag picker overlay */
#tag-picker { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--border);
border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.5); min-width: 200px; padding: 6px; }
#tag-picker.hidden { display: none; }
.tag-picker-hdr { font-size: 11px; color: var(--accent); font-weight: 600; padding: 2px 4px 6px; }
.tag-picker-list { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.tag-pick-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 3px; cursor: pointer; }
.tag-pick-row:hover { background: var(--hover); }
.tag-pick-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tag-pick-name { flex: 1; font-size: 12px; }
.tag-pick-check { font-size: 11px; color: var(--accent); width: 14px; text-align: right; }
.tag-picker-sep { border-top: 1px solid var(--border); margin: 4px 0; }
.tag-picker-new { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.tag-picker-new input[type=text] { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
border-radius: 3px; padding: 2px 6px; font-size: 11px; outline: none; min-width: 0; }
.tag-picker-new input[type=text]:focus { border-color: var(--accent); }
.tag-picker-new input[type=color] { width: 24px; height: 20px; border: 1px solid var(--border); border-radius: 2px;
cursor: pointer; padding: 1px; background: none; flex-shrink: 0; }
.tag-win-auto { font-size: 10px; color: var(--muted); padding: 2px 4px; display: flex; align-items: center; gap: 4px; }
.tag-win-auto input[type=checkbox] { cursor: pointer; }
/* Config panel */
#config-panel { background: var(--surface); border-bottom: 2px solid var(--accent); overflow-y: auto; max-height: 55vh; flex-shrink: 0; }
#config-panel.hidden { display: none; }
.cfg-section { border-bottom: 1px solid var(--border); }
.cfg-section:last-child { border-bottom: none; }
.cfg-hdr { display: flex; align-items: center; gap: 6px; padding: 5px 8px; cursor: pointer;
font-size: 11px; font-weight: 600; color: var(--accent); user-select: none; }
.cfg-hdr::before { content: '▼'; font-size: 9px; }
.cfg-hdr.collapsed::before { content: '▶'; }
.cfg-hdr:hover { background: var(--hover); }
.cfg-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.cfg-body.hidden { display: none; }
.cfg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfg-lbl { font-size: 11px; color: var(--muted); }
#cfg-io-status { font-size: 11px; color: var(--muted); }
.cfg-colors-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.cfg-color-row { display: flex; align-items: center; gap: 6px; }
.cfg-color-row label { font-size: 11px; color: var(--text); flex: 1; min-width: 0; }
.cfg-color-row input[type=color] { width: 32px; height: 20px; border: 1px solid var(--border);
border-radius: 3px; cursor: pointer; padding: 1px; background: none; flex-shrink: 0; }
/* Tag management in config */
.tag-list { display: flex; flex-direction: column; gap: 4px; }
.tag-list-row { display: flex; align-items: center; gap: 6px; }
.tag-list-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.tag-list-name { flex: 1; font-size: 12px; }
.tag-list-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px;
padding: 1px 4px; border-radius: 2px; }
.tag-list-del:hover { color: var(--red); background: var(--hover); }
.tag-new-row { display: flex; gap: 4px; align-items: center; }
.tag-new-row input[type=text] { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
border-radius: 3px; padding: 2px 6px; font-size: 11px; outline: none; min-width: 0; }
.tag-new-row input[type=text]:focus { border-color: var(--accent); }
.tag-new-row input[type=color] { width: 28px; height: 22px; border: 1px solid var(--border); border-radius: 2px;
cursor: pointer; padding: 1px; background: none; flex-shrink: 0; }
/* Action rules in config */
.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-row { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; }
.action-row-hdr { display: flex; align-items: center; gap: 6px; }
.action-badge { font-size: 9px; padding: 1px 5px; border-radius: 8px; background: var(--surface); color: var(--muted); }
.action-badge.auto { background: rgba(38,139,210,.2); color: var(--accent); }
.action-row-btns { display: flex; gap: 3px; flex-shrink: 0; }
.action-row-btns button { background: none; border: 1px solid var(--border); color: var(--muted);
border-radius: 3px; cursor: pointer; font-size: 10px; padding: 1px 6px; }
.action-row-btns button:hover { background: var(--hover); color: var(--text); }
.action-name { flex: 1; font-size: 12px; font-weight: 600; min-width: 0;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-badges { display: flex; gap: 3px; flex-shrink: 0; }
.action-editor { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px;
align-items: center; padding: 8px; margin-bottom: 6px;
background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; }
.action-editor-row { display: contents; }
.action-editor label { font-size: 10px; color: var(--muted); text-align: right; white-space: nowrap; }
.action-editor input, .action-editor select, .action-editor textarea {
background: var(--surface); border: 1px solid var(--border); color: var(--text);
border-radius: 3px; padding: 3px 6px; font-size: 11px; outline: none; width: 100%; }
.action-editor input:focus, .action-editor select:focus, .action-editor textarea:focus { border-color: var(--accent); }
.action-editor textarea { height: 48px; resize: vertical; font-family: 'JetBrains Mono','Consolas',monospace; }
.action-editor .ae-inline { font-size: 11px; color: var(--text); text-align: left;
display: flex; align-items: center; gap: 5px; cursor: pointer; }
.action-editor .ae-btns { display: flex; gap: 6px; }
#cfg-actions-status { font-size: 11px; color: var(--muted); }
/* Schema popup */
#schema-popup { position: absolute; inset: 0; z-index: 2000; background: var(--surface);
border: 1px solid var(--border); border-radius: 0; box-shadow: 0 4px 16px rgba(0,0,0,.4);
display: flex; flex-direction: column; overflow: hidden; }
#schema-popup.hidden { display: none; }
#schema-popup-hdr { display: flex; align-items: center; padding: 8px 12px; background: var(--bg);
border-bottom: 1px solid var(--border); flex-shrink: 0; }
#schema-popup-hdr h2 { flex: 1; font-size: 13px; color: var(--accent); margin: 0; }
#schema-popup-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
#schema-popup-close:hover { color: var(--text); }
#schema-popup-body { flex: 1; overflow-y: auto; padding: 12px; font-size: 12px; }
.schema-table { margin-bottom: 16px; }
.schema-table-name { font-weight: 700; color: var(--accent); margin-bottom: 4px; font-size: 12px; }
.schema-cols { border-collapse: collapse; width: 100%; }
.schema-cols th { background: var(--bg); color: var(--muted); text-align: left; padding: 3px 8px; font-size: 10px;
border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.schema-cols td { padding: 2px 8px; border-bottom: 1px solid var(--surface); font-size: 11px; }
.schema-cols tr:hover td { background: var(--hover); }
.schema-pk { color: var(--accent); font-size: 9px; }
</style>
</head>
<body>
<div id="toolbar">
<input id="search" type="search" placeholder="Search… (field:value)" autocomplete="off">
<button class="btn" id="btn-search-window" title="Move results to new window" style="display:none">⬡</button>
<button class="btn" id="btn-save-search" title="Save and close search results" style="display:none">💾</button>
<button class="btn" id="btn-close-search" title="Close search results" style="display:none">✕</button>
<button class="btn" id="btn-tag-search" title="Apply tag to search results" style="display:none">🏷</button>
<button class="btn" id="btn-refresh" title="Reload tree">↺</button>
<button class="btn" id="btn-config" title="Settings">⚙</button>
</div>
<div id="config-panel" class="hidden">
<div class="cfg-section">
<div class="cfg-hdr" data-target="cfg-io-body">Import / Export</div>
<div id="cfg-io-body" class="cfg-body">
<div class="cfg-row">
<label class="cfg-lbl">Format</label>
<select id="cfg-format" class="btn" style="padding:2px 6px">
<option value="taboutliner">TabOutliner (.tree)</option>
<option value="sql">SQL (.sql)</option>
</select>
</div>
<div class="cfg-row">
<button class="btn" id="cfg-import">⬆ Import…</button>
<button class="btn" id="cfg-export">⬇ Export</button>
<input type="file" id="cfg-file-input" style="display:none" accept=".tree,.sql,.txt">
</div>
<div id="cfg-io-status"></div>
</div>
</div>
<div class="cfg-section">
<div class="cfg-hdr" data-target="cfg-colors-body">Colors</div>
<div id="cfg-colors-body" class="cfg-body">
<div id="cfg-colors-grid" class="cfg-colors-grid"></div>
<div class="cfg-row" style="margin-top:4px">
<button class="btn" id="cfg-colors-reset">Reset defaults</button>
</div>
</div>
</div>
<div class="cfg-section">
<div class="cfg-hdr" data-target="cfg-tags-body">Tags</div>
<div id="cfg-tags-body" class="cfg-body hidden">
<div id="cfg-tag-list" class="tag-list"></div>
<div class="tag-new-row">
<input type="text" id="cfg-tag-name" placeholder="New tag name…">
<input type="color" id="cfg-tag-color" value="#7c9ef8">
<button class="btn" id="cfg-tag-add">Add</button>
</div>
</div>
</div>
<div class="cfg-section">
<div class="cfg-hdr" data-target="cfg-actions-body">Actions</div>
<div id="cfg-actions-body" class="cfg-body hidden">
<div id="cfg-action-list" class="action-list"></div>
<div class="cfg-row">
<button class="btn" id="cfg-action-new">+ New action</button>
<button class="btn" id="cfg-action-run-all">▶ Run auto</button>
<span id="cfg-actions-status"></span>
</div>
</div>
</div>
</div>
<div id="main">
<div id="tree-area">
<div id="tree"></div>
<div id="status">Loading…</div>
<div id="schema-popup" class="hidden">
<div id="schema-popup-hdr">
<h2>Database Schema</h2>
<button id="schema-popup-close">✕</button>
</div>
<div id="schema-popup-body"></div>
</div>
</div>
<div id="sql-resize"></div>
<div id="sql-panel">
<div id="sql-bar">
<span class="label">SQL</span>
<select id="sql-quick"><option value="">Saved queries…</option></select>
<button class="btn" id="sql-save-query" title="Save / update query">+</button>
<button class="btn" id="sql-del-query" title="Delete selected query">-</button>
<button class="btn" id="sql-restore-defaults" title="Restore missing defaults">↺</button>
<button class="btn" id="sql-schema" title="Show schema">📋</button>
<div style="margin-left:auto;display:flex;align-items:center;gap:6px">
<button class="btn" id="sql-run">▶ Run</button>
<button class="btn" id="sql-export-csv" title="Export results to CSV">⬇ CSV</button>
<span id="sql-status"></span>
</div>
</div>
<textarea id="sql-input" spellcheck="false"
placeholder="SELECT * FROM node LIMIT 20; -- Ctrl+Enter to run"></textarea>
<div id="sql-results"></div>
</div>
</div>
<div id="ctx" class="hidden">
<div class="ctx-item" data-action="open">Open</div>
<div class="ctx-item" data-action="open-all">Open all tabs</div>
<div class="ctx-sep"></div>
<div class="ctx-item" data-action="copy-url">Copy URL</div>
<div class="ctx-item" data-action="copy-title">Copy title</div>
<div class="ctx-sep"></div>
<div class="ctx-item" data-action="tags">Tags…</div>
<div class="ctx-item" data-action="toggle-saved">Toggle saved</div>
<div class="ctx-sep"></div>
<div class="ctx-item" data-action="delete">Delete</div>
</div>
<div id="tag-picker" class="hidden">
<div class="tag-picker-hdr">Tags</div>
<div id="tag-picker-list" class="tag-picker-list"></div>
<div class="tag-picker-sep"></div>
<div class="tag-picker-new">
<input type="text" id="tag-picker-new-name" placeholder="New tag…">
<input type="color" id="tag-picker-new-color" value="#7c9ef8">
<button class="btn" id="tag-picker-new-add" title="Add">+</button>
</div>
<div id="tag-picker-win-auto" class="tag-win-auto hidden">
<input type="checkbox" id="tag-picker-auto-cb">
<label for="tag-picker-auto-cb">Auto-tag new tabs in this window</label>
</div>
</div>
<script type="module" src="tree.js"></script>
</body>
</html>