-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.html
More file actions
777 lines (643 loc) · 23.4 KB
/
Copy pathindex.html
File metadata and controls
777 lines (643 loc) · 23.4 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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>KEV Commit History</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Favicon: shield-style professional icon (replace with official logo anytime). -->
<link
rel="icon"
type="image/svg+xml"
href='data:image/svg+xml;utf8,
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="%230b5cad"/>
<stop offset="1" stop-color="%232d7bd1"/>
</linearGradient>
</defs>
<path fill="url(%23g)" d="M32 2l22 8v16c0 16-12 29-22 36-10-7-22-20-22-36V10l22-8z"/>
<path fill="white" d="M32 14l10 4v8c0 9-6 16-10 19-4-3-10-10-10-19v-8l10-4z"/>
<circle cx="32" cy="26" r="6" fill="%230b5cad"/>
</svg>'
/>
<style>
:root {
--bg: #ffffff;
--fg: #1c2733;
--muted: #5f6d7a;
--accent: #0b5cad;
--border: #d9dee3;
--row: #f7f9fb;
--chip-bg: #eef3f9;
--added: #0f7b28;
--removed: #b00020;
--ransom: #8a2be2;
--admin: #8a6d1c;
--csv: #0b5cad;
--json: #2d7bd1;
}
body.dark {
--bg: #0f141a;
--fg: #e8eef3;
--muted: #a0adb7;
--accent: #58a6ff;
--border: #2a3742;
--row: #111821;
--chip-bg: #0f253d;
--csv: #58a6ff;
--json: #8dbbff;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--fg);
font: 15px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
header {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 16px;
padding: 24px clamp(16px, 5vw, 48px);
border-bottom: 1px solid var(--border);
background: linear-gradient(180deg, rgba(11,92,173,0.07), transparent);
position: relative;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
width: 36px;
height: 36px;
border-radius: 8px;
background: var(--row);
display: grid;
place-items: center;
border: 1px solid var(--border);
}
.brand-icon svg { width: 24px; height: 24px; }
h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); }
.sub { color: var(--muted); font-size: 14px; }
.controls {
display: flex;
gap: 10px;
align-items: center;
position: absolute;
top: 16px;
right: 24px;
}
.btn {
background: var(--row);
color: var(--fg);
border: 1px solid var(--border);
padding: 8px 12px;
border-radius: 8px;
cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
main {
padding: 24px clamp(16px, 5vw, 48px);
display: grid;
gap: 24px;
}
tbody a { color: var(--accent); text-decoration: none; }
tbody a:hover { text-decoration: underline; }
/* Filter bar */
.filter-bar {
display: grid;
gap: 12px;
grid-template-columns: 1fr 1fr auto auto;
align-items: end;
padding: 12px;
border: 1px solid var(--border);
border-radius: 12px;
background: var(--row);
}
.filter-bar label { font-size: 13px; color: var(--muted); }
.filter-bar input[type="date"] {
width: 100%;
padding: 8px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--bg);
color: var(--fg);
}
.disclaimer { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
section {
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
background: var(--bg);
}
.section-header {
background: var(--row);
padding: 12px 16px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: baseline;
justify-content: space-between;
}
.updated { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
text-align: left;
padding: 12px 16px;
border-bottom: 1px solid var(--border);
color: var(--muted);
white-space: nowrap;
}
tbody td {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
vertical-align: top;
}
tbody tr:nth-child(even) { background: var(--row); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.chip {
display: inline-block;
padding: 3px 8px;
border-radius: 999px;
font-size: 12px;
background: var(--chip-bg);
border: 1px solid var(--border);
margin-right: 6px;
}
.chip.csv { color: var(--csv); border-color: var(--csv); }
.chip.json { color: var(--json); border-color: var(--json); }
.chip.added { color: var(--added); border-color: var(--added); }
.chip.removed { color: var(--removed); border-color: var(--removed); }
.chip.ransom { color: var(--ransom); border-color: var(--ransom); }
.chip.admin { color: var(--admin); border-color: var(--admin); }
details { margin-top: 8px; border-left: 3px solid var(--border); padding-left: 12px; }
summary { cursor: pointer; color: var(--accent); }
ul { margin: 8px 0 0 20px; }
footer {
padding: 16px clamp(16px, 5vw, 48px);
color: var(--muted);
border-top: 1px solid var(--border);
}
@media (max-width: 820px) {
header { grid-template-columns: 1fr auto; }
.filter-bar { grid-template-columns: 1fr 1fr; }
}
</style>
</head>
<body>
<header>
<div class="brand">
<div class="brand-icon" aria-hidden="true">
<!-- Header icon (shield) -->
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" role="img">
<defs>
<linearGradient id="gh" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#0b5cad" />
<stop offset="1" stop-color="#2d7bd1" />
</linearGradient>
</defs>
<path fill="url(#gh)" d="M32 2l22 8v16c0 16-12 29-22 36-10-7-22-20-22-36V10l22-8z" />
<path fill="white" d="M32 14l10 4v8c0 9-6 16-10 19-4-3-10-10-10-19v-8l10-4z" />
<circle cx="32" cy="26" r="6" fill="#0b5cad" />
</svg>
</div>
<div>
<h1>KEV Commit History</h1>
<div class="sub">
Unified JSON/CSV commit view, CVE diffs (Added/Removed/Ransomware/Admin), last 14 days by default.
</div>
</div>
</div>
<div class="controls">
<button id="themeToggle" class="btn" aria-label="Toggle theme">🌙 / 🌞</button>
</div>
</header>
<main>
<!-- FILTER BAR -->
<div class="filter-bar" role="region" aria-label="Date range filters">
<div>
<label for="fromDate">From</label>
<input id="fromDate" type="date" />
</div>
<div>
<label for="toDate">To</label>
<input id="toDate" type="date" />
</div>
<button id="applyRange" class="btn">Apply Date Range</button>
<button id="resetRange" class="btn">Reset to Last 14 Days</button>
<div id="rangeNote" class="disclaimer"></div>
</div>
<!-- UNIFIED TIMELINE -->
<section>
<div class="section-header">
<div>
<strong>Commits in Selected Range</strong>
<div id="updated" class="updated"></div>
</div>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Commit Time</th>
<th>Files Changed</th>
<th>Summary</th>
<th>Details (per CVE)</th>
</tr>
</thead>
<tbody id="timeline">
<tr><td colspan="4">Loading…</td></tr>
</tbody>
</table>
</div>
</section>
</main>
<footer>Data loads live from GitHub on each view.</footer>
<script>
const OWNER = "cisagov";
const REPO = "kev-data";
const PATHS = {
JSON: "known_exploited_vulnerabilities.json",
CSV: "known_exploited_vulnerabilities.csv"
};
/* ===== Theme ===== */
const themeBtn = document.getElementById("themeToggle");
const saved = localStorage.getItem("theme") || "light";
if (saved === "dark") document.body.classList.add("dark");
themeBtn.onclick = () => {
document.body.classList.toggle("dark");
localStorage.setItem(
"theme",
document.body.classList.contains("dark") ? "dark" : "light"
);
};
const fmt = d => new Date(d).toLocaleString(undefined, { hour12: false });
/* ===== GitHub Helpers ===== */
async function fetchJSON(url) {
const r = await fetch(url);
if (!r.ok) throw new Error(`${r.status} ${url}`);
return r.json();
}
async function fetchText(url) {
const r = await fetch(url);
if (!r.ok) throw new Error(`${r.status} ${url}`);
return r.text();
}
async function listHistoryForPathPaged(path, { perPage = 100, maxPages = 2, stopIfOlderThan = null }) {
const results = [];
for (let page = 1; page <= maxPages; page++) {
const url = `https://api.github.com/repos/${OWNER}/${REPO}/commits?path=${encodeURIComponent(path)}&per_page=${perPage}&page=${page}`;
const batch = await fetchJSON(url);
if (!Array.isArray(batch) || batch.length === 0) break;
results.push(...batch);
if (stopIfOlderThan) {
const oldest = batch[batch.length - 1];
const oldestDate = new Date(oldest.commit?.author?.date || oldest.commit?.committer?.date);
if (oldestDate < stopIfOlderThan) break;
}
if (batch.length < perPage) break;
}
return results;
}
async function rawAt(sha, path) {
return fetchText(`https://raw.githubusercontent.com/${OWNER}/${REPO}/${sha}/${path}`);
}
/* ===== Parsing ===== */
function normalizeValue(val) {
if (val === undefined || val === null) return null;
if (typeof val === "string") {
const s = val.trim();
return s.length ? s.replace(/\s+/g, " ") : null;
}
if (typeof val === "number" || typeof val === "boolean") return val;
if (Array.isArray(val)) {
const norm = val.map(v => normalizeValue(v)).filter(v => v !== null);
return norm.sort((a, b) => String(a).localeCompare(String(b)));
}
if (typeof val === "object") {
const keys = Object.keys(val).sort();
const obj = {};
for (const k of keys) obj[k] = normalizeValue(val[k]);
return obj;
}
return val;
}
function eq(a, b) {
return JSON.stringify(normalizeValue(a)) === JSON.stringify(normalizeValue(b));
}
/* JSON Parser */
function parseKEVJson(text) {
const data = JSON.parse(text);
const rows = Array.isArray(data)
? data
: (Array.isArray(data.vulnerabilities) ? data.vulnerabilities : []);
const map = new Map();
for (const row of rows) {
const id = row.cveID || row.cveId || row.cve || row.CVE;
if (!id) continue;
map.set(String(id), row);
}
return map;
}
/* CSV Parser */
function parseCsv(text) {
const out = [];
let i = 0, field = "", row = [], inQ = false;
while (i < text.length) {
const c = text[i++];
if (inQ) {
if (c === `"`) {
if (text[i] === `"`) { field += `"`; i++; }
else { inQ = false; }
} else field += c;
} else {
if (c === `,`) { row.push(field); field = ""; }
else if (c === `\n`) { row.push(field); field = ""; out.push(row); row = []; }
else if (c === `\r`) {}
else if (c === `"`) inQ = true;
else field += c;
}
}
if (field.length || row.length) { row.push(field); out.push(row); }
const header = (out.shift() || []).map(h => h.trim());
const idx = Object.fromEntries(header.map((h, i) => [h, i]));
const arr = out
.filter(r => r.length > 0 && r.some(x => x?.trim()?.length))
.map(r => {
const obj = {};
header.forEach((h, j) => obj[h] = (r[j] || "").trim());
return obj;
});
const idCol = ["cveID", "cveId", "cve", "CVE", "CVE_ID", "cve_id"].find(k => k in idx) || "cveID";
const map = new Map();
for (const row of arr) {
const id = row[idCol];
if (id) map.set(String(id), row);
}
return map;
}
/* ===== Diffing ===== */
function normalizeRansomEnum(v) {
if (v === undefined || v === null) return null;
const s = String(v).trim().toLowerCase();
if (!s) return null;
if (s === "known") return "Known";
if (s === "unknown") return "Unknown";
return null;
}
function displayRansomEnum(v) {
if (v === "Known") return "Known";
if (v === "Unknown") return "Unknown";
return "(empty)";
}
function diffRecords(currMap, prevMap, isJson = false) {
const changes = new Map();
const ids = new Set([...currMap.keys(), ...prevMap.keys()]);
for (const id of ids) {
const c = currMap.get(id), p = prevMap.get(id);
if (c && !p) { changes.set(id, [{ type: "added" }]); continue; }
if (!c && p) { changes.set(id, [{ type: "removed" }]); continue; }
if (c && p) {
const entries = [];
// FIX: Detect ransomware change for BOTH JSON and CSV (Known/Unknown strings)
const currRan = normalizeRansomEnum(c.knownRansomwareCampaignUse);
const prevRan = normalizeRansomEnum(p.knownRansomwareCampaignUse);
if (currRan !== prevRan) {
entries.push({
type: "ransom",
field: "knownRansomwareCampaignUse",
from: prevRan,
to: currRan
});
}
const keys = new Set([...Object.keys(c), ...Object.keys(p)]);
for (const key of keys) {
if (["cveID", "cveId", "cve", "CVE", "knownRansomwareCampaignUse"].includes(key)) continue;
const fromV = p ? p[key] : null;
const toV = c ? c[key] : null;
if (!eq(fromV, toV)) {
entries.push({
type: "admin",
field: key,
from: displayVal(fromV),
to: displayVal(toV)
});
}
}
if (entries.length) changes.set(id, entries);
}
}
return changes;
}
function displayVal(v) {
if (v === null || v === undefined) return "(empty)";
if (typeof v === "boolean") return v ? "true" : "false";
if (Array.isArray(v)) return v.length ? JSON.stringify(v) : "(empty)";
if (typeof v === "object") return JSON.stringify(v);
return String(v);
}
/* ===== Rendering ===== */
function chipsForFiles(flags) {
const arr = [];
if (flags.json) arr.push(`<span class="chip json">JSON</span>`);
if (flags.csv) arr.push(`<span class="chip csv">CSV</span>`);
return arr.join(" ");
}
function summaryChips(changeMap) {
const types = new Set();
for (const arr of changeMap.values())
for (const ch of arr) types.add(ch.type);
const out = [];
if (types.has("added")) out.push(`<span class="chip added">added</span>`);
if (types.has("removed")) out.push(`<span class="chip removed">removed</span>`);
if (types.has("ransom")) out.push(`<span class="chip ransom">ransomware changed</span>`);
if (types.has("admin")) out.push(`<span class="chip admin">admin changed</span>`);
return out.join(" ");
}
function detailsList(changeMap) {
const items = [];
const ids = Array.from(changeMap.keys()).sort((a, b) => String(a).localeCompare(String(b)));
for (const id of ids) {
const changes = changeMap.get(id);
for (const ch of changes) {
if (ch.type === "added")
items.push(`<li class="mono">${id} — added</li>`);
else if (ch.type === "removed")
items.push(`<li class="mono">${id} — removed</li>`);
else if (ch.type === "ransom")
items.push(`<li class="mono">${id} — ransomware tag changed (${displayRansomEnum(ch.from)} → ${displayRansomEnum(ch.to)})</li>`);
else if (ch.type === "admin")
items.push(`<li class="mono">${id} — admin change: ${ch.field} (${displayVal(ch.from)} → ${displayVal(ch.to)})</li>`);
}
}
if (!items.length) return "No CVE-level changes.";
return `<details><summary>View CVE details</summary><ul>${items.join("")}</ul></details>`;
}
function renderRow(commitTime, commitUrl, fileFlags, combinedChanges) {
const safeUrl = commitUrl ? String(commitUrl) : "#";
return `
<tr>
<td><a href="${safeUrl}" target="_blank" rel="noopener noreferrer">${commitTime}</a></td>
<td>${chipsForFiles(fileFlags)}</td>
<td>${summaryChips(combinedChanges) || "No changes"}</td>
<td>${detailsList(combinedChanges)}</td>
</tr>
`;
}
/* ===== Date Range ===== */
const rangeNote = document.getElementById("rangeNote");
const fromInput = document.getElementById("fromDate");
const toInput = document.getElementById("toDate");
const applyBtn = document.getElementById("applyRange");
const resetBtn = document.getElementById("resetRange");
const DAY_MS = 86400000;
function defaultRange() {
const now = new Date();
const to = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const from = new Date(to.getTime() - 14 * DAY_MS);
return { from, to };
}
let currentRange = defaultRange();
function setFilterInputs(range) {
const toISO = d =>
new Date(d.getTime() - d.getTimezoneOffset() * 60000)
.toISOString()
.slice(0, 10);
fromInput.value = toISO(range.from);
toInput.value = toISO(range.to);
}
applyBtn.onclick = async () => {
try {
const from = new Date(fromInput.value);
const to = new Date(toInput.value);
if (isNaN(from) || isNaN(to)) throw new Error("Please select valid dates.");
if (from > to) throw new Error("From date cannot be later than To date.");
currentRange = { from, to };
const spanDays = Math.ceil((to - from) / DAY_MS) + 1;
rangeNote.textContent = spanDays > 60
? "Note: Loading a large range may take additional time."
: "";
await loadUnified(from, to);
} catch (e) {
rangeNote.textContent = e.message;
}
};
resetBtn.onclick = async () => {
currentRange = defaultRange();
setFilterInputs(currentRange);
rangeNote.textContent = "";
await loadUnified(currentRange.from, currentRange.to);
};
/* ===== Unified Loader ===== */
const rawCache = new Map();
async function cachedRawAt(sha, path) {
const key = `${sha}:${path}`;
if (rawCache.has(key)) return rawCache.get(key);
const text = await rawAt(sha, path);
rawCache.set(key, text);
return text;
}
function findPrevSha(history, sha) {
const idx = history.findIndex(c => c.sha === sha);
const prev = idx >= 0 ? history[idx + 1] : null;
return prev ? prev.sha : null;
}
function mergeChangeMaps(baseMap, newMap) {
const merged = new Map(baseMap);
for (const [id, newList] of newMap.entries()) {
if (!merged.has(id)) merged.set(id, newList);
else {
const existing = merged.get(id);
const combined = [...existing];
newList.forEach(entry => {
const serialized = JSON.stringify(entry);
const exists = existing.some(e => JSON.stringify(e) === serialized);
if (!exists) combined.push(entry);
});
merged.set(id, combined);
}
}
return merged;
}
async function loadUnified(fromDate, toDate) {
const tbody = document.getElementById("timeline");
const updated = document.getElementById("updated");
tbody.innerHTML = `<tr><td colspan="4">Loading…</td></tr>`;
try {
const spanDays = Math.ceil((toDate - fromDate) / DAY_MS) + 1;
const needsDeepPaging = spanDays > 14;
const pagingPlan = {
perPage: 100,
maxPages: needsDeepPaging ? 10 : 2,
stopIfOlderThan: needsDeepPaging ? null : fromDate
};
const [jsonHist, csvHist] = await Promise.all([
listHistoryForPathPaged(PATHS.JSON, pagingPlan),
listHistoryForPathPaged(PATHS.CSV, pagingPlan)
]);
const bySha = new Map();
const addCommit = (c, isJson) => {
const sha = c.sha;
const time = c.commit?.author?.date || c.commit?.committer?.date;
const url = c.html_url;
if (!bySha.has(sha))
bySha.set(sha, { sha, time, url, flags: { json: false, csv: false } });
bySha.get(sha).flags[isJson ? "json" : "csv"] = true;
};
jsonHist.forEach(c => addCommit(c, true));
csvHist.forEach(c => addCommit(c, false));
const commits = Array.from(bySha.values())
.sort((a, b) => new Date(b.time) - new Date(a.time));
const inRange = commits.filter(c => {
const t = new Date(c.time).getTime();
return t >= fromDate.getTime() && t <= (toDate.getTime() + DAY_MS - 1);
});
const rows = [];
for (const item of inRange) {
let combined = new Map();
if (item.flags.json) {
const currText = await cachedRawAt(item.sha, PATHS.JSON);
const prevSha = findPrevSha(jsonHist, item.sha);
const prevText = prevSha ? await cachedRawAt(prevSha, PATHS.JSON) : null;
const currMap = parseKEVJson(currText);
const prevMap = prevText ? parseKEVJson(prevText) : new Map();
const diffMap = diffRecords(currMap, prevMap, true);
combined = mergeChangeMaps(combined, diffMap);
}
if (item.flags.csv) {
const currText = await cachedRawAt(item.sha, PATHS.CSV);
const prevSha = findPrevSha(csvHist, item.sha);
const prevText = prevSha ? await cachedRawAt(prevSha, PATHS.CSV) : null;
const currMap = parseCsv(currText);
const prevMap = prevText ? parseCsv(prevText) : new Map();
const diffMap = diffRecords(currMap, prevMap, false);
combined = mergeChangeMaps(combined, diffMap);
}
rows.push({
time: item.time,
url: item.url,
flags: item.flags,
changes: combined
});
}
const tableRows = rows.map(r => renderRow(r.time, r.url, r.flags, r.changes));
tbody.innerHTML =
tableRows.join("") ||
`<tr><td colspan="4">No JSON/CSV updates in this range.</td></tr>`;
updated.textContent =
`Last updated: ${fmt(new Date())} — Range: ${fmt(fromDate)} → ${fmt(toDate)}`;
if (needsDeepPaging) {
rangeNote.textContent = "Note: Loading extended ranges may take additional time.";
}
} catch (e) {
tbody.innerHTML = `<tr><td colspan="4">Error loading updates: ${e.message}</td></tr>`;
}
}
/* ===== Init ===== */
(async function init() {
currentRange = defaultRange();
setFilterInputs(currentRange);
await loadUnified(currentRange.from, currentRange.to);
})();
</script>
</body>
</html>