-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
429 lines (381 loc) · 13 KB
/
index.html
File metadata and controls
429 lines (381 loc) · 13 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Danny's Biggles Collection</title>
<style>
:root {
--bg: #faf9f6;
--card: #fff;
--border: #e2e0dc;
--text: #2c2c2c;
--muted: #7a7672;
--accent: #8b6914;
--accent-light: #f5f0e0;
--owned: #2d7a3a;
--owned-bg: #e8f5ea;
--kindle: #5b6abf;
--kindle-bg: #eceefb;
--wanted: #b8860b;
--wanted-bg: #fdf6e3;
--missing: #9a4040;
--missing-bg: #fbeaea;
--upgrade: #7a5c1f;
--upgrade-bg: #faf3df;
--order-bg: #f0eefd;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.5;
padding: 2rem 1rem;
max-width: 900px;
margin: 0 auto;
}
header { margin-bottom: 2rem; }
header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.25rem; }
header p { color: var(--muted); font-size: 0.9rem; }
.stats {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin: 1rem 0 1.5rem;
}
.stat {
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
padding: 0.6rem 1rem;
font-size: 0.85rem;
}
.stat strong { display: block; font-size: 1.3rem; line-height: 1.2; }
.tabs {
display: flex;
gap: 0.25rem;
border-bottom: 2px solid var(--border);
margin-bottom: 1rem;
flex-wrap: wrap;
}
.tab {
padding: 0.5rem 1rem;
font-size: 0.85rem;
cursor: pointer;
border: none;
background: none;
color: var(--muted);
font-weight: 500;
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count {
font-size: 0.75rem;
background: var(--border);
border-radius: 10px;
padding: 0.1rem 0.45rem;
margin-left: 0.3rem;
}
.tab.active .count { background: var(--accent-light); color: var(--accent); }
.search-bar {
margin-bottom: 1rem;
}
.search-bar input {
width: 100%;
padding: 0.5rem 0.75rem;
border: 1px solid var(--border);
border-radius: 6px;
font-size: 0.9rem;
background: var(--card);
}
.search-bar input:focus { outline: 2px solid var(--accent); border-color: transparent; }
table { width: 100%; border-collapse: collapse; }
thead th {
text-align: left;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--muted);
padding: 0.4rem 0.5rem;
border-bottom: 1px solid var(--border);
cursor: pointer;
user-select: none;
white-space: nowrap;
}
thead th:hover { color: var(--text); }
thead th .arrow { font-size: 0.65rem; margin-left: 0.2rem; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--accent-light); }
tbody td {
padding: 0.5rem;
font-size: 0.85rem;
border-bottom: 1px solid var(--border);
vertical-align: top;
}
.chron { color: var(--muted); font-size: 0.8rem; min-width: 2rem; text-align: center; }
.title-cell { font-weight: 500; }
.period { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.pub { font-size: 0.8rem; color: var(--muted); text-align: center; }
.badge {
display: inline-block;
font-size: 0.7rem;
font-weight: 600;
padding: 0.15rem 0.5rem;
border-radius: 10px;
white-space: nowrap;
}
.badge-owned { background: var(--owned-bg); color: var(--owned); }
.badge-kindle { background: var(--kindle-bg); color: var(--kindle); }
.badge-wanted { background: var(--wanted-bg); color: var(--wanted); }
.badge-missing { background: var(--missing-bg); color: var(--missing); }
.badge-upgrade { background: var(--upgrade-bg); color: var(--upgrade); }
.badge-order { background: var(--order-bg); color: var(--kindle); }
.badge-first { background: #f0f7f1; color: var(--owned); border: 1px solid #c8e6c9; }
.badges { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.copies {
font-size: 0.78rem;
color: var(--muted);
margin-top: 0.2rem;
}
.upgrade-note {
font-size: 0.78rem;
color: var(--upgrade);
font-style: italic;
margin-top: 0.2rem;
}
.empty-state {
text-align: center;
padding: 3rem 1rem;
color: var(--muted);
font-size: 0.9rem;
}
footer {
margin-top: 3rem;
padding-top: 1rem;
border-top: 1px solid var(--border);
font-size: 0.8rem;
color: var(--muted);
}
@media (max-width: 600px) {
body { padding: 1rem 0.5rem; }
.stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.3rem;
}
.stat { padding: 0.4rem 0.7rem; font-size: 0.8rem; text-align: center; }
.stat strong { font-size: 1.1rem; }
.tabs { gap: 0; }
.tab { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
.search-bar input { padding: 0.6rem 0.75rem; font-size: 1rem; }
.hide-mobile { display: none; }
.chron { display: none; }
thead th.chron { display: none; }
.badge { font-size: 0.65rem; padding: 0.1rem 0.4rem; }
}
</style>
</head>
<body>
<header>
<h1>Danny's Biggles Collection</h1>
<p>Tracking my collection of W.E. Johns' Biggles books. If you have any of the books I'm looking for, <a href="mailto:[email protected]">get in touch</a>.</p>
</header>
<div class="stats" id="stats"></div>
<div class="tabs" id="tabs"></div>
<div class="search-bar"><input type="text" id="search" placeholder="Search by title..."></div>
<table>
<thead id="thead"></thead>
<tbody id="tbody"></tbody>
</table>
<div class="empty-state" id="empty" style="display:none">No books match your search.</div>
<footer>
Data maintained by hand. Last updated <span id="updated"></span>. 98 Biggles books published 1932–1999.
</footer>
<script>
const TABS = [
{ id: 'looking', label: 'Looking For' },
{ id: 'upgrade', label: 'Want Upgrade' },
{ id: 'collection', label: 'Full Collection' },
{ id: 'first-editions', label: 'First Editions' },
];
let canonical = [];
let collectionMap = {};
let currentTab = 'looking';
let searchQuery = '';
let sortKey = 'chronology';
let sortDir = 1;
async function init() {
const [canonRes, collRes] = await Promise.all([
fetch('canonical.json').then(r => r.json()),
fetch('collection.json').then(r => r.json()),
]);
canonical = canonRes;
collRes.forEach(c => collectionMap[c.book_id] = c);
// Last commit date fallback
document.getElementById('updated').textContent = new Date().toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
renderStats();
renderTabs();
renderTable();
document.getElementById('search').addEventListener('input', e => {
searchQuery = e.target.value.toLowerCase();
renderTable();
});
}
function getStatus(book) {
const c = collectionMap[book.id];
if (!c) return 'missing';
if (c.owned) return 'owned';
if (c.on_order) return 'on_order';
if (c.on_kindle) return 'kindle';
if (c.wanted) return 'wanted';
return 'missing';
}
function renderStats() {
const owned = canonical.filter(b => collectionMap[b.id]?.owned).length;
const kindle = canonical.filter(b => collectionMap[b.id]?.on_kindle).length;
const firstEds = canonical.filter(b => collectionMap[b.id]?.copies?.some(c => c.first_edition)).length;
const read = canonical.filter(b => collectionMap[b.id]?.read).length;
const missing = canonical.filter(b => {
const c = collectionMap[b.id];
return !c || (!c.owned && !c.on_order);
}).length;
document.getElementById('stats').innerHTML = `
<div class="stat"><strong>${owned}/98</strong>Owned</div>
<div class="stat"><strong>${kindle}</strong>On Kindle</div>
<div class="stat"><strong>${firstEds}</strong>First Editions</div>
<div class="stat"><strong>${read}</strong>Read</div>
<div class="stat"><strong>${missing}</strong>Still Looking</div>
`;
}
function getFilteredBooks() {
let books = canonical;
if (currentTab === 'looking') {
books = books.filter(b => {
const c = collectionMap[b.id];
return !c || (!c.owned && !c.on_order);
});
} else if (currentTab === 'upgrade') {
books = books.filter(b => collectionMap[b.id]?.want_upgrade);
} else if (currentTab === 'first-editions') {
books = books.filter(b => collectionMap[b.id]?.copies?.some(c => c.first_edition));
}
if (searchQuery) {
books = books.filter(b => b.title.toLowerCase().includes(searchQuery));
}
books.sort((a, b) => {
let va, vb;
if (sortKey === 'chronology') { va = a.id; vb = b.id; }
else if (sortKey === 'title') { va = a.title; vb = b.title; }
else if (sortKey === 'period') { va = a.period; vb = b.period; }
else if (sortKey === 'pub_date') { va = a.pub_date; vb = b.pub_date; }
else if (sortKey === 'status') { va = getStatus(a); vb = getStatus(b); }
if (currentTab === 'looking') {
// Sort wanted to top
const aw = collectionMap[a.id]?.wanted ? 0 : 1;
const bw = collectionMap[b.id]?.wanted ? 0 : 1;
if (aw !== bw) return aw - bw;
}
if (va < vb) return -1 * sortDir;
if (va > vb) return 1 * sortDir;
return 0;
});
return books;
}
function renderTabs() {
const counts = {
looking: canonical.filter(b => {
const c = collectionMap[b.id];
return !c || (!c.owned && !c.on_order);
}).length,
upgrade: canonical.filter(b => collectionMap[b.id]?.want_upgrade).length,
collection: canonical.length,
'first-editions': canonical.filter(b => collectionMap[b.id]?.copies?.some(c => c.first_edition)).length,
};
document.getElementById('tabs').innerHTML = TABS.map(t =>
`<button class="tab ${currentTab === t.id ? 'active' : ''}" data-tab="${t.id}">
${t.label}<span class="count">${counts[t.id]}</span>
</button>`
).join('');
document.querySelectorAll('.tab').forEach(btn => {
btn.addEventListener('click', () => {
currentTab = btn.dataset.tab;
sortKey = 'chronology';
sortDir = 1;
renderTabs();
renderTable();
});
});
}
function renderTable() {
const books = getFilteredBooks();
const showStatus = currentTab === 'collection';
const showCopies = currentTab === 'collection' || currentTab === 'first-editions';
const cols = [
{ key: 'chronology', label: '#', cls: 'chron' },
{ key: 'title', label: 'Title', cls: 'title-cell' },
{ key: 'status', label: 'Status', cls: '' },
{ key: 'period', label: 'Period', cls: 'period hide-mobile' },
{ key: 'pub_date', label: 'Published', cls: 'pub hide-mobile' },
];
document.getElementById('thead').innerHTML = '<tr>' + cols.map(c => {
const arrow = sortKey === c.key ? (sortDir === 1 ? ' ▲' : ' ▼') : '';
return `<th class="${c.cls}" data-sort="${c.key}">${c.label}<span class="arrow">${arrow}</span></th>`;
}).join('') + '</tr>';
document.querySelectorAll('thead th').forEach(th => {
th.addEventListener('click', () => {
const key = th.dataset.sort;
if (sortKey === key) sortDir *= -1;
else { sortKey = key; sortDir = 1; }
renderTable();
});
});
if (books.length === 0) {
document.getElementById('tbody').innerHTML = '';
document.getElementById('empty').style.display = 'block';
return;
}
document.getElementById('empty').style.display = 'none';
document.getElementById('tbody').innerHTML = books.map(book => {
const c = collectionMap[book.id];
const status = getStatus(book);
let badges = '';
if (status === 'owned') badges += '<span class="badge badge-owned">Owned</span>';
if (status === 'kindle') badges += '<span class="badge badge-kindle">Kindle</span>';
if (status === 'on_order') badges += '<span class="badge badge-order">On Order</span>';
if (status === 'wanted') badges += '<span class="badge badge-wanted">Wanted</span>';
if (status === 'missing') badges += '<span class="badge badge-missing">Not Owned</span>';
if (c?.on_kindle && c?.owned) badges += '<span class="badge badge-kindle">Kindle</span>';
if (c?.copies?.some(cp => cp.first_edition)) badges += '<span class="badge badge-first">1st Ed</span>';
if (c?.want_upgrade) badges += '<span class="badge badge-upgrade">Want Upgrade</span>';
let extra = '';
if (showCopies && c?.copies?.length) {
const copyDescs = c.copies.map(cp => {
const parts = [];
if (cp.year) parts.push(cp.year);
if (cp.first_edition) parts.push('1st ed');
parts.push(cp.paperback ? 'PB' : 'HB');
if (cp.notes) parts.push(cp.notes);
return parts.join(', ');
});
extra += `<div class="copies">${copyDescs.join(' | ')}</div>`;
}
if (c?.want_upgrade && c?.upgrade_notes) {
extra += `<div class="upgrade-note">${c.upgrade_notes}</div>`;
}
return `<tr>
<td class="chron">${book.id}</td>
<td class="title-cell">${book.title}${extra}</td>
<td><div class="badges">${badges}</div></td>
<td class="period hide-mobile">${book.period}</td>
<td class="pub hide-mobile">${book.pub_date}</td>
</tr>`;
}).join('');
}
init();
</script>
</body>
</html>