egehan 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -2
- package/assets/dictionary/narratives.en.json +660 -0
- package/assets/dictionary/narratives.tr.json +660 -0
- package/assets/schema/egehan-report.schema.json +354 -0
- package/assets/spec/rules.json +272 -0
- package/assets/templates/egehan-book.html +2027 -0
- package/assets/templates/hook.sh +41 -0
- package/dist/artifacts.d.ts +21 -0
- package/dist/artifacts.js +32 -0
- package/dist/capsule/capsule.d.ts +35 -0
- package/dist/capsule/capsule.js +123 -0
- package/dist/capsule/storage.d.ts +15 -0
- package/dist/capsule/storage.js +52 -0
- package/dist/cli/commands/capsule.d.ts +20 -0
- package/dist/cli/commands/capsule.js +94 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.js +47 -0
- package/dist/cli/commands/hook.d.ts +14 -0
- package/dist/cli/commands/hook.js +120 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.js +92 -0
- package/dist/cli/commands/stats.d.ts +14 -0
- package/dist/cli/commands/stats.js +112 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +167 -0
- package/dist/cli/output.d.ts +26 -0
- package/dist/cli/output.js +87 -0
- package/dist/cli/prompt.d.ts +21 -0
- package/dist/cli/prompt.js +63 -0
- package/dist/config/config.d.ts +51 -0
- package/dist/config/config.js +160 -0
- package/dist/detect/projectType.d.ts +34 -0
- package/dist/detect/projectType.js +95 -0
- package/dist/engine/buildReport.d.ts +32 -0
- package/dist/engine/buildReport.js +188 -0
- package/dist/engine/chapters.d.ts +20 -0
- package/dist/engine/chapters.js +33 -0
- package/dist/engine/classifier.d.ts +21 -0
- package/dist/engine/classifier.js +119 -0
- package/dist/engine/conventional.d.ts +15 -0
- package/dist/engine/conventional.js +137 -0
- package/dist/engine/datetime.d.ts +47 -0
- package/dist/engine/datetime.js +100 -0
- package/dist/engine/milestones.d.ts +6 -0
- package/dist/engine/milestones.js +109 -0
- package/dist/engine/narrator.d.ts +71 -0
- package/dist/engine/narrator.js +189 -0
- package/dist/engine/prepare.d.ts +36 -0
- package/dist/engine/prepare.js +46 -0
- package/dist/engine/privacy.d.ts +45 -0
- package/dist/engine/privacy.js +110 -0
- package/dist/engine/pulse.d.ts +17 -0
- package/dist/engine/pulse.js +205 -0
- package/dist/engine/templating.d.ts +40 -0
- package/dist/engine/templating.js +64 -0
- package/dist/engine/types.d.ts +205 -0
- package/dist/engine/types.js +9 -0
- package/dist/git/logReader.d.ts +37 -0
- package/dist/git/logReader.js +133 -0
- package/dist/git/repository.d.ts +14 -0
- package/dist/git/repository.js +61 -0
- package/dist/git/runGit.d.ts +21 -0
- package/dist/git/runGit.js +74 -0
- package/dist/hooks/block.d.ts +27 -0
- package/dist/hooks/block.js +62 -0
- package/dist/hooks/manager.d.ts +47 -0
- package/dist/hooks/manager.js +153 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +26 -0
- package/dist/pipeline.d.ts +35 -0
- package/dist/pipeline.js +80 -0
- package/dist/renderers/html.d.ts +6 -0
- package/dist/renderers/html.js +117 -0
- package/dist/renderers/markdown.d.ts +4 -0
- package/dist/renderers/markdown.js +168 -0
- package/dist/spec/assets.d.ts +14 -0
- package/dist/spec/assets.js +98 -0
- package/dist/spec/dictionary.d.ts +100 -0
- package/dist/spec/dictionary.js +39 -0
- package/dist/spec/rules.d.ts +191 -0
- package/dist/spec/rules.js +15 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +20 -0
- package/package.json +55 -4
|
@@ -0,0 +1,2027 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="__EGEHAN_LANG__" data-theme="__EGEHAN_THEME__">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
|
+
<meta name="referrer" content="no-referrer" />
|
|
8
|
+
<meta name="generator" content="egehan" />
|
|
9
|
+
<title>__EGEHAN_TITLE__</title>
|
|
10
|
+
|
|
11
|
+
<!--
|
|
12
|
+
egehan-chronicle.html — a self-contained chronicle.
|
|
13
|
+
|
|
14
|
+
Nothing here loads from the network: no fonts, no scripts, no stylesheets, no images. The
|
|
15
|
+
file opens from a USB stick, from an aeroplane, and in ten years' time. That is the whole
|
|
16
|
+
point of it, so please keep it that way.
|
|
17
|
+
|
|
18
|
+
The page renders itself from the two JSON blocks at the bottom. That is deliberate: the
|
|
19
|
+
template is the single source of presentation for *every* Egehan engine, so the Node and the
|
|
20
|
+
.NET implementations produce a byte-identical file by injecting the same data into the same
|
|
21
|
+
template, instead of each assembling HTML strings that would slowly drift apart.
|
|
22
|
+
|
|
23
|
+
Every value that comes from a repository — commit subjects, author names, tags, file paths —
|
|
24
|
+
is written to the DOM with textContent. A commit message is untrusted input: somebody's
|
|
25
|
+
contributor can write `<img onerror=…>` in a commit subject, and if this file interpolated
|
|
26
|
+
that into innerHTML the maintainer's own chronicle would execute it.
|
|
27
|
+
-->
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
/* ---------------------------------------------------------------
|
|
31
|
+
Tokens. Dark values are declared twice on purpose: once for the
|
|
32
|
+
OS setting and once for the in-page toggle, which must win both
|
|
33
|
+
ways. The :not() guard lets an explicit light choice beat OS dark.
|
|
34
|
+
--------------------------------------------------------------- */
|
|
35
|
+
:root {
|
|
36
|
+
color-scheme: light;
|
|
37
|
+
|
|
38
|
+
--bg: #f4f2ee;
|
|
39
|
+
--surface: #fdfcfa;
|
|
40
|
+
--surface-2: #f7f5f1;
|
|
41
|
+
--surface-3: #efece6;
|
|
42
|
+
--border: #e2ded5;
|
|
43
|
+
--border-strong: #cfcabe;
|
|
44
|
+
|
|
45
|
+
--text: #15140f;
|
|
46
|
+
--text-2: #55524a;
|
|
47
|
+
--text-3: #837f76;
|
|
48
|
+
|
|
49
|
+
--accent: #2a78d6;
|
|
50
|
+
--accent-soft: #e8f0fc;
|
|
51
|
+
--grid: #e7e3db;
|
|
52
|
+
|
|
53
|
+
--cat-birth: #1baf7a;
|
|
54
|
+
--cat-first-steps: #2a78d6;
|
|
55
|
+
--cat-growing-pains: #eb6834;
|
|
56
|
+
--cat-midnight-oil: #6250d6;
|
|
57
|
+
--cat-milestone: #e87ba4;
|
|
58
|
+
--cat-evolution: #008300;
|
|
59
|
+
|
|
60
|
+
--shadow: 0 1px 2px rgba(20, 18, 12, 0.05), 0 12px 32px -22px rgba(20, 18, 12, 0.3);
|
|
61
|
+
--radius: 14px;
|
|
62
|
+
--radius-sm: 9px;
|
|
63
|
+
|
|
64
|
+
--sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
65
|
+
'Noto Sans', sans-serif;
|
|
66
|
+
--serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
|
|
67
|
+
--mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@media (prefers-color-scheme: dark) {
|
|
71
|
+
:root:not([data-theme='light']) {
|
|
72
|
+
color-scheme: dark;
|
|
73
|
+
|
|
74
|
+
--bg: #121211;
|
|
75
|
+
--surface: #1c1c1a;
|
|
76
|
+
--surface-2: #232321;
|
|
77
|
+
--surface-3: #2b2b28;
|
|
78
|
+
--border: #32312d;
|
|
79
|
+
--border-strong: #46453f;
|
|
80
|
+
|
|
81
|
+
--text: #f2f0ea;
|
|
82
|
+
--text-2: #b5b2a9;
|
|
83
|
+
--text-3: #85827b;
|
|
84
|
+
|
|
85
|
+
--accent: #3987e5;
|
|
86
|
+
--accent-soft: #19283b;
|
|
87
|
+
--grid: #2b2b27;
|
|
88
|
+
|
|
89
|
+
--cat-birth: #199e70;
|
|
90
|
+
--cat-first-steps: #3987e5;
|
|
91
|
+
--cat-growing-pains: #d95926;
|
|
92
|
+
--cat-midnight-oil: #9085e9;
|
|
93
|
+
--cat-milestone: #d55181;
|
|
94
|
+
--cat-evolution: #0ca30c;
|
|
95
|
+
|
|
96
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -22px rgba(0, 0, 0, 0.8);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:root[data-theme='dark'] {
|
|
101
|
+
color-scheme: dark;
|
|
102
|
+
|
|
103
|
+
--bg: #121211;
|
|
104
|
+
--surface: #1c1c1a;
|
|
105
|
+
--surface-2: #232321;
|
|
106
|
+
--surface-3: #2b2b28;
|
|
107
|
+
--border: #32312d;
|
|
108
|
+
--border-strong: #46453f;
|
|
109
|
+
|
|
110
|
+
--text: #f2f0ea;
|
|
111
|
+
--text-2: #b5b2a9;
|
|
112
|
+
--text-3: #85827b;
|
|
113
|
+
|
|
114
|
+
--accent: #3987e5;
|
|
115
|
+
--accent-soft: #19283b;
|
|
116
|
+
--grid: #2b2b27;
|
|
117
|
+
|
|
118
|
+
--cat-birth: #199e70;
|
|
119
|
+
--cat-first-steps: #3987e5;
|
|
120
|
+
--cat-growing-pains: #d95926;
|
|
121
|
+
--cat-midnight-oil: #9085e9;
|
|
122
|
+
--cat-milestone: #d55181;
|
|
123
|
+
--cat-evolution: #0ca30c;
|
|
124
|
+
|
|
125
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -22px rgba(0, 0, 0, 0.8);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
*,
|
|
129
|
+
*::before,
|
|
130
|
+
*::after {
|
|
131
|
+
box-sizing: border-box;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
html {
|
|
135
|
+
-webkit-text-size-adjust: 100%;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
body {
|
|
139
|
+
margin: 0;
|
|
140
|
+
background: var(--bg);
|
|
141
|
+
color: var(--text);
|
|
142
|
+
font-family: var(--sans);
|
|
143
|
+
font-size: 16px;
|
|
144
|
+
line-height: 1.6;
|
|
145
|
+
-webkit-font-smoothing: antialiased;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.wrap {
|
|
149
|
+
max-width: 68rem;
|
|
150
|
+
margin: 0 auto;
|
|
151
|
+
padding: 0 16px 96px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* --- header ------------------------------------------------- */
|
|
155
|
+
|
|
156
|
+
.masthead {
|
|
157
|
+
padding: 56px 0 28px;
|
|
158
|
+
display: flex;
|
|
159
|
+
flex-wrap: wrap;
|
|
160
|
+
gap: 20px;
|
|
161
|
+
align-items: flex-end;
|
|
162
|
+
justify-content: space-between;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.masthead h1 {
|
|
166
|
+
font-family: var(--serif);
|
|
167
|
+
font-size: clamp(2rem, 5vw, 3rem);
|
|
168
|
+
line-height: 1.12;
|
|
169
|
+
letter-spacing: -0.02em;
|
|
170
|
+
margin: 0 0 6px;
|
|
171
|
+
font-weight: 600;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.masthead p {
|
|
175
|
+
margin: 0;
|
|
176
|
+
color: var(--text-2);
|
|
177
|
+
font-size: 0.95rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.dedication {
|
|
181
|
+
margin: 18px 0 0;
|
|
182
|
+
padding-left: 14px;
|
|
183
|
+
border-left: 3px solid var(--border-strong);
|
|
184
|
+
font-family: var(--serif);
|
|
185
|
+
font-style: italic;
|
|
186
|
+
color: var(--text-2);
|
|
187
|
+
max-width: 46ch;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.tools {
|
|
191
|
+
display: flex;
|
|
192
|
+
gap: 8px;
|
|
193
|
+
align-items: center;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
button,
|
|
197
|
+
select,
|
|
198
|
+
input[type='search'],
|
|
199
|
+
input[type='password'] {
|
|
200
|
+
font: inherit;
|
|
201
|
+
color: var(--text);
|
|
202
|
+
background: var(--surface);
|
|
203
|
+
border: 1px solid var(--border);
|
|
204
|
+
border-radius: var(--radius-sm);
|
|
205
|
+
padding: 7px 11px;
|
|
206
|
+
cursor: pointer;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
input[type='search'],
|
|
210
|
+
input[type='password'] {
|
|
211
|
+
cursor: text;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
button:hover,
|
|
215
|
+
select:hover {
|
|
216
|
+
border-color: var(--border-strong);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
button:focus-visible,
|
|
220
|
+
select:focus-visible,
|
|
221
|
+
input:focus-visible,
|
|
222
|
+
summary:focus-visible,
|
|
223
|
+
.chip:focus-visible {
|
|
224
|
+
outline: 2px solid var(--accent);
|
|
225
|
+
outline-offset: 2px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.chip {
|
|
229
|
+
display: inline-flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
gap: 6px;
|
|
232
|
+
border: 1px solid var(--border);
|
|
233
|
+
background: var(--surface);
|
|
234
|
+
border-radius: 999px;
|
|
235
|
+
padding: 5px 12px 5px 9px;
|
|
236
|
+
font-size: 0.85rem;
|
|
237
|
+
color: var(--text-2);
|
|
238
|
+
cursor: pointer;
|
|
239
|
+
user-select: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.chip .dot {
|
|
243
|
+
width: 9px;
|
|
244
|
+
height: 9px;
|
|
245
|
+
border-radius: 50%;
|
|
246
|
+
background: var(--chip-color, var(--text-3));
|
|
247
|
+
flex: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.chip[aria-pressed='true'] {
|
|
251
|
+
color: var(--text);
|
|
252
|
+
border-color: var(--border-strong);
|
|
253
|
+
background: var(--surface-3);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.chip[aria-pressed='false'] {
|
|
257
|
+
opacity: 0.5;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* --- cards -------------------------------------------------- */
|
|
261
|
+
|
|
262
|
+
.card {
|
|
263
|
+
background: var(--surface);
|
|
264
|
+
border: 1px solid var(--border);
|
|
265
|
+
border-radius: var(--radius);
|
|
266
|
+
box-shadow: var(--shadow);
|
|
267
|
+
padding: 22px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
section {
|
|
271
|
+
margin-top: 44px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.section-head {
|
|
275
|
+
display: flex;
|
|
276
|
+
align-items: baseline;
|
|
277
|
+
justify-content: space-between;
|
|
278
|
+
gap: 16px;
|
|
279
|
+
margin-bottom: 14px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
h2 {
|
|
283
|
+
font-family: var(--serif);
|
|
284
|
+
font-size: 1.35rem;
|
|
285
|
+
font-weight: 600;
|
|
286
|
+
letter-spacing: -0.01em;
|
|
287
|
+
margin: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.lede {
|
|
291
|
+
font-family: var(--serif);
|
|
292
|
+
font-size: 1.1rem;
|
|
293
|
+
line-height: 1.65;
|
|
294
|
+
color: var(--text);
|
|
295
|
+
margin: 0 0 20px;
|
|
296
|
+
max-width: 62ch;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* --- stat tiles --------------------------------------------- */
|
|
300
|
+
|
|
301
|
+
/* Borders on the tiles rather than a 1px grid gap: the gap technique paints the container
|
|
302
|
+
colour wherever the last row runs out of tiles, which reads as an unexplained dark block. */
|
|
303
|
+
.tiles {
|
|
304
|
+
display: grid;
|
|
305
|
+
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
306
|
+
background: var(--surface);
|
|
307
|
+
border: 1px solid var(--border);
|
|
308
|
+
border-radius: var(--radius);
|
|
309
|
+
overflow: hidden;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.tile {
|
|
313
|
+
padding: 15px 18px;
|
|
314
|
+
border-right: 1px solid var(--border);
|
|
315
|
+
border-bottom: 1px solid var(--border);
|
|
316
|
+
min-height: 74px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.tile .label {
|
|
320
|
+
display: block;
|
|
321
|
+
font-size: 0.78rem;
|
|
322
|
+
color: var(--text-3);
|
|
323
|
+
letter-spacing: 0.01em;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.tile .value {
|
|
327
|
+
display: block;
|
|
328
|
+
font-size: 1.5rem;
|
|
329
|
+
font-weight: 600;
|
|
330
|
+
letter-spacing: -0.02em;
|
|
331
|
+
margin-top: 2px;
|
|
332
|
+
font-variant-numeric: tabular-nums;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* A worded value (a chronotype name) cannot wear the number size without wrapping into a
|
|
336
|
+
tile twice the height of its neighbours. */
|
|
337
|
+
.tile .value.worded {
|
|
338
|
+
font-size: 1.02rem;
|
|
339
|
+
font-weight: 600;
|
|
340
|
+
line-height: 1.35;
|
|
341
|
+
letter-spacing: 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.tile .value .unit {
|
|
345
|
+
font-size: 0.8rem;
|
|
346
|
+
font-weight: 500;
|
|
347
|
+
color: var(--text-3);
|
|
348
|
+
margin-left: 3px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/* --- charts -------------------------------------------------- */
|
|
352
|
+
|
|
353
|
+
.charts {
|
|
354
|
+
display: grid;
|
|
355
|
+
grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
|
|
356
|
+
gap: 16px;
|
|
357
|
+
margin-top: 16px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/* A class rather than a style attribute: the VS Code webview serves this page under a
|
|
361
|
+
strict Content-Security-Policy, and `style-src 'nonce-…'` blocks inline style
|
|
362
|
+
attributes in markup. Scripted `element.style` assignments are unaffected. */
|
|
363
|
+
.mix-card {
|
|
364
|
+
margin-top: 16px;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.chart-title {
|
|
368
|
+
font-size: 0.82rem;
|
|
369
|
+
color: var(--text-3);
|
|
370
|
+
margin: 0 0 12px;
|
|
371
|
+
letter-spacing: 0.02em;
|
|
372
|
+
text-transform: uppercase;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.chart svg {
|
|
376
|
+
display: block;
|
|
377
|
+
width: 100%;
|
|
378
|
+
height: auto;
|
|
379
|
+
overflow: visible;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.axis-label {
|
|
383
|
+
font-family: var(--sans);
|
|
384
|
+
font-size: 10px;
|
|
385
|
+
fill: var(--text-3);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.grid-line {
|
|
389
|
+
stroke: var(--grid);
|
|
390
|
+
stroke-width: 1;
|
|
391
|
+
shape-rendering: crispEdges;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.bar {
|
|
395
|
+
fill: var(--accent);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.bar-hit {
|
|
399
|
+
fill: transparent;
|
|
400
|
+
cursor: default;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.bar-hit:hover + .bar,
|
|
404
|
+
.bar-hit:focus-visible + .bar {
|
|
405
|
+
fill: var(--text);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.trend-area {
|
|
409
|
+
fill: var(--accent);
|
|
410
|
+
opacity: 0.1;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.trend-line {
|
|
414
|
+
fill: none;
|
|
415
|
+
stroke: var(--accent);
|
|
416
|
+
stroke-width: 2;
|
|
417
|
+
stroke-linejoin: round;
|
|
418
|
+
stroke-linecap: round;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.trend-dot {
|
|
422
|
+
fill: var(--accent);
|
|
423
|
+
stroke: var(--surface);
|
|
424
|
+
stroke-width: 2;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.crosshair {
|
|
428
|
+
stroke: var(--border-strong);
|
|
429
|
+
stroke-width: 1;
|
|
430
|
+
shape-rendering: crispEdges;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.tooltip {
|
|
434
|
+
position: fixed;
|
|
435
|
+
z-index: 20;
|
|
436
|
+
pointer-events: none;
|
|
437
|
+
background: var(--text);
|
|
438
|
+
color: var(--bg);
|
|
439
|
+
border-radius: 8px;
|
|
440
|
+
padding: 7px 10px;
|
|
441
|
+
font-size: 0.8rem;
|
|
442
|
+
line-height: 1.35;
|
|
443
|
+
box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.5);
|
|
444
|
+
max-width: 18rem;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.tooltip .tip-value {
|
|
448
|
+
font-weight: 650;
|
|
449
|
+
font-variant-numeric: tabular-nums;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.tooltip .tip-label {
|
|
453
|
+
opacity: 0.72;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.tooltip[hidden] {
|
|
457
|
+
display: none;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/* --- category strip ----------------------------------------- */
|
|
461
|
+
|
|
462
|
+
.strip {
|
|
463
|
+
display: flex;
|
|
464
|
+
gap: 2px;
|
|
465
|
+
height: 14px;
|
|
466
|
+
margin: 4px 0 16px;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.strip span {
|
|
470
|
+
border-radius: 3px;
|
|
471
|
+
min-width: 3px;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.strip-legend {
|
|
475
|
+
display: flex;
|
|
476
|
+
flex-wrap: wrap;
|
|
477
|
+
gap: 6px 18px;
|
|
478
|
+
font-size: 0.86rem;
|
|
479
|
+
color: var(--text-2);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.strip-legend span {
|
|
483
|
+
display: inline-flex;
|
|
484
|
+
align-items: center;
|
|
485
|
+
gap: 7px;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.strip-legend .swatch {
|
|
489
|
+
width: 10px;
|
|
490
|
+
height: 10px;
|
|
491
|
+
border-radius: 3px;
|
|
492
|
+
flex: none;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.strip-legend b {
|
|
496
|
+
color: var(--text);
|
|
497
|
+
font-variant-numeric: tabular-nums;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/* --- data table (the relief rule, and keyboard-only readers) - */
|
|
501
|
+
|
|
502
|
+
details.data-table {
|
|
503
|
+
margin-top: 18px;
|
|
504
|
+
border-top: 1px solid var(--border);
|
|
505
|
+
padding-top: 12px;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
details.data-table summary {
|
|
509
|
+
cursor: pointer;
|
|
510
|
+
color: var(--text-2);
|
|
511
|
+
font-size: 0.86rem;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
table {
|
|
515
|
+
border-collapse: collapse;
|
|
516
|
+
width: 100%;
|
|
517
|
+
margin-top: 12px;
|
|
518
|
+
font-size: 0.86rem;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
th,
|
|
522
|
+
td {
|
|
523
|
+
text-align: left;
|
|
524
|
+
padding: 6px 10px;
|
|
525
|
+
border-bottom: 1px solid var(--border);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
th {
|
|
529
|
+
color: var(--text-3);
|
|
530
|
+
font-weight: 500;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
td.num {
|
|
534
|
+
text-align: right;
|
|
535
|
+
font-variant-numeric: tabular-nums;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/* --- milestones --------------------------------------------- */
|
|
539
|
+
|
|
540
|
+
.milestones {
|
|
541
|
+
display: grid;
|
|
542
|
+
gap: 1px;
|
|
543
|
+
background: var(--border);
|
|
544
|
+
border: 1px solid var(--border);
|
|
545
|
+
border-radius: var(--radius);
|
|
546
|
+
overflow: hidden;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.milestone {
|
|
550
|
+
background: var(--surface);
|
|
551
|
+
padding: 12px 18px;
|
|
552
|
+
display: flex;
|
|
553
|
+
gap: 14px;
|
|
554
|
+
align-items: baseline;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.milestone time {
|
|
558
|
+
color: var(--text-3);
|
|
559
|
+
font-size: 0.82rem;
|
|
560
|
+
white-space: nowrap;
|
|
561
|
+
min-width: 7.5rem;
|
|
562
|
+
font-variant-numeric: tabular-nums;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.milestone .what {
|
|
566
|
+
font-family: var(--serif);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.milestone .badge {
|
|
570
|
+
margin-left: auto;
|
|
571
|
+
font-family: var(--mono);
|
|
572
|
+
font-size: 0.72rem;
|
|
573
|
+
color: var(--text-2);
|
|
574
|
+
background: var(--surface-3);
|
|
575
|
+
border-radius: 999px;
|
|
576
|
+
padding: 2px 9px;
|
|
577
|
+
white-space: nowrap;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/* --- filters ------------------------------------------------- */
|
|
581
|
+
|
|
582
|
+
.filters {
|
|
583
|
+
display: flex;
|
|
584
|
+
flex-wrap: wrap;
|
|
585
|
+
gap: 10px;
|
|
586
|
+
align-items: center;
|
|
587
|
+
padding: 14px 0 4px;
|
|
588
|
+
position: sticky;
|
|
589
|
+
top: 0;
|
|
590
|
+
background: linear-gradient(var(--bg) 70%, transparent);
|
|
591
|
+
z-index: 10;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.filters input[type='search'] {
|
|
595
|
+
flex: 1 1 14rem;
|
|
596
|
+
min-width: 10rem;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.result-count {
|
|
600
|
+
font-size: 0.82rem;
|
|
601
|
+
color: var(--text-3);
|
|
602
|
+
font-variant-numeric: tabular-nums;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/* --- timeline ------------------------------------------------ */
|
|
606
|
+
|
|
607
|
+
.chapter {
|
|
608
|
+
position: relative;
|
|
609
|
+
padding: 0 0 8px 34px;
|
|
610
|
+
margin-top: 34px;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.chapter::before {
|
|
614
|
+
content: '';
|
|
615
|
+
position: absolute;
|
|
616
|
+
left: 11px;
|
|
617
|
+
top: 34px;
|
|
618
|
+
bottom: 0;
|
|
619
|
+
width: 2px;
|
|
620
|
+
background: var(--border);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.chapter:last-child::before {
|
|
624
|
+
bottom: 22px;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.chapter-mark {
|
|
628
|
+
position: absolute;
|
|
629
|
+
left: 0;
|
|
630
|
+
top: 2px;
|
|
631
|
+
width: 24px;
|
|
632
|
+
height: 24px;
|
|
633
|
+
border-radius: 50%;
|
|
634
|
+
display: grid;
|
|
635
|
+
place-items: center;
|
|
636
|
+
font-size: 13px;
|
|
637
|
+
background: var(--surface);
|
|
638
|
+
border: 2px solid var(--chapter-color, var(--border-strong));
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.chapter h3 {
|
|
642
|
+
font-family: var(--serif);
|
|
643
|
+
font-size: 1.22rem;
|
|
644
|
+
font-weight: 600;
|
|
645
|
+
margin: 0;
|
|
646
|
+
letter-spacing: -0.01em;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.chapter .meta {
|
|
650
|
+
color: var(--text-3);
|
|
651
|
+
font-size: 0.8rem;
|
|
652
|
+
margin: 2px 0 10px;
|
|
653
|
+
font-variant-numeric: tabular-nums;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.chapter .summary {
|
|
657
|
+
font-family: var(--serif);
|
|
658
|
+
font-style: italic;
|
|
659
|
+
color: var(--text-2);
|
|
660
|
+
margin: 0 0 16px;
|
|
661
|
+
max-width: 62ch;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.entry {
|
|
665
|
+
position: relative;
|
|
666
|
+
background: var(--surface);
|
|
667
|
+
border: 1px solid var(--border);
|
|
668
|
+
border-left: 3px solid var(--entry-color, var(--border-strong));
|
|
669
|
+
border-radius: var(--radius-sm);
|
|
670
|
+
padding: 13px 16px;
|
|
671
|
+
margin-bottom: 9px;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.entry .narrative {
|
|
675
|
+
font-family: var(--serif);
|
|
676
|
+
margin: 0 0 7px;
|
|
677
|
+
max-width: 68ch;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.entry .facts {
|
|
681
|
+
display: flex;
|
|
682
|
+
flex-wrap: wrap;
|
|
683
|
+
gap: 4px 14px;
|
|
684
|
+
font-size: 0.78rem;
|
|
685
|
+
color: var(--text-3);
|
|
686
|
+
font-variant-numeric: tabular-nums;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.entry .facts code {
|
|
690
|
+
font-family: var(--mono);
|
|
691
|
+
font-size: 0.74rem;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.entry .facts .tag {
|
|
695
|
+
color: var(--text);
|
|
696
|
+
background: var(--surface-3);
|
|
697
|
+
border-radius: 999px;
|
|
698
|
+
padding: 1px 8px;
|
|
699
|
+
font-family: var(--mono);
|
|
700
|
+
font-size: 0.72rem;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
.entry .facts .added {
|
|
704
|
+
color: var(--cat-evolution);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.entry .facts .removed {
|
|
708
|
+
color: var(--cat-growing-pains);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
mark {
|
|
712
|
+
background: var(--accent-soft);
|
|
713
|
+
color: var(--text);
|
|
714
|
+
border-radius: 3px;
|
|
715
|
+
padding: 0 2px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.empty {
|
|
719
|
+
color: var(--text-3);
|
|
720
|
+
font-family: var(--serif);
|
|
721
|
+
font-style: italic;
|
|
722
|
+
padding: 28px 0;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/* --- capsule ------------------------------------------------- */
|
|
726
|
+
|
|
727
|
+
.capsule {
|
|
728
|
+
text-align: center;
|
|
729
|
+
padding: 34px 22px;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.capsule h2 {
|
|
733
|
+
margin-bottom: 6px;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.countdown {
|
|
737
|
+
font-size: clamp(1.6rem, 5vw, 2.4rem);
|
|
738
|
+
font-weight: 600;
|
|
739
|
+
letter-spacing: -0.02em;
|
|
740
|
+
font-variant-numeric: tabular-nums;
|
|
741
|
+
margin: 14px 0 4px;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.capsule .hint,
|
|
745
|
+
.capsule .note {
|
|
746
|
+
color: var(--text-2);
|
|
747
|
+
font-size: 0.88rem;
|
|
748
|
+
margin: 4px 0;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.capsule form {
|
|
752
|
+
display: flex;
|
|
753
|
+
gap: 8px;
|
|
754
|
+
justify-content: center;
|
|
755
|
+
flex-wrap: wrap;
|
|
756
|
+
margin-top: 18px;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.capsule input[type='password'] {
|
|
760
|
+
min-width: 15rem;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.capsule .message {
|
|
764
|
+
font-family: var(--serif);
|
|
765
|
+
font-size: 1.05rem;
|
|
766
|
+
text-align: left;
|
|
767
|
+
white-space: pre-wrap;
|
|
768
|
+
background: var(--surface-2);
|
|
769
|
+
border-radius: var(--radius-sm);
|
|
770
|
+
padding: 18px 20px;
|
|
771
|
+
margin-top: 18px;
|
|
772
|
+
max-width: 58ch;
|
|
773
|
+
margin-inline: auto;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.capsule .error {
|
|
777
|
+
color: var(--cat-growing-pains);
|
|
778
|
+
font-size: 0.88rem;
|
|
779
|
+
margin-top: 10px;
|
|
780
|
+
min-height: 1.3em;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/* --- footer -------------------------------------------------- */
|
|
784
|
+
|
|
785
|
+
footer {
|
|
786
|
+
margin-top: 64px;
|
|
787
|
+
padding-top: 20px;
|
|
788
|
+
border-top: 1px solid var(--border);
|
|
789
|
+
color: var(--text-3);
|
|
790
|
+
font-size: 0.8rem;
|
|
791
|
+
display: flex;
|
|
792
|
+
flex-wrap: wrap;
|
|
793
|
+
gap: 6px 18px;
|
|
794
|
+
justify-content: space-between;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.noscript {
|
|
798
|
+
margin: 32px 0;
|
|
799
|
+
padding: 18px 20px;
|
|
800
|
+
border: 1px solid var(--border);
|
|
801
|
+
border-radius: var(--radius);
|
|
802
|
+
background: var(--surface);
|
|
803
|
+
font-family: var(--serif);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
[hidden] {
|
|
807
|
+
display: none !important;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.visually-hidden {
|
|
811
|
+
position: absolute;
|
|
812
|
+
width: 1px;
|
|
813
|
+
height: 1px;
|
|
814
|
+
overflow: hidden;
|
|
815
|
+
clip: rect(0 0 0 0);
|
|
816
|
+
white-space: nowrap;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
@media (max-width: 640px) {
|
|
820
|
+
.masthead {
|
|
821
|
+
padding-top: 34px;
|
|
822
|
+
}
|
|
823
|
+
.card {
|
|
824
|
+
padding: 16px;
|
|
825
|
+
}
|
|
826
|
+
.chapter {
|
|
827
|
+
padding-left: 26px;
|
|
828
|
+
}
|
|
829
|
+
.milestone {
|
|
830
|
+
flex-wrap: wrap;
|
|
831
|
+
gap: 4px 12px;
|
|
832
|
+
}
|
|
833
|
+
.milestone .badge {
|
|
834
|
+
margin-left: 0;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
@media print {
|
|
839
|
+
.tools,
|
|
840
|
+
.filters,
|
|
841
|
+
.tooltip,
|
|
842
|
+
details.data-table {
|
|
843
|
+
display: none !important;
|
|
844
|
+
}
|
|
845
|
+
body {
|
|
846
|
+
background: #fff;
|
|
847
|
+
}
|
|
848
|
+
.entry,
|
|
849
|
+
.card {
|
|
850
|
+
box-shadow: none;
|
|
851
|
+
break-inside: avoid;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
@media (prefers-reduced-motion: reduce) {
|
|
856
|
+
* {
|
|
857
|
+
animation: none !important;
|
|
858
|
+
transition: none !important;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
</style>
|
|
862
|
+
</head>
|
|
863
|
+
|
|
864
|
+
<body>
|
|
865
|
+
<div class="wrap">
|
|
866
|
+
<header class="masthead">
|
|
867
|
+
<div>
|
|
868
|
+
<h1 id="project-name"></h1>
|
|
869
|
+
<p id="subtitle"></p>
|
|
870
|
+
<p class="dedication" id="dedication" hidden></p>
|
|
871
|
+
</div>
|
|
872
|
+
<div class="tools">
|
|
873
|
+
<button id="theme-toggle" type="button" aria-pressed="false"></button>
|
|
874
|
+
</div>
|
|
875
|
+
</header>
|
|
876
|
+
|
|
877
|
+
<noscript>
|
|
878
|
+
<div class="noscript" id="noscript-notice">
|
|
879
|
+
This chronicle draws itself from the data stored in this file, so it needs JavaScript to render.
|
|
880
|
+
Nothing is loaded from the network either way. The same story in plain text lives in the project's
|
|
881
|
+
EGEHAN.md.
|
|
882
|
+
</div>
|
|
883
|
+
</noscript>
|
|
884
|
+
|
|
885
|
+
<div class="noscript" id="template-notice" hidden>
|
|
886
|
+
This is the Egehan page template, not a generated chronicle. Run
|
|
887
|
+
<code>egehan generate</code> in a repository to produce one.
|
|
888
|
+
</div>
|
|
889
|
+
|
|
890
|
+
<main id="app" hidden>
|
|
891
|
+
<section id="pulse-section">
|
|
892
|
+
<div class="section-head"><h2 id="pulse-title"></h2></div>
|
|
893
|
+
<p class="lede" id="pulse-narrative"></p>
|
|
894
|
+
|
|
895
|
+
<div class="tiles" id="tiles"></div>
|
|
896
|
+
|
|
897
|
+
<div class="charts">
|
|
898
|
+
<div class="card chart">
|
|
899
|
+
<p class="chart-title" id="hour-title"></p>
|
|
900
|
+
<div id="hour-chart"></div>
|
|
901
|
+
</div>
|
|
902
|
+
<div class="card chart">
|
|
903
|
+
<p class="chart-title" id="weekday-title"></p>
|
|
904
|
+
<div id="weekday-chart"></div>
|
|
905
|
+
</div>
|
|
906
|
+
<div class="card chart" id="monthly-card">
|
|
907
|
+
<p class="chart-title" id="monthly-title"></p>
|
|
908
|
+
<div id="monthly-chart"></div>
|
|
909
|
+
</div>
|
|
910
|
+
</div>
|
|
911
|
+
|
|
912
|
+
<div class="card mix-card">
|
|
913
|
+
<p class="chart-title" id="mix-title"></p>
|
|
914
|
+
<div class="strip" id="category-strip" role="img"></div>
|
|
915
|
+
<div class="strip-legend" id="category-legend"></div>
|
|
916
|
+
</div>
|
|
917
|
+
|
|
918
|
+
<details class="data-table">
|
|
919
|
+
<summary id="table-summary"></summary>
|
|
920
|
+
<div id="tables"></div>
|
|
921
|
+
</details>
|
|
922
|
+
</section>
|
|
923
|
+
|
|
924
|
+
<section id="milestones-section" hidden>
|
|
925
|
+
<div class="section-head"><h2 id="milestones-title"></h2></div>
|
|
926
|
+
<div class="milestones" id="milestones"></div>
|
|
927
|
+
</section>
|
|
928
|
+
|
|
929
|
+
<section id="timeline-section">
|
|
930
|
+
<div class="section-head">
|
|
931
|
+
<h2 id="timeline-title"></h2>
|
|
932
|
+
<span class="result-count" id="result-count"></span>
|
|
933
|
+
</div>
|
|
934
|
+
|
|
935
|
+
<div class="filters">
|
|
936
|
+
<input type="search" id="search" autocomplete="off" />
|
|
937
|
+
<select id="author-filter"></select>
|
|
938
|
+
<select id="year-filter"></select>
|
|
939
|
+
<span id="category-chips"></span>
|
|
940
|
+
</div>
|
|
941
|
+
|
|
942
|
+
<div id="timeline"></div>
|
|
943
|
+
<p class="empty" id="no-results" hidden></p>
|
|
944
|
+
</section>
|
|
945
|
+
|
|
946
|
+
<section id="capsule-section" hidden>
|
|
947
|
+
<div class="card capsule">
|
|
948
|
+
<h2 id="capsule-title"></h2>
|
|
949
|
+
<p class="note" id="capsule-author"></p>
|
|
950
|
+
<p class="countdown" id="capsule-countdown"></p>
|
|
951
|
+
<p class="note" id="capsule-status"></p>
|
|
952
|
+
<p class="hint" id="capsule-hint" hidden></p>
|
|
953
|
+
|
|
954
|
+
<form id="capsule-form" hidden>
|
|
955
|
+
<label class="visually-hidden" for="capsule-passphrase" id="capsule-label"></label>
|
|
956
|
+
<input type="password" id="capsule-passphrase" autocomplete="off" />
|
|
957
|
+
<button type="submit" id="capsule-submit"></button>
|
|
958
|
+
</form>
|
|
959
|
+
|
|
960
|
+
<p class="error" id="capsule-error" role="alert"></p>
|
|
961
|
+
<div class="message" id="capsule-message" hidden></div>
|
|
962
|
+
<p class="note" id="capsule-disclaimer"></p>
|
|
963
|
+
</div>
|
|
964
|
+
</section>
|
|
965
|
+
|
|
966
|
+
<footer>
|
|
967
|
+
<span id="footer-generator"></span>
|
|
968
|
+
<span id="footer-offline"></span>
|
|
969
|
+
</footer>
|
|
970
|
+
</main>
|
|
971
|
+
</div>
|
|
972
|
+
|
|
973
|
+
<div class="tooltip" id="tooltip" role="status" aria-live="polite" hidden></div>
|
|
974
|
+
|
|
975
|
+
<script id="egehan-report" type="application/json">
|
|
976
|
+
__EGEHAN_REPORT__
|
|
977
|
+
</script>
|
|
978
|
+
<script id="egehan-strings" type="application/json">
|
|
979
|
+
__EGEHAN_STRINGS__
|
|
980
|
+
</script>
|
|
981
|
+
|
|
982
|
+
<script>
|
|
983
|
+
'use strict';
|
|
984
|
+
|
|
985
|
+
/* ================================================================
|
|
986
|
+
Egehan chronicle renderer.
|
|
987
|
+
|
|
988
|
+
Reads the two JSON blocks above and builds the page. No network,
|
|
989
|
+
no dependencies, and every repository-derived string goes through
|
|
990
|
+
textContent — a commit subject is untrusted input.
|
|
991
|
+
================================================================ */
|
|
992
|
+
|
|
993
|
+
const $ = (id) => document.getElementById(id);
|
|
994
|
+
|
|
995
|
+
const data = (() => {
|
|
996
|
+
const read = (id) => {
|
|
997
|
+
const node = $(id);
|
|
998
|
+
if (node === null) return null;
|
|
999
|
+
try {
|
|
1000
|
+
return JSON.parse(node.textContent);
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
return { report: read('egehan-report'), strings: read('egehan-strings') };
|
|
1006
|
+
})();
|
|
1007
|
+
|
|
1008
|
+
const isRendered =
|
|
1009
|
+
data.report !== null &&
|
|
1010
|
+
data.strings !== null &&
|
|
1011
|
+
Array.isArray(data.report.entries) &&
|
|
1012
|
+
data.report.entries.length > 0;
|
|
1013
|
+
|
|
1014
|
+
/* ---------------------------------------------------------------
|
|
1015
|
+
Theme. The stored choice is a per-viewer convenience, so every
|
|
1016
|
+
access is guarded: private windows and blocked site data make
|
|
1017
|
+
localStorage throw rather than return empty.
|
|
1018
|
+
--------------------------------------------------------------- */
|
|
1019
|
+
|
|
1020
|
+
const THEME_KEY = 'egehan:theme';
|
|
1021
|
+
|
|
1022
|
+
const storage = {
|
|
1023
|
+
get(key) {
|
|
1024
|
+
try {
|
|
1025
|
+
return window.localStorage.getItem(key);
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
set(key, value) {
|
|
1031
|
+
try {
|
|
1032
|
+
window.localStorage.setItem(key, value);
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
/* nothing to do: the page works the same without a remembered theme */
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
function resolvedTheme() {
|
|
1040
|
+
const stored = storage.get(THEME_KEY);
|
|
1041
|
+
if (stored === 'light' || stored === 'dark') return stored;
|
|
1042
|
+
const declared = document.documentElement.getAttribute('data-theme');
|
|
1043
|
+
if (declared === 'light' || declared === 'dark') return declared;
|
|
1044
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function applyTheme(theme) {
|
|
1048
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
1049
|
+
const button = $('theme-toggle');
|
|
1050
|
+
if (button !== null) button.setAttribute('aria-pressed', String(theme === 'dark'));
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/* ---------------------------------------------------------------
|
|
1054
|
+
Formatting. Dates are parsed out of the ISO string's own fields,
|
|
1055
|
+
never through Date(), so a commit keeps the wall clock it was
|
|
1056
|
+
written at instead of being shifted into the reader's timezone.
|
|
1057
|
+
--------------------------------------------------------------- */
|
|
1058
|
+
|
|
1059
|
+
const strings = data.strings ?? {};
|
|
1060
|
+
const locale = strings.locale ?? {};
|
|
1061
|
+
const ui = strings.ui ?? {};
|
|
1062
|
+
|
|
1063
|
+
const fill = (template, values) =>
|
|
1064
|
+
String(template ?? '').replace(/\{([A-Za-z][A-Za-z0-9]*)\}/g, (match, name) =>
|
|
1065
|
+
Object.prototype.hasOwnProperty.call(values, name) ? String(values[name]) : match,
|
|
1066
|
+
);
|
|
1067
|
+
|
|
1068
|
+
function parts(iso) {
|
|
1069
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(String(iso ?? ''));
|
|
1070
|
+
if (match === null) return null;
|
|
1071
|
+
return {
|
|
1072
|
+
year: Number(match[1]),
|
|
1073
|
+
month: Number(match[2]),
|
|
1074
|
+
day: Number(match[3]),
|
|
1075
|
+
hour: match[4],
|
|
1076
|
+
minute: match[5],
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function formatDate(iso, short) {
|
|
1081
|
+
const at = parts(iso);
|
|
1082
|
+
if (at === null) return '';
|
|
1083
|
+
const months = locale.months ?? [];
|
|
1084
|
+
return fill(short === true ? locale.dateShortFormat : locale.dateFormat, {
|
|
1085
|
+
day: at.day,
|
|
1086
|
+
month: months[at.month - 1] ?? at.month,
|
|
1087
|
+
year: at.year,
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function formatTime(iso) {
|
|
1092
|
+
const at = parts(iso);
|
|
1093
|
+
if (at === null) return '';
|
|
1094
|
+
return fill(locale.timeFormat, { hour: at.hour, minute: at.minute });
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
function formatMonth(key) {
|
|
1098
|
+
const match = /^(\d{4})-(\d{2})$/.exec(String(key ?? ''));
|
|
1099
|
+
if (match === null) return String(key ?? '');
|
|
1100
|
+
const months = locale.months ?? [];
|
|
1101
|
+
return (months[Number(match[2]) - 1] ?? match[2]) + ' ' + match[1];
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
const number = (value) => new Intl.NumberFormat(document.documentElement.lang || 'en').format(value);
|
|
1105
|
+
|
|
1106
|
+
/** Appends text with every occurrence of `needle` wrapped in <mark>, without innerHTML. */
|
|
1107
|
+
function appendHighlighted(target, text, needle) {
|
|
1108
|
+
const haystack = String(text ?? '');
|
|
1109
|
+
if (needle === '') {
|
|
1110
|
+
target.appendChild(document.createTextNode(haystack));
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
const lowered = haystack.toLowerCase();
|
|
1115
|
+
const term = needle.toLowerCase();
|
|
1116
|
+
let cursor = 0;
|
|
1117
|
+
|
|
1118
|
+
for (;;) {
|
|
1119
|
+
const found = lowered.indexOf(term, cursor);
|
|
1120
|
+
if (found === -1) break;
|
|
1121
|
+
if (found > cursor) {
|
|
1122
|
+
target.appendChild(document.createTextNode(haystack.slice(cursor, found)));
|
|
1123
|
+
}
|
|
1124
|
+
const hit = document.createElement('mark');
|
|
1125
|
+
hit.textContent = haystack.slice(found, found + term.length);
|
|
1126
|
+
target.appendChild(hit);
|
|
1127
|
+
cursor = found + term.length;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (cursor < haystack.length) {
|
|
1131
|
+
target.appendChild(document.createTextNode(haystack.slice(cursor)));
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
function el(tag, className, text) {
|
|
1136
|
+
const node = document.createElement(tag);
|
|
1137
|
+
if (className !== undefined && className !== null) node.className = className;
|
|
1138
|
+
if (text !== undefined && text !== null) node.textContent = String(text);
|
|
1139
|
+
return node;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
1143
|
+
|
|
1144
|
+
function svgEl(tag, attributes) {
|
|
1145
|
+
const node = document.createElementNS(SVG_NS, tag);
|
|
1146
|
+
for (const key of Object.keys(attributes ?? {})) {
|
|
1147
|
+
node.setAttribute(key, String(attributes[key]));
|
|
1148
|
+
}
|
|
1149
|
+
return node;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/* ---------------------------------------------------------------
|
|
1153
|
+
Tooltip. Shared by every chart; the hovered mark is the hit
|
|
1154
|
+
target, and keyboard focus gets the same readout as hover.
|
|
1155
|
+
--------------------------------------------------------------- */
|
|
1156
|
+
|
|
1157
|
+
const tooltip = $('tooltip');
|
|
1158
|
+
|
|
1159
|
+
function showTooltip(event, value, label) {
|
|
1160
|
+
if (tooltip === null) return;
|
|
1161
|
+
tooltip.replaceChildren();
|
|
1162
|
+
tooltip.appendChild(el('div', 'tip-value', value));
|
|
1163
|
+
tooltip.appendChild(el('div', 'tip-label', label));
|
|
1164
|
+
tooltip.hidden = false;
|
|
1165
|
+
|
|
1166
|
+
const box = tooltip.getBoundingClientRect();
|
|
1167
|
+
const target = event.currentTarget.getBoundingClientRect();
|
|
1168
|
+
const x = Math.min(
|
|
1169
|
+
Math.max(8, target.left + target.width / 2 - box.width / 2),
|
|
1170
|
+
window.innerWidth - box.width - 8,
|
|
1171
|
+
);
|
|
1172
|
+
const y = target.top - box.height - 10;
|
|
1173
|
+
tooltip.style.left = x + 'px';
|
|
1174
|
+
tooltip.style.top = (y < 8 ? target.bottom + 10 : y) + 'px';
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
function hideTooltip() {
|
|
1178
|
+
if (tooltip !== null) tooltip.hidden = true;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/* ---------------------------------------------------------------
|
|
1182
|
+
Charts. One series each, so no legend box: the card title says
|
|
1183
|
+
what is plotted. Bars cap at 24px with a 2px surface gap and a
|
|
1184
|
+
4px rounded data-end, square where they meet the baseline.
|
|
1185
|
+
--------------------------------------------------------------- */
|
|
1186
|
+
|
|
1187
|
+
const MAX_BAR = 24;
|
|
1188
|
+
const GAP = 2;
|
|
1189
|
+
const CORNER = 4;
|
|
1190
|
+
|
|
1191
|
+
function roundedTopPath(x, y, width, height, radius) {
|
|
1192
|
+
const r = Math.max(0, Math.min(radius, width / 2, height));
|
|
1193
|
+
return (
|
|
1194
|
+
'M' +
|
|
1195
|
+
x +
|
|
1196
|
+
' ' +
|
|
1197
|
+
(y + height) +
|
|
1198
|
+
'V' +
|
|
1199
|
+
(y + r) +
|
|
1200
|
+
'a' +
|
|
1201
|
+
r +
|
|
1202
|
+
' ' +
|
|
1203
|
+
r +
|
|
1204
|
+
' 0 0 1 ' +
|
|
1205
|
+
r +
|
|
1206
|
+
' ' +
|
|
1207
|
+
-r +
|
|
1208
|
+
'h' +
|
|
1209
|
+
(width - 2 * r) +
|
|
1210
|
+
'a' +
|
|
1211
|
+
r +
|
|
1212
|
+
' ' +
|
|
1213
|
+
r +
|
|
1214
|
+
' 0 0 1 ' +
|
|
1215
|
+
r +
|
|
1216
|
+
' ' +
|
|
1217
|
+
r +
|
|
1218
|
+
'V' +
|
|
1219
|
+
(y + height) +
|
|
1220
|
+
'Z'
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function barChart(container, values, options) {
|
|
1225
|
+
if (container === null) return;
|
|
1226
|
+
container.replaceChildren();
|
|
1227
|
+
|
|
1228
|
+
const width = 480;
|
|
1229
|
+
const plotHeight = 92;
|
|
1230
|
+
const axisHeight = 18;
|
|
1231
|
+
const height = plotHeight + axisHeight;
|
|
1232
|
+
const peak = Math.max(1, ...values);
|
|
1233
|
+
const slot = width / values.length;
|
|
1234
|
+
const barWidth = Math.min(MAX_BAR, slot - GAP);
|
|
1235
|
+
|
|
1236
|
+
const svg = svgEl('svg', {
|
|
1237
|
+
viewBox: '0 0 ' + width + ' ' + height,
|
|
1238
|
+
role: 'img',
|
|
1239
|
+
'aria-label': options.ariaLabel ?? '',
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
// Baseline plus one recessive gridline at the peak: hairline, solid, never dashed.
|
|
1243
|
+
svg.appendChild(
|
|
1244
|
+
svgEl('line', { class: 'grid-line', x1: 0, y1: plotHeight + 0.5, x2: width, y2: plotHeight + 0.5 }),
|
|
1245
|
+
);
|
|
1246
|
+
svg.appendChild(svgEl('line', { class: 'grid-line', x1: 0, y1: 0.5, x2: width, y2: 0.5 }));
|
|
1247
|
+
|
|
1248
|
+
values.forEach((value, index) => {
|
|
1249
|
+
const barHeight = value === 0 ? 0 : Math.max(2, (value / peak) * plotHeight);
|
|
1250
|
+
const x = index * slot + (slot - barWidth) / 2;
|
|
1251
|
+
|
|
1252
|
+
// The hit target covers the whole slot, so a one-commit bar is still easy to reach.
|
|
1253
|
+
const hit = svgEl('rect', {
|
|
1254
|
+
class: 'bar-hit',
|
|
1255
|
+
x: index * slot,
|
|
1256
|
+
y: 0,
|
|
1257
|
+
width: slot,
|
|
1258
|
+
height: plotHeight,
|
|
1259
|
+
tabindex: 0,
|
|
1260
|
+
role: 'graphics-symbol',
|
|
1261
|
+
'aria-label': options.describe(index, value),
|
|
1262
|
+
});
|
|
1263
|
+
const readout = () => options.describe(index, value);
|
|
1264
|
+
const show = (event) => showTooltip(event, number(value), options.labelFor(index));
|
|
1265
|
+
hit.addEventListener('pointerenter', show);
|
|
1266
|
+
hit.addEventListener('focus', show);
|
|
1267
|
+
hit.addEventListener('pointerleave', hideTooltip);
|
|
1268
|
+
hit.addEventListener('blur', hideTooltip);
|
|
1269
|
+
hit.appendChild(svgEl('title', {})).textContent = readout();
|
|
1270
|
+
svg.appendChild(hit);
|
|
1271
|
+
|
|
1272
|
+
if (barHeight > 0) {
|
|
1273
|
+
svg.appendChild(
|
|
1274
|
+
svgEl('path', {
|
|
1275
|
+
class: 'bar',
|
|
1276
|
+
d: roundedTopPath(x, plotHeight - barHeight, barWidth, barHeight, CORNER),
|
|
1277
|
+
}),
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
(options.axisTicks ?? []).forEach((tick) => {
|
|
1283
|
+
const label = svgEl('text', {
|
|
1284
|
+
class: 'axis-label',
|
|
1285
|
+
x: tick.index * slot + slot / 2,
|
|
1286
|
+
y: height - 5,
|
|
1287
|
+
'text-anchor': 'middle',
|
|
1288
|
+
});
|
|
1289
|
+
label.textContent = tick.label;
|
|
1290
|
+
svg.appendChild(label);
|
|
1291
|
+
});
|
|
1292
|
+
|
|
1293
|
+
container.appendChild(svg);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
function trendChart(container, points, options) {
|
|
1297
|
+
if (container === null || points.length === 0) return;
|
|
1298
|
+
container.replaceChildren();
|
|
1299
|
+
|
|
1300
|
+
const width = 480;
|
|
1301
|
+
const plotHeight = 100;
|
|
1302
|
+
const axisHeight = 18;
|
|
1303
|
+
const height = plotHeight + axisHeight;
|
|
1304
|
+
const peak = Math.max(1, ...points.map((point) => point.value));
|
|
1305
|
+
const step = points.length === 1 ? 0 : width / (points.length - 1);
|
|
1306
|
+
const xOf = (index) => (points.length === 1 ? width / 2 : index * step);
|
|
1307
|
+
const yOf = (value) => plotHeight - (value / peak) * (plotHeight - 6);
|
|
1308
|
+
|
|
1309
|
+
const svg = svgEl('svg', {
|
|
1310
|
+
viewBox: '0 0 ' + width + ' ' + height,
|
|
1311
|
+
role: 'img',
|
|
1312
|
+
'aria-label': options.ariaLabel ?? '',
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
svg.appendChild(
|
|
1316
|
+
svgEl('line', { class: 'grid-line', x1: 0, y1: plotHeight + 0.5, x2: width, y2: plotHeight + 0.5 }),
|
|
1317
|
+
);
|
|
1318
|
+
svg.appendChild(svgEl('line', { class: 'grid-line', x1: 0, y1: 0.5, x2: width, y2: 0.5 }));
|
|
1319
|
+
|
|
1320
|
+
const line = points.map((point, index) => xOf(index) + ' ' + yOf(point.value)).join(' L');
|
|
1321
|
+
svg.appendChild(
|
|
1322
|
+
svgEl('path', {
|
|
1323
|
+
class: 'trend-area',
|
|
1324
|
+
d: 'M' + line + 'L' + xOf(points.length - 1) + ' ' + plotHeight + 'L0 ' + plotHeight + 'Z',
|
|
1325
|
+
}),
|
|
1326
|
+
);
|
|
1327
|
+
svg.appendChild(svgEl('path', { class: 'trend-line', d: 'M' + line }));
|
|
1328
|
+
|
|
1329
|
+
const crosshair = svgEl('line', { class: 'crosshair', x1: 0, y1: 0, x2: 0, y2: plotHeight });
|
|
1330
|
+
crosshair.setAttribute('visibility', 'hidden');
|
|
1331
|
+
svg.appendChild(crosshair);
|
|
1332
|
+
|
|
1333
|
+
const dot = svgEl('circle', { class: 'trend-dot', r: 4.5, cx: 0, cy: 0 });
|
|
1334
|
+
dot.setAttribute('visibility', 'hidden');
|
|
1335
|
+
svg.appendChild(dot);
|
|
1336
|
+
|
|
1337
|
+
// The crosshair snaps to the nearest point, so the reader aims at a month, not at a line.
|
|
1338
|
+
points.forEach((point, index) => {
|
|
1339
|
+
const hit = svgEl('rect', {
|
|
1340
|
+
class: 'bar-hit',
|
|
1341
|
+
x: xOf(index) - (step || width) / 2,
|
|
1342
|
+
y: 0,
|
|
1343
|
+
width: step || width,
|
|
1344
|
+
height: plotHeight,
|
|
1345
|
+
tabindex: 0,
|
|
1346
|
+
role: 'graphics-symbol',
|
|
1347
|
+
'aria-label': options.describe(point),
|
|
1348
|
+
});
|
|
1349
|
+
const show = (event) => {
|
|
1350
|
+
crosshair.setAttribute('x1', String(xOf(index)));
|
|
1351
|
+
crosshair.setAttribute('x2', String(xOf(index)));
|
|
1352
|
+
crosshair.setAttribute('visibility', 'visible');
|
|
1353
|
+
dot.setAttribute('cx', String(xOf(index)));
|
|
1354
|
+
dot.setAttribute('cy', String(yOf(point.value)));
|
|
1355
|
+
dot.setAttribute('visibility', 'visible');
|
|
1356
|
+
showTooltip(event, number(point.value), options.labelFor(point));
|
|
1357
|
+
};
|
|
1358
|
+
const hide = () => {
|
|
1359
|
+
crosshair.setAttribute('visibility', 'hidden');
|
|
1360
|
+
dot.setAttribute('visibility', 'hidden');
|
|
1361
|
+
hideTooltip();
|
|
1362
|
+
};
|
|
1363
|
+
hit.addEventListener('pointerenter', show);
|
|
1364
|
+
hit.addEventListener('focus', show);
|
|
1365
|
+
hit.addEventListener('pointerleave', hide);
|
|
1366
|
+
hit.addEventListener('blur', hide);
|
|
1367
|
+
hit.appendChild(svgEl('title', {})).textContent = options.describe(point);
|
|
1368
|
+
svg.appendChild(hit);
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
// Only the ends are labelled: a value on every point is chaos and goes unread.
|
|
1372
|
+
[0, points.length - 1].forEach((index, position) => {
|
|
1373
|
+
if (points.length === 1 && position === 1) return;
|
|
1374
|
+
const label = svgEl('text', {
|
|
1375
|
+
class: 'axis-label',
|
|
1376
|
+
x: xOf(index),
|
|
1377
|
+
y: height - 5,
|
|
1378
|
+
'text-anchor': position === 0 ? 'start' : 'end',
|
|
1379
|
+
});
|
|
1380
|
+
label.textContent = options.labelFor(points[index]);
|
|
1381
|
+
svg.appendChild(label);
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
container.appendChild(svg);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
/* ---------------------------------------------------------------
|
|
1388
|
+
Sections
|
|
1389
|
+
--------------------------------------------------------------- */
|
|
1390
|
+
|
|
1391
|
+
const report = data.report ?? {};
|
|
1392
|
+
const categories = strings.categories ?? {};
|
|
1393
|
+
const pulseStrings = strings.pulse ?? {};
|
|
1394
|
+
const labels = pulseStrings.labels ?? {};
|
|
1395
|
+
const units = strings.units ?? {};
|
|
1396
|
+
|
|
1397
|
+
const categoryColor = (id) => 'var(--cat-' + String(id).replace(/[^a-z-]/g, '') + ')';
|
|
1398
|
+
const categoryLabel = (id) => (categories[id] ?? {}).label ?? id;
|
|
1399
|
+
const categoryIcon = (id) => (categories[id] ?? {}).icon ?? '•';
|
|
1400
|
+
|
|
1401
|
+
function unit(count, key) {
|
|
1402
|
+
const forms = units[key] ?? {};
|
|
1403
|
+
const word = count === 1 ? forms.one : forms.other;
|
|
1404
|
+
return fill(units.format ?? '{n} {unit}', { n: number(count), unit: word ?? '' });
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
function renderHeader() {
|
|
1408
|
+
$('project-name').textContent = report.project.name;
|
|
1409
|
+
$('subtitle').textContent = fill(ui.subtitle, {
|
|
1410
|
+
days: number(report.range.days),
|
|
1411
|
+
commits: number(report.totals.commits),
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
const dedication = report.project.dedication;
|
|
1415
|
+
if (typeof dedication === 'string' && dedication.trim() !== '') {
|
|
1416
|
+
$('dedication').textContent = dedication.trim();
|
|
1417
|
+
$('dedication').hidden = false;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
$('theme-toggle').textContent = ui.themeToggle ?? 'Theme';
|
|
1421
|
+
$('pulse-title').textContent = pulseStrings.title ?? '';
|
|
1422
|
+
$('pulse-narrative').textContent = report.pulse.narrative;
|
|
1423
|
+
$('timeline-title').textContent = ui.timelineTitle ?? '';
|
|
1424
|
+
$('milestones-title').textContent = categoryLabel('milestone');
|
|
1425
|
+
$('mix-title').textContent = ui.filterByCategory ?? '';
|
|
1426
|
+
$('table-summary').textContent = ui.dataTable ?? '';
|
|
1427
|
+
$('hour-title').textContent = labels.hourDistribution ?? '';
|
|
1428
|
+
$('weekday-title').textContent = labels.weekdayDistribution ?? '';
|
|
1429
|
+
$('monthly-title').textContent = labels.monthlyActivity ?? '';
|
|
1430
|
+
$('search').placeholder = ui.searchPlaceholder ?? '';
|
|
1431
|
+
$('no-results').textContent = ui.noResults ?? '';
|
|
1432
|
+
$('footer-generator').textContent = fill(ui.generatedBy, {
|
|
1433
|
+
version: report.generator.version,
|
|
1434
|
+
});
|
|
1435
|
+
$('footer-offline').textContent = ui.offlineNote ?? '';
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function renderTiles() {
|
|
1439
|
+
const pulse = report.pulse;
|
|
1440
|
+
const chronotype = (pulseStrings.chronotypes ?? {})[pulse.chronotype] ?? {};
|
|
1441
|
+
const weekdays = locale.weekdays ?? [];
|
|
1442
|
+
|
|
1443
|
+
const tiles = [
|
|
1444
|
+
{ label: labels.totalCommits, value: number(report.totals.commits) },
|
|
1445
|
+
{ label: labels.totalAuthors, value: number(report.totals.authors) },
|
|
1446
|
+
{ label: labels.projectAge, value: number(report.range.days), unit: ui.daysLabel },
|
|
1447
|
+
{ label: labels.filesTouched, value: number(report.totals.filesTouched) },
|
|
1448
|
+
{
|
|
1449
|
+
label: labels.chronotype,
|
|
1450
|
+
value: (chronotype.icon ?? '') + ' ' + pulse.chronotypeLabel,
|
|
1451
|
+
worded: true,
|
|
1452
|
+
},
|
|
1453
|
+
{ label: labels.busiestHour, value: String(pulse.busiestHour).padStart(2, '0') + ':00' },
|
|
1454
|
+
{ label: labels.busiestDay, value: weekdays[pulse.busiestWeekday] ?? '', worded: true },
|
|
1455
|
+
{ label: labels.creationRatio, value: Math.round(pulse.creationRatio * 100) + '%' },
|
|
1456
|
+
{
|
|
1457
|
+
label: labels.longestStreak,
|
|
1458
|
+
value: number(pulse.longestStreak.days),
|
|
1459
|
+
unit: pulse.longestStreak.days > 0 ? ui.daysLabel : null,
|
|
1460
|
+
},
|
|
1461
|
+
];
|
|
1462
|
+
|
|
1463
|
+
const container = $('tiles');
|
|
1464
|
+
container.replaceChildren();
|
|
1465
|
+
|
|
1466
|
+
for (const spec of tiles) {
|
|
1467
|
+
const tile = el('div', 'tile');
|
|
1468
|
+
tile.appendChild(el('span', 'label', spec.label ?? ''));
|
|
1469
|
+
const valueNode = el('span', spec.worded === true ? 'value worded' : 'value', spec.value);
|
|
1470
|
+
if (spec.unit !== null && spec.unit !== undefined) {
|
|
1471
|
+
valueNode.appendChild(el('span', 'unit', spec.unit));
|
|
1472
|
+
}
|
|
1473
|
+
tile.appendChild(valueNode);
|
|
1474
|
+
container.appendChild(tile);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
function renderCharts() {
|
|
1479
|
+
const pulse = report.pulse;
|
|
1480
|
+
const weekdays = locale.weekdays ?? [];
|
|
1481
|
+
const shortDays = locale.weekdaysShort ?? weekdays;
|
|
1482
|
+
|
|
1483
|
+
barChart($('hour-chart'), pulse.hourHistogram, {
|
|
1484
|
+
ariaLabel: labels.hourDistribution ?? '',
|
|
1485
|
+
labelFor: (index) => String(index).padStart(2, '0') + ':00',
|
|
1486
|
+
describe: (index, value) => String(index).padStart(2, '0') + ':00 — ' + unit(value, 'commit'),
|
|
1487
|
+
axisTicks: [0, 3, 6, 9, 12, 15, 18, 21].map((hour) => ({
|
|
1488
|
+
index: hour,
|
|
1489
|
+
label: String(hour),
|
|
1490
|
+
})),
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1493
|
+
barChart($('weekday-chart'), pulse.weekdayHistogram, {
|
|
1494
|
+
ariaLabel: labels.weekdayDistribution ?? '',
|
|
1495
|
+
labelFor: (index) => weekdays[index] ?? '',
|
|
1496
|
+
describe: (index, value) => (weekdays[index] ?? '') + ' — ' + unit(value, 'commit'),
|
|
1497
|
+
axisTicks: shortDays.map((day, index) => ({ index, label: day })),
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
const monthly = pulse.monthlyActivity ?? [];
|
|
1501
|
+
if (monthly.length < 2) {
|
|
1502
|
+
$('monthly-card').hidden = true;
|
|
1503
|
+
} else {
|
|
1504
|
+
trendChart(
|
|
1505
|
+
$('monthly-chart'),
|
|
1506
|
+
monthly.map((month) => ({ key: month.month, value: month.commits })),
|
|
1507
|
+
{
|
|
1508
|
+
ariaLabel: labels.monthlyActivity ?? '',
|
|
1509
|
+
labelFor: (point) => formatMonth(point.key),
|
|
1510
|
+
describe: (point) => formatMonth(point.key) + ' — ' + unit(point.value, 'commit'),
|
|
1511
|
+
},
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* The category mix, as one segmented bar.
|
|
1518
|
+
*
|
|
1519
|
+
* Every segment carries a 2px surface gap, and the legend below prints each name, icon and
|
|
1520
|
+
* count — so identity never rests on colour alone. Two of the light-mode hues sit below 3:1
|
|
1521
|
+
* against the surface, which is exactly the case the visible labels are there to relieve.
|
|
1522
|
+
*/
|
|
1523
|
+
function renderCategoryMix() {
|
|
1524
|
+
const byCategory = report.totals.byCategory ?? {};
|
|
1525
|
+
const present = Object.keys(byCategory).filter((id) => byCategory[id] > 0);
|
|
1526
|
+
const total = present.reduce((sum, id) => sum + byCategory[id], 0);
|
|
1527
|
+
|
|
1528
|
+
const strip = $('category-strip');
|
|
1529
|
+
const legend = $('category-legend');
|
|
1530
|
+
strip.replaceChildren();
|
|
1531
|
+
legend.replaceChildren();
|
|
1532
|
+
|
|
1533
|
+
strip.setAttribute(
|
|
1534
|
+
'aria-label',
|
|
1535
|
+
present.map((id) => categoryLabel(id) + ': ' + byCategory[id]).join(', '),
|
|
1536
|
+
);
|
|
1537
|
+
|
|
1538
|
+
for (const id of present) {
|
|
1539
|
+
const segment = el('span');
|
|
1540
|
+
segment.style.background = categoryColor(id);
|
|
1541
|
+
segment.style.flexGrow = String(byCategory[id]);
|
|
1542
|
+
segment.title = categoryLabel(id) + ' — ' + unit(byCategory[id], 'commit');
|
|
1543
|
+
strip.appendChild(segment);
|
|
1544
|
+
|
|
1545
|
+
const item = el('span');
|
|
1546
|
+
const swatch = el('span', 'swatch');
|
|
1547
|
+
swatch.style.background = categoryColor(id);
|
|
1548
|
+
item.appendChild(swatch);
|
|
1549
|
+
item.appendChild(document.createTextNode(categoryIcon(id) + ' ' + categoryLabel(id) + ' '));
|
|
1550
|
+
item.appendChild(el('b', null, number(byCategory[id])));
|
|
1551
|
+
if (total > 0) {
|
|
1552
|
+
item.appendChild(
|
|
1553
|
+
document.createTextNode(' (' + Math.round((byCategory[id] / total) * 100) + '%)'),
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
legend.appendChild(item);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/** The table view: the relief for low-contrast hues, and the version a screen reader reads. */
|
|
1561
|
+
function renderTables() {
|
|
1562
|
+
const container = $('tables');
|
|
1563
|
+
container.replaceChildren();
|
|
1564
|
+
|
|
1565
|
+
const table = (heading, columns, rows) => {
|
|
1566
|
+
container.appendChild(el('p', 'chart-title', heading));
|
|
1567
|
+
const node = el('table');
|
|
1568
|
+
const head = el('tr');
|
|
1569
|
+
for (const column of columns) head.appendChild(el('th', null, column));
|
|
1570
|
+
node.appendChild(el('thead')).appendChild(head);
|
|
1571
|
+
const body = el('tbody');
|
|
1572
|
+
for (const row of rows) {
|
|
1573
|
+
const tr = el('tr');
|
|
1574
|
+
row.forEach((cell, index) => {
|
|
1575
|
+
tr.appendChild(el('td', index === 0 ? null : 'num', cell));
|
|
1576
|
+
});
|
|
1577
|
+
body.appendChild(tr);
|
|
1578
|
+
}
|
|
1579
|
+
node.appendChild(body);
|
|
1580
|
+
container.appendChild(node);
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
const commitsLabel = ui.commitsLabel ?? '';
|
|
1584
|
+
const weekdays = locale.weekdays ?? [];
|
|
1585
|
+
|
|
1586
|
+
table(
|
|
1587
|
+
labels.hourDistribution ?? '',
|
|
1588
|
+
[labels.busiestHour ?? '', commitsLabel],
|
|
1589
|
+
report.pulse.hourHistogram
|
|
1590
|
+
.map((value, hour) => [String(hour).padStart(2, '0') + ':00', number(value)])
|
|
1591
|
+
.filter((row, hour) => report.pulse.hourHistogram[hour] > 0),
|
|
1592
|
+
);
|
|
1593
|
+
|
|
1594
|
+
table(
|
|
1595
|
+
labels.weekdayDistribution ?? '',
|
|
1596
|
+
[labels.busiestDay ?? '', commitsLabel],
|
|
1597
|
+
report.pulse.weekdayHistogram.map((value, index) => [weekdays[index] ?? '', number(value)]),
|
|
1598
|
+
);
|
|
1599
|
+
|
|
1600
|
+
const monthly = report.pulse.monthlyActivity ?? [];
|
|
1601
|
+
if (monthly.length > 0) {
|
|
1602
|
+
table(
|
|
1603
|
+
labels.monthlyActivity ?? '',
|
|
1604
|
+
[labels.monthlyActivity ?? '', commitsLabel, ui.insertionsLabel ?? '+', ui.deletionsLabel ?? '-'],
|
|
1605
|
+
monthly.map((month) => [
|
|
1606
|
+
formatMonth(month.month),
|
|
1607
|
+
number(month.commits),
|
|
1608
|
+
number(month.insertions),
|
|
1609
|
+
number(month.deletions),
|
|
1610
|
+
]),
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
function renderMilestones() {
|
|
1616
|
+
const milestones = report.milestones ?? [];
|
|
1617
|
+
if (milestones.length === 0) return;
|
|
1618
|
+
|
|
1619
|
+
const container = $('milestones');
|
|
1620
|
+
container.replaceChildren();
|
|
1621
|
+
|
|
1622
|
+
for (const milestone of milestones) {
|
|
1623
|
+
const row = el('div', 'milestone');
|
|
1624
|
+
const time = el('time', null, formatDate(milestone.at));
|
|
1625
|
+
time.setAttribute('datetime', milestone.at);
|
|
1626
|
+
row.appendChild(time);
|
|
1627
|
+
row.appendChild(el('span', 'what', milestone.narrative));
|
|
1628
|
+
if (milestone.label !== null && milestone.label !== undefined && milestone.label !== '') {
|
|
1629
|
+
row.appendChild(el('span', 'badge', milestone.label));
|
|
1630
|
+
}
|
|
1631
|
+
container.appendChild(row);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
$('milestones-section').hidden = false;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
/* ---------------------------------------------------------------
|
|
1638
|
+
Timeline and filters
|
|
1639
|
+
--------------------------------------------------------------- */
|
|
1640
|
+
|
|
1641
|
+
const entriesBySha = new Map((report.entries ?? []).map((entry) => [entry.sha, entry]));
|
|
1642
|
+
const authorsById = new Map((report.authors ?? []).map((author) => [author.id, author]));
|
|
1643
|
+
const rendered = [];
|
|
1644
|
+
|
|
1645
|
+
function renderTimeline() {
|
|
1646
|
+
const container = $('timeline');
|
|
1647
|
+
container.replaceChildren();
|
|
1648
|
+
rendered.length = 0;
|
|
1649
|
+
|
|
1650
|
+
for (const chapter of report.chapters ?? []) {
|
|
1651
|
+
const article = el('article', 'chapter');
|
|
1652
|
+
article.style.setProperty('--chapter-color', categoryColor(chapter.category));
|
|
1653
|
+
|
|
1654
|
+
const mark = el('div', 'chapter-mark', categoryIcon(chapter.category));
|
|
1655
|
+
mark.setAttribute('aria-hidden', 'true');
|
|
1656
|
+
article.appendChild(mark);
|
|
1657
|
+
|
|
1658
|
+
article.appendChild(el('h3', null, chapter.title));
|
|
1659
|
+
|
|
1660
|
+
const from = formatDate(chapter.from, true);
|
|
1661
|
+
const to = formatDate(chapter.to);
|
|
1662
|
+
article.appendChild(
|
|
1663
|
+
el(
|
|
1664
|
+
'p',
|
|
1665
|
+
'meta',
|
|
1666
|
+
(from === formatDate(chapter.to, true) ? to : from + ' – ' + to) +
|
|
1667
|
+
' · ' +
|
|
1668
|
+
fill(ui.chapterCommits, { commits: number(chapter.stats.commits) }),
|
|
1669
|
+
),
|
|
1670
|
+
);
|
|
1671
|
+
|
|
1672
|
+
article.appendChild(el('p', 'summary', chapter.narrative));
|
|
1673
|
+
|
|
1674
|
+
const list = el('div', 'entries');
|
|
1675
|
+
for (const sha of chapter.entryShas) {
|
|
1676
|
+
const entry = entriesBySha.get(sha);
|
|
1677
|
+
if (entry === undefined) continue;
|
|
1678
|
+
const node = renderEntry(entry);
|
|
1679
|
+
list.appendChild(node);
|
|
1680
|
+
rendered.push({ entry, node, chapter: article });
|
|
1681
|
+
}
|
|
1682
|
+
article.appendChild(list);
|
|
1683
|
+
container.appendChild(article);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
function renderEntry(entry) {
|
|
1688
|
+
const node = el('div', 'entry');
|
|
1689
|
+
node.style.setProperty('--entry-color', categoryColor(entry.category));
|
|
1690
|
+
|
|
1691
|
+
const narrative = el('p', 'narrative');
|
|
1692
|
+
narrative.textContent = entry.narrative;
|
|
1693
|
+
node.appendChild(narrative);
|
|
1694
|
+
|
|
1695
|
+
const facts = el('div', 'facts');
|
|
1696
|
+
const author = authorsById.get(entry.authorId);
|
|
1697
|
+
|
|
1698
|
+
const when = el(
|
|
1699
|
+
'span',
|
|
1700
|
+
null,
|
|
1701
|
+
formatDate(entry.authoredAt, true) + ' ' + formatTime(entry.authoredAt),
|
|
1702
|
+
);
|
|
1703
|
+
facts.appendChild(when);
|
|
1704
|
+
facts.appendChild(el('code', null, entry.shortSha));
|
|
1705
|
+
if (author !== undefined) facts.appendChild(el('span', null, author.displayName));
|
|
1706
|
+
facts.appendChild(el('span', null, unit(entry.stats.filesCount, 'file')));
|
|
1707
|
+
// A commit that deleted nothing says nothing about deletions; "−0" is ink without content.
|
|
1708
|
+
if (entry.stats.insertions > 0) {
|
|
1709
|
+
facts.appendChild(el('span', 'added', '+' + number(entry.stats.insertions)));
|
|
1710
|
+
}
|
|
1711
|
+
if (entry.stats.deletions > 0) {
|
|
1712
|
+
facts.appendChild(el('span', 'removed', '−' + number(entry.stats.deletions)));
|
|
1713
|
+
}
|
|
1714
|
+
for (const tag of entry.tags ?? []) facts.appendChild(el('span', 'tag', tag));
|
|
1715
|
+
|
|
1716
|
+
node.appendChild(facts);
|
|
1717
|
+
return node;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
const filters = { search: '', author: '', year: '', categories: new Set() };
|
|
1721
|
+
|
|
1722
|
+
function buildFilterControls() {
|
|
1723
|
+
const authorSelect = $('author-filter');
|
|
1724
|
+
authorSelect.replaceChildren();
|
|
1725
|
+
authorSelect.appendChild(el('option', null, ui.filterByAuthor ?? '')).value = '';
|
|
1726
|
+
for (const author of report.authors ?? []) {
|
|
1727
|
+
authorSelect.appendChild(el('option', null, author.displayName)).value = author.id;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
const years = [
|
|
1731
|
+
...new Set((report.entries ?? []).map((entry) => entry.authoredAt.slice(0, 4))),
|
|
1732
|
+
].sort();
|
|
1733
|
+
const yearSelect = $('year-filter');
|
|
1734
|
+
yearSelect.replaceChildren();
|
|
1735
|
+
yearSelect.appendChild(el('option', null, ui.filterByYear ?? '')).value = '';
|
|
1736
|
+
for (const year of years) yearSelect.appendChild(el('option', null, year)).value = year;
|
|
1737
|
+
yearSelect.hidden = years.length < 2;
|
|
1738
|
+
|
|
1739
|
+
const chips = $('category-chips');
|
|
1740
|
+
chips.replaceChildren();
|
|
1741
|
+
const present = Object.keys(report.totals.byCategory ?? {}).filter(
|
|
1742
|
+
(id) => report.totals.byCategory[id] > 0,
|
|
1743
|
+
);
|
|
1744
|
+
for (const id of present) {
|
|
1745
|
+
filters.categories.add(id);
|
|
1746
|
+
const chip = el('button', 'chip');
|
|
1747
|
+
chip.type = 'button';
|
|
1748
|
+
chip.setAttribute('aria-pressed', 'true');
|
|
1749
|
+
chip.style.setProperty('--chip-color', categoryColor(id));
|
|
1750
|
+
const dot = el('span', 'dot');
|
|
1751
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
1752
|
+
chip.appendChild(dot);
|
|
1753
|
+
chip.appendChild(document.createTextNode(categoryLabel(id)));
|
|
1754
|
+
chip.addEventListener('click', () => {
|
|
1755
|
+
if (filters.categories.has(id)) {
|
|
1756
|
+
filters.categories.delete(id);
|
|
1757
|
+
chip.setAttribute('aria-pressed', 'false');
|
|
1758
|
+
} else {
|
|
1759
|
+
filters.categories.add(id);
|
|
1760
|
+
chip.setAttribute('aria-pressed', 'true');
|
|
1761
|
+
}
|
|
1762
|
+
applyFilters();
|
|
1763
|
+
});
|
|
1764
|
+
chips.appendChild(chip);
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
$('search').addEventListener('input', (event) => {
|
|
1768
|
+
filters.search = event.target.value.trim();
|
|
1769
|
+
applyFilters();
|
|
1770
|
+
});
|
|
1771
|
+
authorSelect.addEventListener('change', (event) => {
|
|
1772
|
+
filters.author = event.target.value;
|
|
1773
|
+
applyFilters();
|
|
1774
|
+
});
|
|
1775
|
+
yearSelect.addEventListener('change', (event) => {
|
|
1776
|
+
filters.year = event.target.value;
|
|
1777
|
+
applyFilters();
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
function matches(entry) {
|
|
1782
|
+
if (!filters.categories.has(entry.category)) return false;
|
|
1783
|
+
if (filters.author !== '' && entry.authorId !== filters.author) return false;
|
|
1784
|
+
if (filters.year !== '' && !entry.authoredAt.startsWith(filters.year)) return false;
|
|
1785
|
+
|
|
1786
|
+
if (filters.search !== '') {
|
|
1787
|
+
const needle = filters.search.toLowerCase();
|
|
1788
|
+
const author = authorsById.get(entry.authorId);
|
|
1789
|
+
const haystack = [
|
|
1790
|
+
entry.narrative,
|
|
1791
|
+
entry.cleanSubject,
|
|
1792
|
+
entry.subject,
|
|
1793
|
+
entry.shortSha,
|
|
1794
|
+
author === undefined ? '' : author.displayName,
|
|
1795
|
+
(entry.tags ?? []).join(' '),
|
|
1796
|
+
]
|
|
1797
|
+
.join(' ')
|
|
1798
|
+
.toLowerCase();
|
|
1799
|
+
if (!haystack.includes(needle)) return false;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
return true;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
function applyFilters() {
|
|
1806
|
+
let visible = 0;
|
|
1807
|
+
const chaptersWithContent = new Set();
|
|
1808
|
+
|
|
1809
|
+
for (const item of rendered) {
|
|
1810
|
+
const show = matches(item.entry);
|
|
1811
|
+
item.node.hidden = !show;
|
|
1812
|
+
if (show) {
|
|
1813
|
+
visible += 1;
|
|
1814
|
+
chaptersWithContent.add(item.chapter);
|
|
1815
|
+
|
|
1816
|
+
// Re-render the narrative so the search term is highlighted — built from text nodes,
|
|
1817
|
+
// never from an HTML string, because the narrative quotes a commit message.
|
|
1818
|
+
const narrative = item.node.querySelector('.narrative');
|
|
1819
|
+
narrative.replaceChildren();
|
|
1820
|
+
appendHighlighted(narrative, item.entry.narrative, filters.search);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
for (const chapter of document.querySelectorAll('.chapter')) {
|
|
1825
|
+
chapter.hidden = !chaptersWithContent.has(chapter);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
$('result-count').textContent = fill(ui.chapterCommits, { commits: number(visible) });
|
|
1829
|
+
$('no-results').hidden = visible > 0;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/* ---------------------------------------------------------------
|
|
1833
|
+
The time capsule.
|
|
1834
|
+
|
|
1835
|
+
The countdown is a ritual; the passphrase is the lock. This file
|
|
1836
|
+
can be published and the message stays unreadable without it,
|
|
1837
|
+
which is why there is no passphrase-free mode to offer here.
|
|
1838
|
+
--------------------------------------------------------------- */
|
|
1839
|
+
|
|
1840
|
+
function base64ToBytes(value) {
|
|
1841
|
+
const binary = atob(String(value));
|
|
1842
|
+
const bytes = new Uint8Array(binary.length);
|
|
1843
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
1844
|
+
return bytes;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
function renderCapsule() {
|
|
1848
|
+
const capsule = report.capsule;
|
|
1849
|
+
if (capsule === null || capsule === undefined) return;
|
|
1850
|
+
|
|
1851
|
+
const section = $('capsule-section');
|
|
1852
|
+
section.hidden = false;
|
|
1853
|
+
|
|
1854
|
+
$('capsule-title').textContent = ui.capsuleTitle ?? '';
|
|
1855
|
+
$('capsule-disclaimer').textContent = ui.capsuleDisclaimer ?? '';
|
|
1856
|
+
$('capsule-label').textContent = ui.capsulePassphrasePrompt ?? '';
|
|
1857
|
+
$('capsule-passphrase').placeholder = ui.capsulePassphrasePrompt ?? '';
|
|
1858
|
+
$('capsule-submit').textContent = ui.capsulePassphraseButton ?? '';
|
|
1859
|
+
|
|
1860
|
+
if (typeof capsule.authorLabel === 'string' && capsule.authorLabel !== '') {
|
|
1861
|
+
$('capsule-author').textContent = fill(ui.capsuleAuthor, { author: capsule.authorLabel });
|
|
1862
|
+
}
|
|
1863
|
+
if (typeof capsule.hint === 'string' && capsule.hint !== '') {
|
|
1864
|
+
$('capsule-hint').textContent = fill(ui.capsuleHint, { hint: capsule.hint });
|
|
1865
|
+
$('capsule-hint').hidden = false;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
const unlockAt = new Date(capsule.unlockDate + 'T00:00:00');
|
|
1869
|
+
const form = $('capsule-form');
|
|
1870
|
+
const status = $('capsule-status');
|
|
1871
|
+
const countdown = $('capsule-countdown');
|
|
1872
|
+
let timer = null;
|
|
1873
|
+
|
|
1874
|
+
const stopCountdown = () => {
|
|
1875
|
+
if (timer !== null) {
|
|
1876
|
+
window.clearInterval(timer);
|
|
1877
|
+
timer = null;
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
const tick = () => {
|
|
1882
|
+
const remaining = unlockAt.getTime() - Date.now();
|
|
1883
|
+
|
|
1884
|
+
if (remaining <= 0) {
|
|
1885
|
+
countdown.textContent = '';
|
|
1886
|
+
status.textContent = ui.capsuleUnlockable ?? '';
|
|
1887
|
+
form.hidden = false;
|
|
1888
|
+
return true;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
const minutes = Math.floor(remaining / 60000);
|
|
1892
|
+
countdown.textContent = fill(ui.capsuleCountdown, {
|
|
1893
|
+
days: Math.floor(minutes / 1440),
|
|
1894
|
+
hours: Math.floor((minutes % 1440) / 60),
|
|
1895
|
+
minutes: minutes % 60,
|
|
1896
|
+
});
|
|
1897
|
+
status.textContent = fill(ui.capsuleLocked, {
|
|
1898
|
+
unlockDate: formatDate(capsule.unlockDate + 'T00:00:00+00:00'),
|
|
1899
|
+
});
|
|
1900
|
+
return false;
|
|
1901
|
+
};
|
|
1902
|
+
|
|
1903
|
+
if (!tick()) {
|
|
1904
|
+
timer = window.setInterval(() => {
|
|
1905
|
+
if (tick()) stopCountdown();
|
|
1906
|
+
}, 1000);
|
|
1907
|
+
|
|
1908
|
+
// The date is presentational, and saying so is the honest thing to do: anyone can change
|
|
1909
|
+
// their clock. Offer the form to whoever already holds the passphrase.
|
|
1910
|
+
const early = el('details');
|
|
1911
|
+
early.appendChild(el('summary', null, ui.capsuleOpenEarly ?? ''));
|
|
1912
|
+
early.appendChild(form);
|
|
1913
|
+
form.hidden = false;
|
|
1914
|
+
$('capsule-hint').after(early);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
form.addEventListener('submit', async (event) => {
|
|
1918
|
+
event.preventDefault();
|
|
1919
|
+
const error = $('capsule-error');
|
|
1920
|
+
error.textContent = '';
|
|
1921
|
+
|
|
1922
|
+
if (window.crypto === undefined || window.crypto.subtle === undefined) {
|
|
1923
|
+
error.textContent = ui.capsuleNoCrypto ?? '';
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
const passphrase = $('capsule-passphrase').value;
|
|
1928
|
+
const submit = $('capsule-submit');
|
|
1929
|
+
submit.disabled = true;
|
|
1930
|
+
|
|
1931
|
+
try {
|
|
1932
|
+
const encoder = new TextEncoder();
|
|
1933
|
+
const material = await crypto.subtle.importKey(
|
|
1934
|
+
'raw',
|
|
1935
|
+
encoder.encode(passphrase),
|
|
1936
|
+
'PBKDF2',
|
|
1937
|
+
false,
|
|
1938
|
+
['deriveKey'],
|
|
1939
|
+
);
|
|
1940
|
+
const key = await crypto.subtle.deriveKey(
|
|
1941
|
+
{
|
|
1942
|
+
name: 'PBKDF2',
|
|
1943
|
+
salt: base64ToBytes(capsule.salt),
|
|
1944
|
+
iterations: capsule.algorithm.iterations,
|
|
1945
|
+
hash: capsule.algorithm.kdfHash,
|
|
1946
|
+
},
|
|
1947
|
+
material,
|
|
1948
|
+
{ name: 'AES-GCM', length: 256 },
|
|
1949
|
+
false,
|
|
1950
|
+
['decrypt'],
|
|
1951
|
+
);
|
|
1952
|
+
const plaintext = await crypto.subtle.decrypt(
|
|
1953
|
+
{
|
|
1954
|
+
name: 'AES-GCM',
|
|
1955
|
+
iv: base64ToBytes(capsule.iv),
|
|
1956
|
+
additionalData: encoder.encode(
|
|
1957
|
+
fill((strings.crypto ?? {}).additionalDataFormat, {
|
|
1958
|
+
unlockDate: capsule.unlockDate,
|
|
1959
|
+
}),
|
|
1960
|
+
),
|
|
1961
|
+
tagLength: capsule.algorithm.authTagBits ?? 128,
|
|
1962
|
+
},
|
|
1963
|
+
key,
|
|
1964
|
+
base64ToBytes(capsule.ciphertext),
|
|
1965
|
+
);
|
|
1966
|
+
|
|
1967
|
+
// The countdown has done its job; leaving the interval running would paint the
|
|
1968
|
+
// remaining time back over a capsule that is already open.
|
|
1969
|
+
stopCountdown();
|
|
1970
|
+
|
|
1971
|
+
const message = $('capsule-message');
|
|
1972
|
+
message.textContent = new TextDecoder().decode(plaintext);
|
|
1973
|
+
message.hidden = false;
|
|
1974
|
+
form.hidden = true;
|
|
1975
|
+
countdown.textContent = '';
|
|
1976
|
+
status.textContent = '';
|
|
1977
|
+
$('capsule-hint').hidden = true;
|
|
1978
|
+
} catch (failure) {
|
|
1979
|
+
// AES-GCM authentication failing is indistinguishable from a wrong passphrase, which
|
|
1980
|
+
// is the property that makes it worth using. Say the one thing that is true.
|
|
1981
|
+
error.textContent = ui.capsuleWrongPassphrase ?? '';
|
|
1982
|
+
} finally {
|
|
1983
|
+
submit.disabled = false;
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
/* ---------------------------------------------------------------
|
|
1989
|
+
Boot
|
|
1990
|
+
--------------------------------------------------------------- */
|
|
1991
|
+
|
|
1992
|
+
applyTheme(resolvedTheme());
|
|
1993
|
+
|
|
1994
|
+
$('theme-toggle').addEventListener('click', () => {
|
|
1995
|
+
const next = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
|
|
1996
|
+
storage.set(THEME_KEY, next);
|
|
1997
|
+
applyTheme(next);
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
if (!isRendered) {
|
|
2001
|
+
$('template-notice').hidden = false;
|
|
2002
|
+
} else {
|
|
2003
|
+
document.title = fill(ui.documentTitle, { project: report.project.name });
|
|
2004
|
+
renderHeader();
|
|
2005
|
+
renderTiles();
|
|
2006
|
+
renderCharts();
|
|
2007
|
+
renderCategoryMix();
|
|
2008
|
+
renderTables();
|
|
2009
|
+
renderMilestones();
|
|
2010
|
+
renderTimeline();
|
|
2011
|
+
buildFilterControls();
|
|
2012
|
+
applyFilters();
|
|
2013
|
+
renderCapsule();
|
|
2014
|
+
$('app').hidden = false;
|
|
2015
|
+
|
|
2016
|
+
document.addEventListener('keydown', (event) => {
|
|
2017
|
+
if (event.key === '/' && event.target === document.body) {
|
|
2018
|
+
event.preventDefault();
|
|
2019
|
+
$('search').focus();
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
|
|
2023
|
+
window.addEventListener('scroll', hideTooltip, { passive: true });
|
|
2024
|
+
}
|
|
2025
|
+
</script>
|
|
2026
|
+
</body>
|
|
2027
|
+
</html>
|