Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
94 lines (92 loc) · 3.03 KB
/
Copy pathindex.html
File metadata and controls
94 lines (92 loc) · 3.03 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>cellucid-datasets</title>
<style>
body {
margin: 0;
font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
line-height: 1.45;
padding: 20px;
max-width: 860px;
}
code {
background: rgba(0, 0, 0, 0.06);
padding: 1px 4px;
border-radius: 4px;
}
ul {
padding-left: 18px;
}
</style>
</head>
<body>
<h1 style="margin: 0 0 8px">cellucid-datasets</h1>
<p style="margin: 0 0 12px">
Static demo exports for the Cellucid web app.
</p>
<p style="margin: 0 0 8px">
Manifest:
<a href="./exports/datasets.json"><code>exports/datasets.json</code></a>
</p>
<h2 style="margin: 0 0 8px; font-size: 16px">Datasets</h2>
<div id="datasets">Loading…</div>
<script type="module">
async function main() {
const container = document.getElementById('datasets');
try {
const resp = await fetch('./exports/datasets.json', { cache: 'no-store' });
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const manifest = await resp.json();
if (
manifest === null ||
typeof manifest !== 'object' ||
Array.isArray(manifest) ||
manifest.version !== 1 ||
typeof manifest.default !== 'string' ||
manifest.default.length === 0 ||
!Array.isArray(manifest.datasets) ||
manifest.datasets.length === 0
) {
throw new Error('datasets.json does not satisfy catalog version 1');
}
const ul = document.createElement('ul');
for (const dataset of manifest.datasets) {
if (
dataset === null ||
typeof dataset !== 'object' ||
Array.isArray(dataset) ||
typeof dataset.id !== 'string' ||
dataset.id.length === 0 ||
typeof dataset.path !== 'string' ||
dataset.path.length === 0
) {
throw new Error(
'datasets.json contains an invalid dataset entry'
);
}
const li = document.createElement('li');
const a = document.createElement('a');
a.href = `./exports/${dataset.path}`;
a.textContent = dataset.id;
li.appendChild(a);
if (dataset.id === manifest.default) {
li.append(' (default)');
}
ul.appendChild(li);
}
container.textContent = '';
container.appendChild(ul);
} catch (err) {
const reason = err instanceof Error
? err.message
: 'catalog loading rejected with a non-Error value';
container.textContent = `Failed to load datasets.json: ${reason}`;
}
}
void main();
</script>
</body>
</html>