-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
150 lines (129 loc) · 4.35 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Krang Dataset</title>
<meta
name="viewport"
content="width = device - width, initial-scale = 1.0, shrink-to-fit = no"
/>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ"
crossorigin="anonymous"
/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="src/main.js"></script>
<link href="src/main.css" rel="stylesheet" />
<script>
globalThis.store = { ...(globalThis.store ?? {}) };
const iconSVGPaths = {
check: `
<path
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417
5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0
1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />`,
cross: `
<path
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647
2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707
8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />`,
};
const Card = ({
id,
fragments = {},
fullImageURL = null,
previewURL,
}) => {
const hasFragments = Object.keys(fragments).length > 0,
hasFullImage = fullImageURL !== null;
const labels = [
{
icon: `
<svg
fill="${hasFragments ? "green" : "red"}"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
${hasFragments ? iconSVGPaths.check : iconSVGPaths.cross}
</svg>
`,
text: `${hasFragments ? "has" : "no"} fragments`,
},
{
icon: `
<svg
fill="${hasFullImage ? "green" : "red"}"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
${hasFullImage ? iconSVGPaths.check : iconSVGPaths.cross}
</svg>
`,
text: `${hasFullImage ? "has" : "no"} full image`,
},
];
return `
<a
href="deepzoom.html#${id}"
class="d-flex flex-column gap-3 pt-3
text-dark text-decoration-none
border border-2 border-dark-subtle bg-dark-subtle bg-opacity-25"
style="width:200px;height:fit-content;"
>
<h6 class="slide-id m-0 px-3">${id}</h6>
<div class="d-inline-flex flex-wrap gap-1 px-3">
${labels
.map(
({ icon, text }) =>
'<span class="d-inline-flex gap-2 align-items-center">' +
icon +
'<span style="white-space:pre;">' +
text +
"</span>" +
"</span>"
)
.join("")}
</div>
<img class="w-100" style="height:fit-content;" src="${previewURL}" />
</a>
`;
};
$(document).ready(() => {
const overviewRoot = $("#overview");
loadSlideCollection().then((slides) => {
if (!globalThis.store.slides) {
/*
* Making the slides registry available globally once the data is downloaded
*/
globalThis.store = { ...globalThis.store, slides };
}
Object.values(slides).forEach((slide) =>
/*
* Only render slides with preview URL existing
*/
slide.previewURL ? overviewRoot.append(Card(slide)) : void null
);
});
});
</script>
</head>
<body>
<nav class="fragments">
<a href="fragments.html">Fragments</a>
</nav>
<main class="container">
<h1>Сканы гистологических препаратов головного мозга</h1>
<div
id="overview"
class="d-flex flex-wrap justify-content-evenly gap-3"
></div>
</main>
<!-- /container -->
</body>
</html>