-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
614 lines (549 loc) · 24.9 KB
/
index.html
File metadata and controls
614 lines (549 loc) · 24.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SwissMicros Factory Defaults</title>
<link rel="stylesheet" href="https://swissmicros.github.io/swissmicros-factorydefaults/assets/css/style.css?v=2">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--border: #d0d7de;
--panel-bg: #ffffff;
--th-bg: #24292f;
--th-text: #f6f8fa;
--th-hover: #32383f;
--th-active: #79c0ff;
--row-alt: #f6f8fa;
--row-hover: #ddf4ff;
--text: #24292f;
--muted: #57606a;
--link: #0969da;
--link-hover: #0550ae;
--status-bg: #f6f8fa;
--radius: 6px;
--shadow: 0 1px 3px rgba(27,31,36,0.12), 0 1px 2px rgba(27,31,36,0.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
/* ── Directory Panel ─────────────────────────────────────── */
.dir-panel {
background: var(--panel-bg);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
margin-bottom: 2rem;
}
/* ── Breadcrumb bar ──────────────────────────────────────── */
.breadcrumb-bar {
display: flex;
align-items: center;
gap: 0.375rem;
padding: 0.5rem 0.875rem;
background: #f6f8fa;
border-bottom: 1px solid var(--border);
font-family: 'IBM Plex Mono', monospace;
font-size: 0.8rem;
color: var(--muted);
min-height: 34px;
flex-wrap: wrap;
}
.breadcrumb-bar svg { flex-shrink: 0; }
.breadcrumb-bar a { color: var(--link); text-decoration: none; }
.breadcrumb-bar a:hover { text-decoration: underline; }
.breadcrumb-bar strong { color: var(--text); font-weight: 600; }
.bc-sep { color: #bbb; user-select: none; }
/* ── Table wrapper ───────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* ── Directory Table ─────────────────────────────────────── */
.dir-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
/* Head */
.dir-table thead tr { background: var(--th-bg); }
.dir-table thead th {
padding: 0.5rem 0.75rem;
text-align: left;
font-family: 'IBM Plex Sans', sans-serif;
font-weight: 600;
font-size: 0.7rem;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--th-text);
white-space: nowrap;
user-select: none;
}
.dir-table thead th.sortable { cursor: pointer; }
.dir-table thead th.sortable:hover { background: var(--th-hover); }
.dir-table thead th.sort-active { color: var(--th-active); }
.dir-table thead th .sort-arrow { margin-left: 4px; font-size: 0.65rem; opacity: 0.5; }
.dir-table thead th.sort-active .sort-arrow { opacity: 1; }
/* Column widths */
.th-icon { width: 40px; padding-left: 1rem !important; }
.th-name { min-width: 200px; }
.th-size { width: 90px; text-align: right !important; }
.th-type { width: 120px; }
.th-dl { width: 110px; padding-right: 1rem !important; }
/* Body rows */
.dir-table tbody tr {
border-bottom: 1px solid var(--border);
transition: background 0.08s ease;
}
.dir-table tbody tr:last-child { border-bottom: none; }
.dir-table tbody tr:nth-child(even) { background: var(--row-alt); }
.dir-table tbody tr:hover { background: var(--row-hover); }
.dir-table tbody td {
padding: 0.375rem 0.75rem;
vertical-align: middle;
}
.td-icon { padding-left: 1rem !important; width: 40px; }
.td-size {
text-align: right;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.78rem;
color: var(--muted);
}
.td-type { font-size: 0.78rem; color: var(--muted); }
.td-dl { text-align: right; padding-right: 1rem !important; }
/* File name links */
.name-link {
color: var(--link);
text-decoration: none;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.8125rem;
}
.name-link:hover { color: var(--link-hover); text-decoration: underline; }
.parent-link {
display: inline-flex;
align-items: center;
gap: 0.375rem;
color: var(--muted);
text-decoration: none;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.8125rem;
}
.parent-link:hover { color: var(--link); text-decoration: underline; }
/* Download button */
.dl-btn {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.2rem 0.55rem;
background: transparent;
border: 1px solid var(--border);
border-radius: 4px;
color: var(--muted);
font-size: 0.72rem;
font-family: 'IBM Plex Sans', sans-serif;
font-weight: 500;
text-decoration: none;
transition: background 0.12s, border-color 0.12s, color 0.12s;
white-space: nowrap;
}
.dl-btn:hover {
background: var(--link);
border-color: var(--link);
color: #fff;
text-decoration: none;
}
/* Status bar */
.status-bar {
padding: 0.375rem 0.875rem;
background: var(--status-bg);
border-top: 1px solid var(--border);
font-size: 0.75rem;
color: var(--muted);
font-family: 'IBM Plex Sans', sans-serif;
min-height: 30px;
display: flex;
align-items: center;
}
/* Loading / error states */
.state-cell {
text-align: center;
padding: 2.5rem 1rem !important;
color: var(--muted);
font-style: italic;
}
.state-cell.is-error { color: #cf222e; font-style: normal; }
.spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid var(--border);
border-top-color: var(--link);
border-radius: 50%;
animation: spin 0.65s linear infinite;
margin-right: 0.5rem;
vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Responsive: hide Size & Type on small screens */
@media (max-width: 580px) {
.th-size, .th-type,
.dir-table tbody td:nth-child(3),
.dir-table tbody td:nth-child(4) { display: none; }
}
/* BMP hover preview */
#img-preview {
display: none;
position: fixed;
z-index: 9999;
background: #fff;
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: 0 4px 20px rgba(27,31,36,0.22);
padding: 5px;
pointer-events: none;
max-width: 260px;
}
#img-preview img {
display: block;
max-width: 250px;
max-height: 220px;
image-rendering: pixelated;
border-radius: 2px;
}
#img-preview .preview-name {
font-family: 'IBM Plex Mono', monospace;
font-size: 0.65rem;
color: var(--muted);
padding: 3px 2px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
}
</style>
</head>
<body>
<section class="page-header">
<h1 class="project-name">SwissMicros Factory Defaults</h1>
<h2 class="project-tagline">Factory default files for Pioneer & Voyager models</h2>
<a href="https://swissmicros.com" class="btn">Shop</a>
<span class="btn-sep">|</span>
<a href="https://technical.swissmicros.com" class="btn">Documentation</a>
<span class="btn-sep">|</span>
<a href="https://forum.swissmicros.com" class="btn">Community Forum</a>
</section>
<section class="main-content">
<div class="dir-panel">
<!-- Breadcrumb -->
<div class="breadcrumb-bar" id="breadcrumb-bar">
<svg width="14" height="14" viewBox="0 0 16 16" fill="#d4a72c">
<path d="M1.75 2.5h3.5l2 2h6.25c.966 0 1.75.784 1.75 1.75v6.5A1.75 1.75 0 0 1 13.5 14.5H1.75A1.75 1.75 0 0 1 0 12.75V4.25C0 3.284.784 2.5 1.75 2.5z"/>
</svg>
<span id="breadcrumb"><a href="#" data-path="">root</a></span>
</div>
<!-- Table -->
<div class="table-wrapper">
<table class="dir-table">
<thead>
<tr>
<th class="th-icon"></th>
<th class="th-name sortable sort-active" data-col="name">
Name <span class="sort-arrow">↑</span>
</th>
<th class="th-size sortable" data-col="size" style="text-align:right">
Size <span class="sort-arrow">↕</span>
</th>
<th class="th-type sortable" data-col="type">
Type <span class="sort-arrow">↕</span>
</th>
<th class="th-dl"></th>
</tr>
</thead>
<tbody id="dir-body">
<tr>
<td colspan="5" class="state-cell">
<span class="spinner"></span>Loading directory contents…
</td>
</tr>
</tbody>
</table>
</div>
<!-- Status bar -->
<div class="status-bar" id="status-bar"> </div>
</div><!-- /.dir-panel -->
<footer class="site-footer">
<span class="site-footer-owner">
<a href="https://github.com/swissmicros/swissmicros-factorydefaults">SwissMicros Factory Defaults</a>
is maintained by <a href="https://github.com/swissmicros">SwissMicros</a>.
</span>
</footer>
</section>
<div id="img-preview">
<img id="img-preview-img" src="" alt="">
<div class="preview-name" id="img-preview-name"></div>
</div>
<script>
(function () {
'use strict';
/* ── Config ────────────────────────────────────────────────── */
const REPO_OWNER = 'swissmicros';
const REPO_NAME = 'swissmicros-factorydefaults';
const BRANCH = 'main';
const HIDDEN = new Set(['index.html', '_config.yml', 'CNAME', 'README.md', 'instructions.md', 'assets']);
/* ── State ─────────────────────────────────────────────────── */
let currentPath = '';
let currentFiles = [];
let sortCol = 'name';
let sortDir = 'asc';
/* ── SVG icons ─────────────────────────────────────────────── */
const ICON_FOLDER = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path d="M1.75 2.5h3.5l2 2h6.25c.966 0 1.75.784 1.75 1.75v6.5
A1.75 1.75 0 0 1 13.5 14.5H1.75A1.75 1.75 0 0 1 0 12.75
V4.25C0 3.284.784 2.5 1.75 2.5z" fill="#d4a72c"/>
</svg>`;
const ICON_UP = `<svg width="14" height="14" viewBox="0 0 16 16" fill="#57606a">
<path d="M7.78 12.53a.75.75 0 0 1-1.06 0L2.47 8.28a.75.75 0 0 1 0-1.06
l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042
L4.81 7h7.44a.75.75 0 0 1 0 1.5H4.81l2.97 2.97a.75.75 0 0 1 0 1.06z"/>
</svg>`;
const ICON_DL = `<svg width="11" height="11" viewBox="0 0 16 16" fill="currentColor">
<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5
c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0
v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97
a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0
L4.22 6.779a.749.749 0 1 1 1.06-1.06z"/>
</svg>`;
/* ext → stroke colour for document icon */
const EXT_COLOR = {
bin:'#0969da', hex:'#0969da',
raw:'#6e40c9', mod:'#6e40c9', p47:'#6e40c9', s47:'#6e40c9',
bmp:'#2da44e',
html:'#e16b36', htm:'#e16b36',
txt:'#57606a', rtf:'#57606a',
};
function fileIcon(ext) {
const c = EXT_COLOR[ext] || '#57606a';
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513
l2.914 2.914c.329.328.513.773.513 1.237v9.586
A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25V1.75z"
fill="${c}" fill-opacity="0.15" stroke="${c}" stroke-width="1.25"/>
<path d="M10 .5v3a.5.5 0 0 0 .5.5h3"
stroke="${c}" stroke-width="1.25" stroke-linecap="round"/>
</svg>`;
}
/* ── Utilities ─────────────────────────────────────────────── */
function h(str) {
return String(str)
.replace(/&/g,'&').replace(/</g,'<')
.replace(/>/g,'>').replace(/"/g,'"');
}
function ext(name) {
const i = name.lastIndexOf('.');
return i > 0 ? name.slice(i + 1).toLowerCase() : '';
}
function typeLabel(file) {
if (file.type === 'dir') return 'Folder';
const e = ext(file.name);
return e ? e.toUpperCase() + '\u2009File' : 'File';
}
function fmtSize(bytes) {
if (!bytes) return '—';
if (bytes < 1024) return bytes + '\u202fB';
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + '\u202fKB';
return (bytes / (1024 * 1024)).toFixed(2) + '\u202fMB';
}
function hidden(name) {
return name.startsWith('.') || HIDDEN.has(name);
}
/* ── GitHub API ─────────────────────────────────────────────── */
async function fetchRepoContents(path) {
const url = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/contents/${path}?ref=${BRANCH}`;
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP\u00a0${res.status}`);
return res.json();
}
/* ── Sort ───────────────────────────────────────────────────── */
function sorted(files) {
return [...files].sort((a, b) => {
if (a.type !== b.type) return a.type === 'dir' ? -1 : 1;
let av, bv;
if (sortCol === 'name') { av = a.name.toLowerCase(); bv = b.name.toLowerCase(); }
else if (sortCol === 'size') { av = a.size || 0; bv = b.size || 0; }
else { av = typeLabel(a).toLowerCase(); bv = typeLabel(b).toLowerCase(); }
const cmp = av < bv ? -1 : av > bv ? 1 : 0;
return sortDir === 'asc' ? cmp : -cmp;
});
}
function updateHeaders() {
document.querySelectorAll('.dir-table thead th[data-col]').forEach(th => {
const arrow = th.querySelector('.sort-arrow');
if (th.dataset.col === sortCol) {
th.classList.add('sort-active');
arrow.textContent = sortDir === 'asc' ? '↑' : '↓';
} else {
th.classList.remove('sort-active');
arrow.textContent = '↕';
}
});
}
/* ── Breadcrumb ─────────────────────────────────────────────── */
function renderBreadcrumb(path) {
const parts = path ? path.split('/') : [];
let html = `<a href="./" data-path="">root</a>`;
let cur = '';
parts.forEach((part, i) => {
cur += (cur ? '/' : '') + part;
html += ` <span class="bc-sep">/</span> `;
if (i < parts.length - 1) {
html += `<a href="#${h(cur)}" data-path="${h(cur)}">${h(part)}</a>`;
} else {
html += `<strong>${h(part)}</strong>`;
}
});
document.getElementById('breadcrumb').innerHTML = html;
}
/* ── Table rendering ────────────────────────────────────────── */
function renderTable(files) {
const tbody = document.getElementById('dir-body');
const list = sorted(files);
let rows = '';
if (currentPath) {
const parent = currentPath.split('/').slice(0, -1).join('/');
rows += `<tr>
<td class="td-icon">${ICON_UP}</td>
<td colspan="3"><a href="${parent ? '#' + h(parent) : './'}" class="parent-link" data-path="${h(parent)}">..\u2002(Parent Directory)</a></td>
<td class="td-dl"></td>
</tr>`;
}
if (list.length === 0) {
rows += `<tr><td colspan="5" class="state-cell">This folder is empty.</td></tr>`;
} else {
list.forEach(f => {
const icon = f.type === 'dir' ? ICON_FOLDER : fileIcon(ext(f.name));
const label = typeLabel(f);
const size = f.type === 'dir' ? '—' : fmtSize(f.size);
if (f.type === 'dir') {
const dlUrl = `https://download-directory.github.io/?url=https://github.com/${REPO_OWNER}/${REPO_NAME}/tree/${BRANCH}/${h(f.path)}`;
rows += `<tr>
<td class="td-icon">${icon}</td>
<td><a href="#${h(f.path)}" class="name-link" data-path="${h(f.path)}">${h(f.name)}</a></td>
<td class="td-size">—</td>
<td class="td-type">${label}</td>
<td class="td-dl"><a href="${dlUrl}" class="dl-btn" target="_blank" rel="noopener">${ICON_DL} Download</a></td>
</tr>`;
} else {
const dl = h(f.download_url);
const fn = h(f.name);
const isBmp = ext(f.name) === 'bmp';
const bmpAttr = isBmp ? ` data-bmp="${dl}" data-bmp-name="${fn}"` : '';
rows += `<tr${bmpAttr}>
<td class="td-icon">${icon}</td>
<td><a href="${dl}" class="name-link" download="${fn}">${fn}</a></td>
<td class="td-size">${size}</td>
<td class="td-type">${label}</td>
<td class="td-dl"><a href="${dl}" class="dl-btn" download="${fn}">${ICON_DL} Download</a></td>
</tr>`;
}
});
}
tbody.innerHTML = rows;
const nDir = files.filter(f => f.type === 'dir').length;
const nFile = files.filter(f => f.type === 'file').length;
const parts = [];
if (nDir) parts.push(`${nDir} folder${nDir !== 1 ? 's' : ''}`);
if (nFile) parts.push(`${nFile} file${nFile !== 1 ? 's' : ''}`);
document.getElementById('status-bar').textContent = parts.join(', ') || 'Empty directory';
}
/* ── Load directory ─────────────────────────────────────────── */
async function loadDir(path, addHistory = true) {
currentPath = path;
if (addHistory) {
const url = path ? '#' + path : (location.pathname + location.search);
history.pushState({ path }, '', url);
}
renderBreadcrumb(path);
const tbody = document.getElementById('dir-body');
tbody.innerHTML = `<tr><td colspan="5" class="state-cell">
<span class="spinner"></span>Loading…
</td></tr>`;
document.getElementById('status-bar').innerHTML = ' ';
try {
const data = await fetchRepoContents(path);
currentFiles = data.filter(f => !hidden(f.name));
renderTable(currentFiles);
} catch (err) {
tbody.innerHTML = `<tr><td colspan="5" class="state-cell is-error">
⚠ Failed to load: ${h(err.message)}
</td></tr>`;
document.getElementById('status-bar').textContent = 'Error loading contents.';
}
}
/* ── Event delegation ───────────────────────────────────────── */
document.addEventListener('click', e => {
/* Nav links (breadcrumb + folder + parent) */
const navLink = e.target.closest('a[data-path]');
if (navLink) {
e.preventDefault();
loadDir(navLink.dataset.path);
return;
}
/* Sort headers */
const th = e.target.closest('th[data-col]');
if (th) {
const col = th.dataset.col;
sortDir = (sortCol === col && sortDir === 'asc') ? 'desc' : 'asc';
sortCol = col;
updateHeaders();
renderTable(currentFiles);
}
});
/* ── BMP hover preview ──────────────────────────────────────── */
const preview = document.getElementById('img-preview');
const previewImg = document.getElementById('img-preview-img');
const previewName = document.getElementById('img-preview-name');
document.getElementById('dir-body').addEventListener('mouseover', e => {
const row = e.target.closest('tr[data-bmp]');
if (row) {
const url = row.dataset.bmp;
if (previewImg.getAttribute('src') !== url) {
previewImg.src = url;
previewName.textContent = row.dataset.bmpName || '';
}
preview.style.display = 'block';
} else {
preview.style.display = 'none';
}
});
document.getElementById('dir-body').addEventListener('mouseleave', () => {
preview.style.display = 'none';
});
document.addEventListener('mousemove', e => {
if (preview.style.display !== 'block') return;
const offset = 16;
const pw = preview.offsetWidth;
const ph = preview.offsetHeight;
const vw = window.innerWidth;
const vh = window.innerHeight;
const x = e.clientX + offset + pw > vw ? e.clientX - pw - offset : e.clientX + offset;
const y = e.clientY + offset + ph > vh ? e.clientY - ph - offset : e.clientY + offset;
preview.style.left = x + 'px';
preview.style.top = y + 'px';
});
/* ── Browser back/forward ───────────────────────────────────── */
window.addEventListener('popstate', e => {
const path = e.state != null ? e.state.path : decodeURIComponent(location.hash.slice(1));
loadDir(path, false);
});
/* ── Boot ───────────────────────────────────────────────────── */
document.addEventListener('DOMContentLoaded', () => {
const path = decodeURIComponent(location.hash.slice(1));
history.replaceState({ path }, '', location.href);
loadDir(path, false);
});
})();
</script>
</body>
</html>