slidetake 0.0.0-stage → 0.1.1
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 +202 -0
- package/NOTICE +2 -0
- package/README.md +113 -2
- package/dist/index.html +4176 -0
- package/dist/slidetake.js +1456 -0
- package/examples/embed.html +30 -0
- package/package.json +48 -4
package/dist/index.html
ADDED
|
@@ -0,0 +1,4176 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Slidetake</title>
|
|
7
|
+
<meta name="description" content="Write in markdown. Present on a spatial canvas. Record without timeline editing: retake by slide, and get a frame-exact cut with YouTube chapters. Free and open source.">
|
|
8
|
+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
9
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
10
|
+
<meta name="theme-color" content="#09090b">
|
|
11
|
+
<meta property="og:type" content="website">
|
|
12
|
+
<meta property="og:site_name" content="Slidetake">
|
|
13
|
+
<meta property="og:title" content="Slidetake: write in markdown, record without timeline editing">
|
|
14
|
+
<meta property="og:description" content="Present markdown on a spatial canvas and record it take by take: retake by slide, keep the best attempt, get a frame-exact cut with YouTube chapters.">
|
|
15
|
+
<meta property="og:url" content="https://slidetake.com/">
|
|
16
|
+
<meta property="og:image" content="https://slidetake.com/og.jpg">
|
|
17
|
+
<meta property="og:image:width" content="1200">
|
|
18
|
+
<meta property="og:image:height" content="630">
|
|
19
|
+
<meta name="twitter:card" content="summary_large_image">
|
|
20
|
+
<script>
|
|
21
|
+
// Google Analytics, on slidetake.com only (not localhost, previews or self-hosted copies).
|
|
22
|
+
// The page address it records drops the #hash, which can hold a whole deck, and ?obs=, which can hold
|
|
23
|
+
// an OBS password.
|
|
24
|
+
if (/^(www\.)?slidetake\.com$/.test(location.hostname)) {
|
|
25
|
+
var u = new URL(location.href); u.hash = ''; u.searchParams.delete('obs');
|
|
26
|
+
var ga = document.createElement('script'); ga.async = true;
|
|
27
|
+
ga.src = 'https://www.googletagmanager.com/gtag/js?id=G-3S9FY4MQLS';
|
|
28
|
+
document.head.appendChild(ga);
|
|
29
|
+
window.dataLayer = window.dataLayer || [];
|
|
30
|
+
window.gtag = function(){ dataLayer.push(arguments); };
|
|
31
|
+
gtag('js', new Date());
|
|
32
|
+
gtag('config', 'G-3S9FY4MQLS', {page_location: u.href});
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
36
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet">
|
|
37
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
|
|
38
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.2/marked.min.js"></script>
|
|
39
|
+
<style>
|
|
40
|
+
/* One palette, Slidetake gold, at two levels: bright gold on zinc in dark mode, deep gold on white in
|
|
41
|
+
light mode (the same values as sakthipriyan.com's Building Wealth section, so its decks match). */
|
|
42
|
+
:root{
|
|
43
|
+
--bg:#09090b;
|
|
44
|
+
--grid-dot:#1d1d21;
|
|
45
|
+
--panel:#111113;
|
|
46
|
+
--panel-line:#27272a;
|
|
47
|
+
--node-bg:#18181b;
|
|
48
|
+
--node-border:#323238;
|
|
49
|
+
--accent:#e0b024;
|
|
50
|
+
--accent-teal:#f5c542; /* headings below h2 */
|
|
51
|
+
--text:#e4e4e7;
|
|
52
|
+
--text-muted:#a1a1aa;
|
|
53
|
+
--danger:#e0645c;
|
|
54
|
+
--code-bg:#0f0f12;
|
|
55
|
+
--overlay:rgba(17,17,19,.9); /* breadcrumbs, nav bar, minimap */
|
|
56
|
+
--on-accent:#1a1408; /* text on an accent-filled button */
|
|
57
|
+
--card-shadow:0 6px 24px rgba(0,0,0,.35);
|
|
58
|
+
--brand-shadow:0 1px 6px rgba(0,0,0,.6);
|
|
59
|
+
--mono: 'IBM Plex Mono', ui-monospace, monospace;
|
|
60
|
+
--display: 'Space Grotesk', sans-serif;
|
|
61
|
+
--body: 'IBM Plex Sans', sans-serif;
|
|
62
|
+
}
|
|
63
|
+
/* Tokens derived from others are declared on body, not :root: a custom property resolves var() where
|
|
64
|
+
it is declared, so on :root these would freeze the default palette's colours. */
|
|
65
|
+
body{
|
|
66
|
+
--accent-line:#966f04; /* borders and connector lines on the active path */
|
|
67
|
+
--accent-ring:var(--accent); /* the current slide's border, glow and the progress bar */
|
|
68
|
+
--edge:var(--node-border); /* connector lines off the active path */
|
|
69
|
+
}
|
|
70
|
+
/* Light mode (L, mode: light, ?mode=light): #7a5c12 carries text (6.2:1 on white); the brighter gold
|
|
71
|
+
only rings and lines, which never need to be read. */
|
|
72
|
+
body[data-mode="light"]{
|
|
73
|
+
--bg:#fafaf9; --grid-dot:#e7e5e4; --panel:#ffffff; --panel-line:#e4e4e7;
|
|
74
|
+
--node-bg:#ffffff; --node-border:#e4e4e7; --edge:#d4d4d8;
|
|
75
|
+
--accent:#7a5c12; --accent-teal:#8a6610; --accent-line:#d4af37; --accent-ring:#d4af37;
|
|
76
|
+
--text:#27272a; --text-muted:#71717a; --danger:#c2410c;
|
|
77
|
+
--code-bg:#f4f4f5; --overlay:rgba(255,255,255,.92); --on-accent:#ffffff;
|
|
78
|
+
--card-shadow:0 4px 18px rgba(24,24,27,.08); --brand-shadow:0 1px 4px rgba(255,255,255,.9);
|
|
79
|
+
}
|
|
80
|
+
body[data-mode="light"] .node .body pre code{color:var(--text);}
|
|
81
|
+
body[data-mode="light"] #help, body[data-mode="light"] .modal{background:rgba(24,24,27,.45);}
|
|
82
|
+
*{box-sizing:border-box;}
|
|
83
|
+
html,body{height:100%;margin:0;}
|
|
84
|
+
body{
|
|
85
|
+
background:var(--bg);
|
|
86
|
+
color:var(--text);
|
|
87
|
+
font-family:var(--body);
|
|
88
|
+
overflow:hidden;
|
|
89
|
+
display:flex;
|
|
90
|
+
flex-direction:column;
|
|
91
|
+
}
|
|
92
|
+
::selection{background:var(--accent);color:var(--on-accent);}
|
|
93
|
+
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
|
|
94
|
+
button{font-family:var(--mono);}
|
|
95
|
+
|
|
96
|
+
/* ---------- header ---------- */
|
|
97
|
+
header{
|
|
98
|
+
min-height:56px;flex:none;
|
|
99
|
+
display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;
|
|
100
|
+
padding:8px 16px;
|
|
101
|
+
background:var(--panel);
|
|
102
|
+
border-bottom:1px solid var(--panel-line);
|
|
103
|
+
z-index:20;
|
|
104
|
+
}
|
|
105
|
+
.brand{display:flex;align-items:baseline;gap:10px;}
|
|
106
|
+
.brand .mark{font-family:var(--display);font-weight:700;font-size:17px;letter-spacing:.02em;color:inherit;text-decoration:none;display:inline-flex;align-items:center;gap:7px;align-self:center;}
|
|
107
|
+
.brand .mark .logo{width:20px;height:20px;fill:var(--accent);flex:none;}
|
|
108
|
+
.brand .mark .word > span{color:var(--accent);}
|
|
109
|
+
.brand .tagline{font-family:var(--mono);font-size:13px;color:var(--text-muted);}
|
|
110
|
+
.hdr-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
|
|
111
|
+
.btn{
|
|
112
|
+
background:transparent;color:var(--text);
|
|
113
|
+
border:1px solid var(--node-border);border-radius:6px;
|
|
114
|
+
padding:7px 12px;font-size:12px;letter-spacing:.02em;cursor:pointer;
|
|
115
|
+
display:flex;align-items:center;gap:6px;
|
|
116
|
+
transition:border-color .15s, color .15s, background .15s;
|
|
117
|
+
}
|
|
118
|
+
a.btn{text-decoration:none;}
|
|
119
|
+
.btn:hover{border-color:var(--accent);color:var(--accent);}
|
|
120
|
+
.btn.primary{border-color:var(--accent);color:var(--accent);}
|
|
121
|
+
.btn.primary:hover{background:var(--accent);color:var(--on-accent);}
|
|
122
|
+
.btn.active{background:var(--node-border);}
|
|
123
|
+
.seg{display:flex;border:1px solid var(--node-border);border-radius:6px;overflow:hidden;}
|
|
124
|
+
.seg-btn{
|
|
125
|
+
background:transparent;border:none;color:var(--text-muted);font-family:var(--mono);
|
|
126
|
+
font-size:12px;padding:7px 12px;cursor:pointer;transition:background .15s,color .15s;
|
|
127
|
+
}
|
|
128
|
+
.seg-btn:hover{color:var(--accent);}
|
|
129
|
+
.seg-btn.active{background:var(--node-border);color:var(--accent);}
|
|
130
|
+
|
|
131
|
+
/* ---------- main layout ---------- */
|
|
132
|
+
main{flex:1;display:flex;min-height:0;}
|
|
133
|
+
/* the editor sits on the right; its width is dragged with #editor-resizer and remembered */
|
|
134
|
+
#editor-pane{
|
|
135
|
+
width:var(--editor-w, 38%);min-width:280px;max-width:75vw;
|
|
136
|
+
display:flex;flex-direction:column;
|
|
137
|
+
background:var(--panel);border-left:1px solid var(--panel-line);
|
|
138
|
+
transition:width .25s ease, min-width .25s ease, opacity .2s ease;
|
|
139
|
+
overflow:hidden;
|
|
140
|
+
}
|
|
141
|
+
#editor-pane.collapsed{width:0;min-width:0;opacity:0;border-left:none;}
|
|
142
|
+
main.resizing #editor-pane{transition:none;}
|
|
143
|
+
main.resizing{cursor:col-resize;user-select:none;}
|
|
144
|
+
#editor-resizer{flex:none;width:6px;margin-right:-3px;margin-left:-3px;z-index:5;cursor:col-resize;position:relative;}
|
|
145
|
+
#editor-resizer:hover, main.resizing #editor-resizer{background:var(--accent-line, var(--accent));opacity:.6;}
|
|
146
|
+
#editor-resizer:has(+ #editor-pane.collapsed){display:none;}
|
|
147
|
+
.pane-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px 8px 14px;border-bottom:1px solid var(--panel-line);}
|
|
148
|
+
.pane-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;}
|
|
149
|
+
#doc-state{text-transform:none;letter-spacing:.02em;font-size:11px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
150
|
+
#doc-state .ro{color:var(--text-muted);}
|
|
151
|
+
#doc-state .mine{color:var(--text);}
|
|
152
|
+
#doc-state .edited{color:var(--accent);}
|
|
153
|
+
#continue{color:var(--accent);border-color:var(--accent-line);}
|
|
154
|
+
#continue[hidden]{display:none;}
|
|
155
|
+
.modal ul.templates{list-style:none;padding:0;display:grid;gap:8px;margin:12px 0;}
|
|
156
|
+
.modal ul.templates a{display:flex;flex-direction:column;gap:2px;padding:10px 12px;border:1px solid var(--panel-line);border-radius:8px;text-decoration:none;color:var(--text);}
|
|
157
|
+
.modal ul.templates a:hover{border-color:var(--accent);}
|
|
158
|
+
.modal ul.templates span{font-size:12px;color:var(--text-muted);}
|
|
159
|
+
#editor-pane.unsaved .pane-bar{box-shadow:inset 0 -2px 0 var(--accent);}
|
|
160
|
+
#editor-pane.unsaved #btn-share, #editor-pane.unsaved #btn-save{border-color:var(--accent);color:var(--accent);}
|
|
161
|
+
.btn.small{padding:3px 9px;font-size:11px;}
|
|
162
|
+
.btn.icon{padding:4px 9px;min-width:30px;display:inline-flex;align-items:center;justify-content:center;}
|
|
163
|
+
.btn.icon svg{width:15px;height:15px;display:block;}
|
|
164
|
+
.pane-label{
|
|
165
|
+
font-family:var(--mono);font-size:10px;letter-spacing:.12em;text-transform:uppercase;
|
|
166
|
+
color:var(--text-muted);flex:none;
|
|
167
|
+
}
|
|
168
|
+
#editor{
|
|
169
|
+
flex:1;resize:none;border:none;outline:none;padding-top:10px !important;
|
|
170
|
+
background:var(--panel);color:var(--text);
|
|
171
|
+
font-family:var(--mono);font-size:12.5px;line-height:1.65;
|
|
172
|
+
padding:0 14px 14px;tab-size:2;
|
|
173
|
+
}
|
|
174
|
+
#status-line{
|
|
175
|
+
flex:none;padding:6px 14px;font-family:var(--mono);font-size:11px;
|
|
176
|
+
color:var(--text-muted);border-top:1px solid var(--panel-line);
|
|
177
|
+
display:flex;justify-content:space-between;gap:10px;
|
|
178
|
+
}
|
|
179
|
+
#status-line .err{color:var(--danger);}
|
|
180
|
+
#btn-reset{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;padding:0;text-decoration:underline;}
|
|
181
|
+
#btn-reset:hover{color:var(--accent);}
|
|
182
|
+
|
|
183
|
+
body.presenting header, body.presenting #editor-pane, body.presenting #editor-resizer{display:none;}
|
|
184
|
+
#breadcrumbs, #navbar, #minimap{transition:opacity .4s;}
|
|
185
|
+
body.presenting.idle #breadcrumbs, body.presenting.idle #navbar, body.presenting.idle #minimap{opacity:0;pointer-events:none;}
|
|
186
|
+
body.presenting.idle, body.presenting.idle *{cursor:none !important;}
|
|
187
|
+
|
|
188
|
+
/* ---------- stage ---------- */
|
|
189
|
+
#stage-wrap{flex:1;position:relative;overflow:hidden;}
|
|
190
|
+
#stage{
|
|
191
|
+
position:absolute;inset:0;
|
|
192
|
+
background-color:var(--bg);
|
|
193
|
+
background-image:radial-gradient(var(--grid-dot) 1.2px, transparent 1.2px);
|
|
194
|
+
background-size:28px 28px;
|
|
195
|
+
overflow:hidden;cursor:grab;touch-action:none;
|
|
196
|
+
}
|
|
197
|
+
#stage.dragging{cursor:grabbing;user-select:none;}
|
|
198
|
+
#world{position:absolute;left:0;top:0;transform-origin:0 0;}
|
|
199
|
+
#connectors{position:absolute;left:0;top:0;overflow:visible;pointer-events:none;}
|
|
200
|
+
#connectors path{fill:none;stroke:var(--edge);stroke-width:1.5;transition:stroke .2s;}
|
|
201
|
+
#connectors path.active{stroke:var(--accent-line);stroke-width:2;}
|
|
202
|
+
|
|
203
|
+
div.node{ /* div: Graphviz also puts class="node" on its SVG shapes */
|
|
204
|
+
position:absolute;left:0;top:0;width:440px;
|
|
205
|
+
/* centre of the card sits at (--cx, --cy); --push is Focus's settle-in scale */
|
|
206
|
+
transform:translate(calc(var(--cx,0) * 1px), calc(var(--cy,0) * 1px)) scale(var(--push,1)) translate(-50%,-50%);
|
|
207
|
+
transform-origin:0 0; /* the last translate puts the card centre at 0,0, so the scale pivots on it */
|
|
208
|
+
background:var(--node-bg);
|
|
209
|
+
border:1px solid var(--node-border);border-radius:8px;
|
|
210
|
+
padding:16px 18px 18px;cursor:pointer;
|
|
211
|
+
box-shadow:var(--card-shadow);
|
|
212
|
+
transition:border-color .18s, box-shadow .18s, opacity .3s;
|
|
213
|
+
}
|
|
214
|
+
/* Focus: every card sits at the same spot and only the current one shows; the next fades in with
|
|
215
|
+
a slight push-in instead of the camera travelling */
|
|
216
|
+
/* other cards vanish at once (no stacked fade on load or layout change); only the slide just left
|
|
217
|
+
fades out, beneath the incoming one */
|
|
218
|
+
#world.focus div.node{transition:none;}
|
|
219
|
+
#world.focus div.node:not(.current){opacity:0;pointer-events:none;}
|
|
220
|
+
#world.focus div.node.current{z-index:2;transition:opacity .55s ease, transform .8s cubic-bezier(.2,.7,.2,1), border-color .18s;}
|
|
221
|
+
#world.focus div.node.leaving{z-index:1;transition:opacity .45s ease;}
|
|
222
|
+
#world.focus div.node.entering{--push:.96;transition:none;}
|
|
223
|
+
#world.focus #connectors{display:none;}
|
|
224
|
+
/* progress: one continuous bar that moves with every press, reveals and camera steps included */
|
|
225
|
+
#progress{position:absolute;left:0;right:0;bottom:0;height:5px;z-index:9;display:none;
|
|
226
|
+
background:color-mix(in srgb, var(--text-muted) 22%, transparent);}
|
|
227
|
+
#progress.show{display:block;}
|
|
228
|
+
#progress i{position:absolute;inset:0 auto 0 0;width:0;background:var(--accent-ring);transition:width .5s ease;}
|
|
229
|
+
/* talk timer on the same bar, in the same colour: the clock grows a half-strength layer behind the
|
|
230
|
+
solid progress, so any half-strength stretch showing past the solid is how far behind the talk is */
|
|
231
|
+
#progress b{position:absolute;inset:0 auto 0 0;width:0;background:color-mix(in srgb, var(--accent-ring) 50%, transparent);transition:width 1s linear;display:none;}
|
|
232
|
+
#progress.timed b{display:block;}
|
|
233
|
+
#progress.over b{animation:over 1.4s ease-in-out infinite;}
|
|
234
|
+
@keyframes over{50%{opacity:.45;}}
|
|
235
|
+
#world.morph div.node{transition:transform .65s cubic-bezier(.65,0,.35,1), border-color .18s, opacity .3s;}
|
|
236
|
+
.node .body{overflow-wrap:anywhere;word-break:break-word;}
|
|
237
|
+
/* only the current slide is ringed in the accent; hover and the route back to the root are faint tints */
|
|
238
|
+
/* hover never touches the current slide, or its border would sit inside the ring as a second line */
|
|
239
|
+
.node:not(.current):hover{border-color:color-mix(in srgb, var(--accent-line) 35%, var(--node-border));}
|
|
240
|
+
body.presenting .node:not(.current):hover{border-color:var(--node-border);}
|
|
241
|
+
/* cards take focus on click; the current-slide ring already marks them, so no second outline
|
|
242
|
+
(Chrome re-shows :focus-visible when the window regains focus) */
|
|
243
|
+
.node:focus-visible{outline:none;}
|
|
244
|
+
.node:not(.current):focus-visible{border-color:var(--accent-line);}
|
|
245
|
+
.node.current{border-color:var(--accent-ring);box-shadow:0 0 0 1px var(--accent-ring), 0 10px 34px color-mix(in srgb, var(--accent-ring) 22%, transparent);}
|
|
246
|
+
.node.active-path:not(.current){border-color:color-mix(in srgb, var(--accent-line) 30%, var(--node-border));}
|
|
247
|
+
.node .crumb{
|
|
248
|
+
font-family:var(--mono);font-size:10px;color:var(--text-muted);overflow-wrap:anywhere;
|
|
249
|
+
letter-spacing:.06em;margin-bottom:8px;text-transform:uppercase;
|
|
250
|
+
}
|
|
251
|
+
.node .body h1,.node .body h2,.node .body h3,.node .body h4,.node .body h5,.node .body h6{
|
|
252
|
+
font-family:var(--display);color:var(--text);margin:0 0 8px;line-height:1.25;
|
|
253
|
+
}
|
|
254
|
+
.node .body h1{font-size:19px;}
|
|
255
|
+
.node .body h2{font-size:16px;}
|
|
256
|
+
.node .body h3{font-size:14px;color:var(--accent-teal);}
|
|
257
|
+
.node .body h4,.node .body h5,.node .body h6{font-size:13px;color:var(--accent-teal);}
|
|
258
|
+
.node .body p{margin:0 0 10px;font-size:13px;line-height:1.6;}
|
|
259
|
+
.node .body > :last-child{margin-bottom:0;}
|
|
260
|
+
.node .body ul,.node .body ol{margin:0 0 10px;padding-left:18px;font-size:13px;line-height:1.6;}
|
|
261
|
+
.node .body li{margin-bottom:3px;}
|
|
262
|
+
.node .body blockquote{margin:0 0 10px;padding-left:10px;border-left:2px solid var(--accent);color:var(--text-muted);font-size:13px;}
|
|
263
|
+
.node .body img{max-width:100%;border-radius:4px;}
|
|
264
|
+
.node .body table{border-collapse:collapse;font-size:12px;margin:0 0 10px;}
|
|
265
|
+
.node .body th,.node .body td{border:1px solid var(--panel-line);padding:3px 7px;}
|
|
266
|
+
.node .body code{
|
|
267
|
+
font-family:var(--mono);background:var(--code-bg);border:1px solid var(--panel-line);
|
|
268
|
+
padding:1px 5px;border-radius:4px;font-size:12px;color:var(--accent-teal);
|
|
269
|
+
}
|
|
270
|
+
.node .body pre{
|
|
271
|
+
background:var(--code-bg);border:1px solid var(--panel-line);border-radius:6px;
|
|
272
|
+
padding:10px 12px;overflow-x:auto;margin:0 0 10px;
|
|
273
|
+
}
|
|
274
|
+
.node .body pre code{border:none;background:none;padding:0;color:var(--text);}
|
|
275
|
+
.node .body strong{color:var(--accent);}
|
|
276
|
+
.node .body a{color:var(--accent-teal);}
|
|
277
|
+
.node .body a.xlink::after{content:" ↗";font-size:10px;}
|
|
278
|
+
.node .err-badge{
|
|
279
|
+
position:absolute;top:-8px;right:-8px;background:var(--danger);color:#1a0a08;
|
|
280
|
+
font-family:var(--mono);font-size:10px;padding:2px 7px;border-radius:20px;font-weight:600;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* ---------- recording ---------- */
|
|
284
|
+
.modal{position:fixed;inset:0;background:rgba(4,7,13,.72);z-index:50;display:none;align-items:center;justify-content:center;padding:16px;}
|
|
285
|
+
.modal.open{display:flex;}
|
|
286
|
+
.modal .panel{
|
|
287
|
+
position:relative;width:min(620px,100%);max-height:88vh;overflow-y:auto;
|
|
288
|
+
background:var(--panel);border:1px solid var(--panel-line);border-radius:12px;padding:24px 26px;
|
|
289
|
+
}
|
|
290
|
+
.modal .panel.wide{width:min(760px,100%);}
|
|
291
|
+
.modal h2{font-family:var(--display);font-size:18px;margin:0 0 6px;color:var(--accent);}
|
|
292
|
+
.modal h3{font-family:var(--display);font-size:13px;margin:18px 0 8px;color:var(--text);display:flex;align-items:center;gap:10px;}
|
|
293
|
+
.modal p, .modal li{font-size:13px;line-height:1.6;color:var(--text-muted);margin:0 0 6px;}
|
|
294
|
+
.modal ul{padding-left:18px;margin:0;}
|
|
295
|
+
.modal .close{position:absolute;top:14px;right:16px;background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;}
|
|
296
|
+
.modal .fields{display:grid;grid-template-columns:2fr 1fr 2fr;gap:10px;}
|
|
297
|
+
#open-form{display:flex;gap:8px;margin:12px 0 6px;}
|
|
298
|
+
#help table.keys{border-collapse:collapse;margin:6px 0 12px;font-size:13px;}
|
|
299
|
+
#help table.keys td{padding:5px 14px 5px 0;color:var(--text-muted);vertical-align:top;}
|
|
300
|
+
#help table.keys td:first-child{white-space:nowrap;}
|
|
301
|
+
#help a{color:var(--accent);}
|
|
302
|
+
#open-url{flex:1;min-width:0;}
|
|
303
|
+
.modal p.warn{color:var(--danger);}
|
|
304
|
+
#toast{position:fixed;left:50%;top:64px;transform:translateX(-50%) translateY(-8px);opacity:0;pointer-events:none;z-index:60;
|
|
305
|
+
background:var(--panel, #18181b);color:var(--text);border:1px solid var(--accent-line, var(--accent));border-radius:8px;
|
|
306
|
+
padding:8px 14px;font-family:var(--mono);font-size:12px;transition:opacity .2s, transform .2s;max-width:min(560px,calc(100vw - 32px));}
|
|
307
|
+
#toast.show{opacity:1;transform:translateX(-50%);}
|
|
308
|
+
.modal label{display:flex;flex-direction:column;gap:4px;font-family:var(--mono);font-size:11px;color:var(--text-muted);}
|
|
309
|
+
.modal label.check{flex-direction:row;align-items:center;gap:8px;margin-top:10px;}
|
|
310
|
+
.modal input[type=text], .modal input[type=password], .modal textarea{
|
|
311
|
+
background:var(--code-bg);border:1px solid var(--node-border);border-radius:6px;color:var(--text);
|
|
312
|
+
font-family:var(--mono);font-size:12.5px;padding:8px 10px;outline:none;
|
|
313
|
+
}
|
|
314
|
+
.modal input:focus, .modal textarea:focus{border-color:var(--accent);}
|
|
315
|
+
.modal textarea{width:100%;resize:vertical;line-height:1.6;}
|
|
316
|
+
.modal .row{display:flex;align-items:center;gap:10px;margin-top:12px;flex-wrap:wrap;}
|
|
317
|
+
.modal .row.end{justify-content:flex-end;margin-top:20px;}
|
|
318
|
+
.modal .btn[disabled]{opacity:.4;cursor:not-allowed;}
|
|
319
|
+
.modal .btn.small{padding:3px 9px;font-size:11px;}
|
|
320
|
+
#obs-status{font-family:var(--mono);font-size:12px;color:var(--text-muted);}
|
|
321
|
+
#obs-status.ok, #rec-screen .ok{color:#10b981;}
|
|
322
|
+
#rec-screen a{color:inherit;text-decoration:underline;}
|
|
323
|
+
#obs-status.err{color:var(--danger);}
|
|
324
|
+
.modal .warn{color:var(--accent);}
|
|
325
|
+
@media (max-width:560px){ .modal .fields{grid-template-columns:1fr;} }
|
|
326
|
+
#navbar #btn-record{color:#f87171;}
|
|
327
|
+
#navbar #btn-record:hover{color:#fff;background:#b91c1c;}
|
|
328
|
+
#navbar #btn-present{color:var(--accent);}
|
|
329
|
+
/* camera: a grey camera when off; green, with a live dot, when on */
|
|
330
|
+
#btn-camera{display:inline-flex;align-items:center;gap:6px;}
|
|
331
|
+
#btn-camera svg{display:block;}
|
|
332
|
+
#navbar #btn-camera.on{color:#22c55e;}
|
|
333
|
+
/* while a take runs nothing but the slides and the camera is on screen */
|
|
334
|
+
body.recording #breadcrumbs, body.recording #navbar, body.recording #minimap, body.recording #pip-msg{display:none !important;}
|
|
335
|
+
body.recording, body.recording *{cursor:none !important;}
|
|
336
|
+
#rec-countdown{
|
|
337
|
+
position:fixed;inset:0;z-index:70;display:none;align-items:center;justify-content:center;flex-direction:column;gap:14px;
|
|
338
|
+
background:rgba(4,7,13,.9);font-family:var(--display);color:var(--accent);
|
|
339
|
+
}
|
|
340
|
+
#rec-countdown.show{display:flex;}
|
|
341
|
+
#rec-countdown .num{font-size:180px;font-weight:700;line-height:1;}
|
|
342
|
+
#rec-countdown .hint{font-family:var(--mono);font-size:13px;color:var(--text-muted);}
|
|
343
|
+
#rec-paused{
|
|
344
|
+
position:fixed;inset:0;z-index:70;display:none;align-items:center;justify-content:center;
|
|
345
|
+
background:rgba(4,7,13,.94);font-family:var(--mono);font-size:15px;color:var(--text-muted);letter-spacing:.06em;
|
|
346
|
+
}
|
|
347
|
+
#rec-paused.show{display:flex;}
|
|
348
|
+
.modal .panel.xwide{width:min(1220px,100%);max-height:94vh;}
|
|
349
|
+
.rv-grid{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,2fr);gap:18px;margin-top:12px;}
|
|
350
|
+
@media (max-width:900px){ .rv-grid{grid-template-columns:1fr;} }
|
|
351
|
+
.rv-video{position:relative;background:#000;border-radius:8px;overflow:hidden;aspect-ratio:16/9;}
|
|
352
|
+
.rv-video video{width:100%;height:100%;display:block;}
|
|
353
|
+
#rv-novideo{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:20px;text-align:center;}
|
|
354
|
+
#rv-novideo[hidden]{display:none;}
|
|
355
|
+
#rv-now{font-family:var(--mono);font-size:12px;color:var(--text-muted);margin-top:8px;min-height:1.4em;}
|
|
356
|
+
.rv-list{max-height:52vh;overflow-y:auto;border:1px solid var(--panel-line);border-radius:8px;}
|
|
357
|
+
.rv-row{padding:9px 12px;border-bottom:1px solid var(--panel-line);}
|
|
358
|
+
.rv-row:last-child{border-bottom:none;}
|
|
359
|
+
.rv-row .t{font-size:12.5px;color:var(--text);margin-bottom:6px;display:flex;justify-content:space-between;gap:8px;}
|
|
360
|
+
.rv-row .t small{font-family:var(--mono);color:var(--text-muted);font-size:10.5px;white-space:nowrap;}
|
|
361
|
+
.rv-row.sec .t{color:var(--accent-teal);}
|
|
362
|
+
.rv-chips{display:flex;flex-wrap:wrap;gap:6px;}
|
|
363
|
+
.rv-chip{background:transparent;border:1px solid var(--node-border);color:var(--text-muted);border-radius:20px;
|
|
364
|
+
font-family:var(--mono);font-size:11px;padding:3px 10px;cursor:pointer;}
|
|
365
|
+
.rv-chip:hover{border-color:var(--accent-teal);color:var(--text);}
|
|
366
|
+
.rv-chip.on{border-color:var(--accent);color:var(--accent);background:color-mix(in srgb, var(--accent) 10%, transparent);}
|
|
367
|
+
.rv-chip.skip.on{border-color:var(--danger);color:var(--danger);background:rgba(224,100,92,.1);}
|
|
368
|
+
.rv-out{margin-top:6px;}
|
|
369
|
+
.rv-out .two{display:grid;grid-template-columns:1fr 1fr;gap:12px;}
|
|
370
|
+
@media (max-width:900px){ .rv-out .two{grid-template-columns:1fr;} }
|
|
371
|
+
.modal select{background:var(--code-bg);border:1px solid var(--node-border);border-radius:6px;color:var(--text);font-family:var(--mono);font-size:11.5px;padding:4px 8px;}
|
|
372
|
+
#rec-sessions{margin-top:14px;}
|
|
373
|
+
|
|
374
|
+
/* ---------- reveal.js compatibility: fragments, stacks, diagrams, charts ---------- */
|
|
375
|
+
.node .fragment{opacity:0;visibility:hidden;transition:opacity .45s ease, transform .45s ease, visibility 0s .45s;}
|
|
376
|
+
.node .fragment.visible{opacity:1;visibility:inherit;transition:opacity .45s ease, transform .45s ease;}
|
|
377
|
+
.node .fragment.fade-up{transform:translateY(24px);}
|
|
378
|
+
.node .fragment.fade-down{transform:translateY(-24px);}
|
|
379
|
+
.node .fragment.fade-left{transform:translateX(40px);}
|
|
380
|
+
.node .fragment.fade-right{transform:translateX(-40px);}
|
|
381
|
+
.node .fragment.zoom-in{transform:scale(.1);}
|
|
382
|
+
.node .fragment.visible:is(.fade-up,.fade-down,.fade-left,.fade-right,.zoom-in){transform:none;}
|
|
383
|
+
/* these start visible and change when their step comes */
|
|
384
|
+
.node .fragment:is(.grow,.shrink,.fade-out,.semi-fade-out,.strike,.highlight-red,.highlight-green,.highlight-blue){opacity:1;visibility:inherit;}
|
|
385
|
+
/* grow: sized to its content and growing rightwards, so the card can make room for its last step */
|
|
386
|
+
.node .fragment.grow{width:fit-content;max-width:100%;transform-origin:left center;}
|
|
387
|
+
.node .fragment.grow.visible{transform:scale(1.3);}
|
|
388
|
+
.node .fragment.shrink.visible{transform:scale(.7);}
|
|
389
|
+
.node .fragment.fade-out.visible{opacity:0;visibility:hidden;}
|
|
390
|
+
.node .fragment.semi-fade-out.visible{opacity:.5;}
|
|
391
|
+
.node .fragment.strike.visible{text-decoration:line-through;}
|
|
392
|
+
.node .fragment.highlight-red.visible{color:var(--danger);}
|
|
393
|
+
.node .fragment.highlight-green.visible{color:#10b981;}
|
|
394
|
+
.node .fragment.highlight-blue.visible{color:#60a5fa;}
|
|
395
|
+
/* shown only while it is the newest step */
|
|
396
|
+
.node .fragment.visible:is(.fade-in-then-out,.current-visible):not(.current-fragment){opacity:0;visibility:hidden;}
|
|
397
|
+
.node .fragment.fade-in-then-semi-out.visible:not(.current-fragment){opacity:.5;}
|
|
398
|
+
.node .r-stack{display:grid;}
|
|
399
|
+
.node .r-stack > *{grid-area:1/1;margin:auto;}
|
|
400
|
+
.node .r-hstack{display:flex;flex-direction:row;align-items:center;justify-content:center;}
|
|
401
|
+
.node .r-vstack{display:flex;flex-direction:column;align-items:center;justify-content:center;}
|
|
402
|
+
.node .body img{max-width:100%;height:auto;object-fit:contain;}
|
|
403
|
+
/* ---------- media from plain markdown (see applyMedia) ---------- */
|
|
404
|
+
.node .body figure.media{margin:0;}
|
|
405
|
+
.node .body figure.media img{display:block;width:100%;height:auto;max-height:70vh;object-fit:contain;border-radius:8px;}
|
|
406
|
+
.node .body figure.media figcaption{margin-top:8px;font-size:.82em;color:var(--text-muted);line-height:1.45;}
|
|
407
|
+
.node .body figure.yt .frame{position:relative;width:100%;aspect-ratio:16/9;border-radius:8px;overflow:hidden;background:#000;}
|
|
408
|
+
.node .body figure.yt.portrait .frame{aspect-ratio:9/16;max-height:70vh;width:auto;margin:0 auto;}
|
|
409
|
+
.node .body figure.yt iframe{position:absolute;inset:0;width:100%;height:100%;border:0;}
|
|
410
|
+
/* the video is always on show; its step only plays it */
|
|
411
|
+
.node .fragment.yt-play{opacity:1 !important;visibility:inherit !important;transform:none !important;}
|
|
412
|
+
.node.card-split .body{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:4px 22px;align-items:center;}
|
|
413
|
+
.node.card-split .body > :is(h1,h2,h3,h4,h5,h6){grid-column:1 / -1;}
|
|
414
|
+
.node.card-split .body .split-text > :first-child{margin-top:0;}
|
|
415
|
+
.node.card-split.media-last .body{grid-template-columns:minmax(0,1fr) minmax(0,1.25fr);}
|
|
416
|
+
.node .body .gallery{list-style:none;padding:0;margin:8px 0 0;display:grid;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));gap:14px;align-items:end;}
|
|
417
|
+
.node .body .gallery li{margin:0;}
|
|
418
|
+
.node .body .gallery figure.media img{max-height:calc(56vh / var(--rows,1));margin:0 auto;}
|
|
419
|
+
.node .body .gallery figure.media figcaption{font-size:.72em;text-align:center;}
|
|
420
|
+
/* a stepped gallery: the images stack in one place and each press brings the next */
|
|
421
|
+
.node .body .gallery.carousel{grid-template-columns:minmax(0,1fr);}
|
|
422
|
+
.node .body .gallery.carousel > li{grid-area:1/1;}
|
|
423
|
+
.node .body .gallery.carousel figure.media img{max-height:58vh;}
|
|
424
|
+
.node .body .gallery.carousel figure.media figcaption{font-size:.82em;}
|
|
425
|
+
.node .body .gallery.carousel figcaption[data-count]::before{content:attr(data-count) " ";color:var(--accent);font-weight:600;white-space:pre;}
|
|
426
|
+
.node .body .gallery.carousel:has(> li.visible) > li:not(.fragment){opacity:0;visibility:hidden;transition:opacity .45s ease, visibility 0s .45s;}
|
|
427
|
+
.node .body .gallery.carousel > li:not(.fragment){transition:opacity .45s ease;}
|
|
428
|
+
/* image cards: an image or carousel alone, laid out by the image's shape (see sizeCard) */
|
|
429
|
+
div.node.card-bleed{padding:0;overflow:hidden;}
|
|
430
|
+
.node.card-bleed .body .gallery{margin:0;}
|
|
431
|
+
.node.card-bleed .body figure.media img,
|
|
432
|
+
.node.card-bleed .body .gallery.carousel figure.media img{max-height:none;border-radius:0;background:var(--code-bg);}
|
|
433
|
+
.node.card-bleed .body figure.media figcaption{margin:0;text-align:left;font-size:.9em;}
|
|
434
|
+
/* landscape: the image spans the card; the heading sits above it, the caption below */
|
|
435
|
+
.node.img-landscape .crumb{margin:12px 18px 4px;}
|
|
436
|
+
.node.img-landscape .body > :is(h1,h2,h3,h4,h5,h6):first-child{margin:0 18px 10px;}
|
|
437
|
+
.node.img-landscape .body figure.media img{width:100%;height:var(--img-h);object-fit:contain;}
|
|
438
|
+
.node.img-landscape .body figure.media figcaption{padding:10px 18px 14px;}
|
|
439
|
+
/* portrait or near-square: the image on the right at the card's height; the heading and caption share the left */
|
|
440
|
+
div.node.img-portrait{height:540px;padding:20px calc(var(--img-w) + 26px) 22px 24px;}
|
|
441
|
+
.node.img-portrait .body{display:flex;flex-direction:column;height:100%;}
|
|
442
|
+
.node.img-portrait .crumb{margin-bottom:10px;}
|
|
443
|
+
.node.img-portrait .body > :is(h1,h2,h3,h4,h5,h6):first-child{font-size:22px;}
|
|
444
|
+
.node.img-portrait .body > .gallery, .node.img-portrait .body > figure.media{margin-top:auto;}
|
|
445
|
+
.node.img-portrait .body figure.media img{position:absolute;top:0;right:0;width:var(--img-w);height:540px;object-fit:contain;}
|
|
446
|
+
.node.img-portrait .body figure.media figcaption, .node.img-portrait .body .gallery.carousel figure.media figcaption{font-size:1.35em;line-height:1.45;color:var(--text);}
|
|
447
|
+
/* 16:9, or a full-screen card: the image fills the card, the heading and caption over it */
|
|
448
|
+
.node.img-overlay::before{content:"";position:absolute;inset:0 0 auto;height:96px;z-index:2;pointer-events:none;
|
|
449
|
+
background:linear-gradient(rgba(0,0,0,.72), rgba(0,0,0,0));border-radius:8px 8px 0 0;}
|
|
450
|
+
.node.img-overlay .crumb{position:absolute;top:12px;left:18px;right:18px;z-index:3;margin:0;color:rgba(255,255,255,.72);}
|
|
451
|
+
.node.img-overlay .body > :is(h1,h2,h3,h4,h5,h6):first-child{position:absolute;top:28px;left:18px;right:18px;z-index:3;margin:0;
|
|
452
|
+
color:#fff;text-shadow:0 1px 6px rgba(0,0,0,.6);}
|
|
453
|
+
.node.img-overlay .body figure.media{position:relative;}
|
|
454
|
+
.node.img-overlay .body figure.media img{width:100%;height:540px;object-fit:contain;}
|
|
455
|
+
.node.card-full.img-overlay .body figure.media img{object-fit:cover;}
|
|
456
|
+
.node.img-overlay .body figure.media figcaption{position:absolute;left:0;right:0;bottom:0;padding:36px 18px 14px;
|
|
457
|
+
color:#f4f4f5;background:linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.78));}
|
|
458
|
+
.node.img-overlay .body .gallery.carousel figure.media figcaption::before{color:#f5c542;}
|
|
459
|
+
/* <!-- view: full -->: a 16:9 card that fills the screen, with the map and breadcrumbs out of the way */
|
|
460
|
+
div.node.card-full{height:540px;overflow:hidden;}
|
|
461
|
+
body.full-card #breadcrumbs, body.full-card #minimap{opacity:0;pointer-events:none;}
|
|
462
|
+
/* measure cards at their resting size, without grow/zoom transforms */
|
|
463
|
+
div.node.measuring .fragment{transform:none !important;transition:none !important;}
|
|
464
|
+
/* a card re-measured mid-entrance (a theme switch replays it) must not count a gsap "from" state such
|
|
465
|
+
as scale(3) as its width, or it shrinks the whole card to fit */
|
|
466
|
+
div.node.measuring [data-gsap]{transform:none !important;}
|
|
467
|
+
/* arriving at or leaving a slide snaps its fragments; only steps within the slide animate */
|
|
468
|
+
div.node.snap .fragment{transition:none !important;}
|
|
469
|
+
.node .body iframe{max-width:100%;border:0;border-radius:6px;background:#fff;}
|
|
470
|
+
.node .diagram{background:#f8fafc;border:1px solid var(--panel-line);border-radius:8px;padding:12px;margin:0 0 10px;overflow:auto;}
|
|
471
|
+
.node .diagram svg{display:block;width:100%;height:auto;max-height:640px;}
|
|
472
|
+
.node .diagram.err{background:none;color:var(--danger);font-family:var(--mono);font-size:12px;padding:0;}
|
|
473
|
+
/* D2 is drawn in the deck's own palette, so it needs no light backdrop */
|
|
474
|
+
.node .diagram.d2{background:none;border:none;padding:0;}
|
|
475
|
+
.node .diagram.d2 svg{max-height:62vh;}
|
|
476
|
+
.node .echarts-container{width:100%;height:360px;margin:0 0 10px;}
|
|
477
|
+
|
|
478
|
+
/* ---------- overlays ---------- */
|
|
479
|
+
#breadcrumbs{
|
|
480
|
+
position:absolute;top:14px;left:14px;z-index:10;
|
|
481
|
+
display:flex;align-items:center;gap:6px;flex-wrap:wrap;max-width:60%;
|
|
482
|
+
font-family:var(--mono);font-size:11.5px;
|
|
483
|
+
}
|
|
484
|
+
#breadcrumbs .crumb-btn{
|
|
485
|
+
background:var(--overlay);border:1px solid var(--panel-line);color:var(--text-muted);
|
|
486
|
+
padding:4px 9px;border-radius:5px;cursor:pointer;backdrop-filter:blur(4px);
|
|
487
|
+
}
|
|
488
|
+
#breadcrumbs .crumb-btn:hover,#breadcrumbs .crumb-btn.here{color:var(--accent);border-color:var(--accent);}
|
|
489
|
+
#breadcrumbs .sep{color:var(--text-muted);}
|
|
490
|
+
|
|
491
|
+
#navbar{
|
|
492
|
+
position:absolute;bottom:16px;left:50%;transform:translateX(-50%);z-index:10;
|
|
493
|
+
display:flex;align-items:center;gap:4px;
|
|
494
|
+
background:var(--overlay);border:1px solid var(--panel-line);border-radius:9px;
|
|
495
|
+
padding:6px;backdrop-filter:blur(6px);
|
|
496
|
+
}
|
|
497
|
+
#navbar button{
|
|
498
|
+
background:transparent;border:none;color:var(--text-muted);white-space:nowrap;
|
|
499
|
+
font-size:12px;padding:7px 11px;border-radius:6px;cursor:pointer;
|
|
500
|
+
}
|
|
501
|
+
#navbar button:hover{color:var(--accent);background:var(--node-bg);}
|
|
502
|
+
#navbar .divider{width:1px;height:18px;background:var(--panel-line);margin:0 2px;}
|
|
503
|
+
/* the arrows are for touch screens; keyboards and clickers use the keys */
|
|
504
|
+
#navbar .touch-only{display:none;}
|
|
505
|
+
@media (pointer:coarse){ #navbar .touch-only{display:inline-block;} }
|
|
506
|
+
|
|
507
|
+
#minimap{
|
|
508
|
+
position:absolute;bottom:16px;right:14px;z-index:10;width:180px;height:130px;
|
|
509
|
+
background:var(--overlay);border:1px solid var(--panel-line);border-radius:8px;
|
|
510
|
+
backdrop-filter:blur(6px);overflow:hidden;
|
|
511
|
+
}
|
|
512
|
+
#minimap .mm-label{
|
|
513
|
+
position:absolute;top:5px;left:8px;font-family:var(--mono);font-size:9px;
|
|
514
|
+
color:var(--text-muted);letter-spacing:.1em;text-transform:uppercase;pointer-events:none;
|
|
515
|
+
}
|
|
516
|
+
#mm-svg circle{cursor:pointer;}
|
|
517
|
+
#stage-wrap[data-pip="bottom-right"] #minimap{right:auto;left:14px;}
|
|
518
|
+
|
|
519
|
+
/* channel mark: fixed in the corner, never moves with the camera */
|
|
520
|
+
#brand{
|
|
521
|
+
position:absolute;top:16px;right:18px;z-index:12;pointer-events:none;
|
|
522
|
+
display:flex;align-items:center;gap:10px;opacity:.9;
|
|
523
|
+
font-family:var(--display);font-weight:600;font-size:18px;letter-spacing:.02em;color:var(--text);
|
|
524
|
+
text-shadow:var(--brand-shadow);
|
|
525
|
+
}
|
|
526
|
+
#brand[hidden]{display:none;}
|
|
527
|
+
/* embedded in a site page: one read-only deck, so no editor, links or copies */
|
|
528
|
+
html.embed #btn-edit-toggle, html.embed #continue, html.embed #editor-pane, html.embed #editor-resizer{display:none !important;}
|
|
529
|
+
html.embed .brand .trail{display:flex;align-items:center;gap:10px;font-family:var(--display);font-weight:600;font-size:15px;min-width:0;}
|
|
530
|
+
html.embed .brand .trail a{color:var(--text);text-decoration:none;white-space:nowrap;}
|
|
531
|
+
html.embed .brand .trail a:hover{color:var(--accent);}
|
|
532
|
+
html.embed .brand .trail a:last-child{color:var(--accent);}
|
|
533
|
+
html.embed .brand .trail .sep{color:var(--text-muted);font-weight:400;}
|
|
534
|
+
#credit{display:inline-flex;align-items:center;gap:6px;padding:4px 6px;text-decoration:none;
|
|
535
|
+
font-family:var(--display);font-weight:700;font-size:14px;color:var(--text);}
|
|
536
|
+
#credit .logo{width:18px;height:18px;fill:var(--accent);}
|
|
537
|
+
#credit .word > span{color:var(--accent);}
|
|
538
|
+
#credit:hover{opacity:.85;}
|
|
539
|
+
html.embed #btn-help{display:none !important;}
|
|
540
|
+
/* a reader's page (embedded, not recording): no bottom bar, except the arrows on touch screens */
|
|
541
|
+
html.embed.no-record #navbar{display:none;}
|
|
542
|
+
@media (pointer:coarse){
|
|
543
|
+
html.embed.no-record #navbar{display:flex;}
|
|
544
|
+
html.embed.no-record #navbar > :not(.touch-only){display:none !important;}
|
|
545
|
+
}
|
|
546
|
+
html.no-record #btn-camera, html.no-record #btn-record, html.no-record #navbar .divider, html.no-record #pip, html.no-record #help tr.rec{display:none !important;}
|
|
547
|
+
/* the logo written into a heading: #  Slidetake */
|
|
548
|
+
.node .body :is(h1,h2) img[src$="favicon.svg"]{height:1em;width:auto;vertical-align:-.12em;margin-right:.25em;display:inline;}
|
|
549
|
+
#brand .st-mark{display:inline-flex;align-items:center;gap:8px;font-family:var(--display);font-weight:700;font-size:20px;color:var(--text);}
|
|
550
|
+
#brand .st-mark .logo{width:24px;height:24px;fill:var(--accent);}
|
|
551
|
+
#brand .st-mark .word > span{color:var(--accent);}
|
|
552
|
+
#brand img{height:40px;width:auto;display:block;}
|
|
553
|
+
/* optional gold chip, as on the decks' title slides (brand_style: chip); plain text is the default */
|
|
554
|
+
#brand .chip{display:inline-block;padding:5px 22px;border-radius:30px;color:#fff;font-family:var(--body);
|
|
555
|
+
font-size:15px;font-weight:600;letter-spacing:.01em;text-shadow:none;
|
|
556
|
+
background:linear-gradient(90deg, #fbbf24, #f59e0b);box-shadow:0 2px 10px rgba(0,0,0,.25);}
|
|
557
|
+
|
|
558
|
+
/* PIP camera: slides are laid out to keep clear of this box */
|
|
559
|
+
#pip{
|
|
560
|
+
position:absolute;z-index:11;pointer-events:none;aspect-ratio:16/9;
|
|
561
|
+
border:2px dashed color-mix(in srgb, var(--accent-teal) 55%, transparent);border-radius:10px;
|
|
562
|
+
display:flex;align-items:center;justify-content:center;
|
|
563
|
+
font-family:var(--mono);font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--accent-teal);
|
|
564
|
+
background:color-mix(in srgb, var(--accent-teal) 4%, transparent);
|
|
565
|
+
}
|
|
566
|
+
#pip[hidden]{display:none;}
|
|
567
|
+
#pip.circle{aspect-ratio:1;border-radius:50%;}
|
|
568
|
+
#pip.top-left{top:16px;left:16px;}
|
|
569
|
+
#pip.top-right{top:16px;right:16px;}
|
|
570
|
+
#pip.bottom-left{bottom:16px;left:16px;}
|
|
571
|
+
#pip.bottom-right{bottom:16px;right:16px;}
|
|
572
|
+
/* full: the camera takes the whole stage, under the brand and the controls */
|
|
573
|
+
/* it also swallows clicks, so a click can't land on the hidden cards behind it */
|
|
574
|
+
#pip.full{inset:0;width:100% !important;height:100%;aspect-ratio:auto;border-radius:0;z-index:9;pointer-events:auto;}
|
|
575
|
+
/* while presenting the box is empty so the camera overlay sits on plain background */
|
|
576
|
+
/* while presenting, the empty box stays as a faint guide for lining up a camera overlay */
|
|
577
|
+
body.presenting #pip{border-color:color-mix(in srgb, var(--accent-teal) 30%, transparent);background:none;}
|
|
578
|
+
body.presenting #pip span{opacity:.5;}
|
|
579
|
+
/* live webcam inside the box */
|
|
580
|
+
#pip.live{border:none;background:#000;overflow:hidden;box-shadow:0 8px 30px rgba(0,0,0,.55), 0 0 0 1px var(--panel-line);}
|
|
581
|
+
#pip.live span{display:none;}
|
|
582
|
+
#pip video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;}
|
|
583
|
+
#pip.mirror video{transform:scaleX(-1);}
|
|
584
|
+
#pip-msg{
|
|
585
|
+
position:absolute;left:50%;top:70px;transform:translateX(-50%);z-index:30;
|
|
586
|
+
background:var(--panel);border:1px solid var(--danger);color:var(--text);
|
|
587
|
+
font-family:var(--mono);font-size:13px;line-height:1.5;padding:10px 16px;border-radius:6px;display:none;
|
|
588
|
+
width:max-content;max-width:min(620px, 90%);text-align:center;box-shadow:0 8px 30px rgba(0,0,0,.5);
|
|
589
|
+
}
|
|
590
|
+
#pip-msg.show{display:block;}
|
|
591
|
+
|
|
592
|
+
/* ---------- help popover ---------- */
|
|
593
|
+
#help{position:fixed;inset:0;background:rgba(4,7,13,.7);z-index:50;display:none;align-items:center;justify-content:center;}
|
|
594
|
+
#help.open{display:flex;}
|
|
595
|
+
#help .panel{
|
|
596
|
+
position:relative;width:min(580px,92vw);max-height:84vh;overflow-y:auto;
|
|
597
|
+
background:var(--panel);border:1px solid var(--panel-line);border-radius:12px;padding:26px 28px;
|
|
598
|
+
}
|
|
599
|
+
#help h2{font-family:var(--display);font-size:18px;margin:0 0 14px;color:var(--accent);}
|
|
600
|
+
#help h3{font-family:var(--display);font-size:13px;margin:18px 0 6px;color:var(--text);}
|
|
601
|
+
#help p, #help li{font-size:13px;line-height:1.65;color:var(--text-muted);margin:0 0 8px;}
|
|
602
|
+
#help pre{
|
|
603
|
+
background:var(--code-bg);border:1px solid var(--panel-line);border-radius:6px;
|
|
604
|
+
padding:10px 12px;font-family:var(--mono);font-size:11.5px;color:var(--text);overflow-x:auto;
|
|
605
|
+
}
|
|
606
|
+
#help .close{position:absolute;top:16px;right:18px;background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;}
|
|
607
|
+
kbd{
|
|
608
|
+
font-family:var(--mono);background:var(--node-bg);border:1px solid var(--node-border);
|
|
609
|
+
border-radius:4px;padding:1px 6px;font-size:11px;color:var(--accent);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
@media (max-width:760px){
|
|
613
|
+
main{flex-direction:column;}
|
|
614
|
+
#editor-pane{width:100% !important;max-width:none;min-width:0;height:40vh;border-left:none;border-top:1px solid var(--panel-line);}
|
|
615
|
+
#editor-resizer{display:none;}
|
|
616
|
+
#editor-pane.collapsed{height:0;}
|
|
617
|
+
#stage-wrap{flex:1;}
|
|
618
|
+
.brand .tagline{display:none;}
|
|
619
|
+
#minimap{display:none;}
|
|
620
|
+
#navbar .lbl{display:none;}
|
|
621
|
+
}
|
|
622
|
+
</style>
|
|
623
|
+
</head>
|
|
624
|
+
<body>
|
|
625
|
+
<noscript>
|
|
626
|
+
<h1>Slidetake</h1>
|
|
627
|
+
<p><strong>Write in markdown. Present on a spatial canvas. Record without timeline editing.</strong></p>
|
|
628
|
+
<p>For developers and technical educators who explain things on video. Your headings become a map you move through; with OBS, every slide is a take, so a fumbled line is retaken on the spot, and Slidetake writes the frame-exact cut, YouTube chapters and description.</p>
|
|
629
|
+
<p>Slidetake needs JavaScript. Read the <a href="/help.md">guide</a>, the <a href="/llms.txt">summary</a>, or the source on <a href="https://github.com/slidetake/slidetake">GitHub</a>.</p>
|
|
630
|
+
</noscript>
|
|
631
|
+
|
|
632
|
+
<header>
|
|
633
|
+
<div class="brand">
|
|
634
|
+
<a class="mark" href="/" title="Slidetake home"><svg class="logo" viewBox="0 0 64 64" aria-hidden="true"><path d="M 10 8 H 38 C 41.3 8 44 10.7 44 14 V 18 H 22 C 16.5 18 12 22.5 12 28 V 36 H 10 C 6.7 36 4 33.3 4 30 V 14 C 4 10.7 6.7 8 10 8 Z" opacity="0.4"/><path fill-rule="evenodd" d="M 22 22 H 54 C 57.3 22 60 24.7 60 28 V 50 C 60 53.3 57.3 56 54 56 H 22 C 18.7 56 16 53.3 16 50 V 28 C 16 24.7 18.7 22 22 22 Z M 26 34 C 28.2 34 30 32.2 30 30 C 30 27.8 28.2 26 26 26 C 23.8 26 22 27.8 22 30 C 22 32.2 23.8 34 26 34 Z M 38 40 C 36.9 40 36 40.9 36 42 V 48 C 36 49.1 36.9 50 38 50 H 50 C 51.1 50 52 49.1 52 48 V 42 C 52 40.9 51.1 40 50 40 H 38 Z"/></svg><span class="word">Slide<span>take</span></span></a>
|
|
635
|
+
<div class="tagline">plain markdown → spatial deck → video</div>
|
|
636
|
+
</div>
|
|
637
|
+
<div class="hdr-actions">
|
|
638
|
+
<input type="file" id="file-input" accept=".md,.markdown,.txt,text/markdown" hidden>
|
|
639
|
+
<div class="seg" id="layout-toggle">
|
|
640
|
+
<button class="seg-btn" data-mode="tree" title="Tree (1)">tree</button>
|
|
641
|
+
<button class="seg-btn" data-mode="radial" title="Radial (2)">radial</button>
|
|
642
|
+
<button class="seg-btn" data-mode="path" title="Path: slides in presenting order (3)">path</button>
|
|
643
|
+
<button class="seg-btn" data-mode="focus" title="Focus: one slide at a time, no travel (4)">focus</button>
|
|
644
|
+
</div>
|
|
645
|
+
<a class="btn" id="continue" href="/edit" hidden></a>
|
|
646
|
+
<button class="btn" id="btn-edit-toggle" title="Editor: write, open, share (E)">✎ Editor</button>
|
|
647
|
+
<button class="btn icon" id="btn-mode" title="Light / dark (L)" aria-label="Light / dark"></button>
|
|
648
|
+
<button class="btn icon" id="btn-help" title="Help: the full guide (? for keys)" aria-label="Help">?</button>
|
|
649
|
+
</div>
|
|
650
|
+
</header>
|
|
651
|
+
|
|
652
|
+
<main>
|
|
653
|
+
<div id="stage-wrap">
|
|
654
|
+
<div id="stage">
|
|
655
|
+
<div id="world">
|
|
656
|
+
<svg id="connectors"></svg>
|
|
657
|
+
</div>
|
|
658
|
+
</div>
|
|
659
|
+
<div id="breadcrumbs"></div>
|
|
660
|
+
<div id="navbar">
|
|
661
|
+
<button id="btn-keys" title="Keyboard shortcuts (K)">⌨<span class="lbl"> Keys</span></button>
|
|
662
|
+
<button id="nav-prev" class="touch-only" title="Previous (←)" aria-label="Previous">←</button>
|
|
663
|
+
<button id="nav-next" class="touch-only" title="Next (→)" aria-label="Next">→</button>
|
|
664
|
+
<div class="divider"></div>
|
|
665
|
+
<button id="btn-camera" title="Camera (C)" aria-pressed="false"></button>
|
|
666
|
+
<button id="btn-record" title="Record a take with OBS (R)">●<span class="lbl"> Record</span></button>
|
|
667
|
+
<button id="btn-present" title="Fullscreen (F)">⛶<span class="lbl"> Fullscreen</span></button>
|
|
668
|
+
</div>
|
|
669
|
+
<div id="progress" aria-hidden="true"></div>
|
|
670
|
+
<div id="minimap"><div class="mm-label" id="mm-label">map</div><svg id="mm-svg" width="180" height="130"></svg></div>
|
|
671
|
+
<div id="brand" hidden></div>
|
|
672
|
+
<div id="pip" hidden><span>PIP camera</span></div>
|
|
673
|
+
<div id="pip-msg" role="status"></div>
|
|
674
|
+
</div>
|
|
675
|
+
<div id="editor-resizer" role="separator" aria-orientation="vertical" aria-label="Resize the editor" title="Drag to resize"></div>
|
|
676
|
+
<div id="editor-pane" class="collapsed">
|
|
677
|
+
<div class="pane-bar">
|
|
678
|
+
<span class="pane-label" id="doc-state" aria-live="polite"></span>
|
|
679
|
+
<span class="pane-actions">
|
|
680
|
+
<a class="btn small" id="btn-new" href="/new" title="Start from a template">New</a>
|
|
681
|
+
<button class="btn small" id="btn-load" title="Load a deck from a link: GitHub, a gist or any URL">⇣ Load</button>
|
|
682
|
+
<button class="btn small" id="btn-open" title="Open a markdown file from this computer">Open</button>
|
|
683
|
+
<button class="btn small" id="btn-save" title="Save the markdown to a file on this computer">Save</button>
|
|
684
|
+
<button class="btn small" id="btn-share" title="Copy a link to this deck">Share</button>
|
|
685
|
+
</span>
|
|
686
|
+
</div>
|
|
687
|
+
<textarea id="editor" spellcheck="false"></textarea>
|
|
688
|
+
<div id="status-line"><span id="status-count"></span><span id="status-err" class="err"></span><button id="btn-reset" hidden title="Discard your edits and go back to the original">reset to original</button></div>
|
|
689
|
+
</div>
|
|
690
|
+
</main>
|
|
691
|
+
|
|
692
|
+
<div id="help">
|
|
693
|
+
<div class="panel">
|
|
694
|
+
<button class="close" id="help-close" aria-label="Close">✕</button>
|
|
695
|
+
<h2>Keys</h2>
|
|
696
|
+
<table class="keys">
|
|
697
|
+
<tr><td><kbd>→</kbd> <kbd>←</kbd> <kbd>Space</kbd></td><td>next / previous step</td></tr>
|
|
698
|
+
<tr><td><kbd>↓</kbd> <kbd>↑</kbd></td><td>first child / parent</td></tr>
|
|
699
|
+
<tr><td><kbd>O</kbd></td><td>the whole map; <kbd>O</kbd> or <kbd>Esc</kbd> goes back</td></tr>
|
|
700
|
+
<tr><td><kbd>1</kbd>–<kbd>4</kbd></td><td>tree, radial, path, focus</td></tr>
|
|
701
|
+
<tr><td><kbd>F</kbd></td><td>fullscreen</td></tr>
|
|
702
|
+
<tr><td><kbd>+</kbd> <kbd>−</kbd></td><td>bigger / smaller slides</td></tr>
|
|
703
|
+
<tr><td><kbd>E</kbd></td><td>editor: write, open, share</td></tr>
|
|
704
|
+
<tr><td><kbd>L</kbd></td><td>light / dark</td></tr>
|
|
705
|
+
<tr class="rec"><td><kbd>C</kbd> <kbd>V</kbd> <kbd>R</kbd></td><td>camera, camera layouts, record</td></tr>
|
|
706
|
+
<tr><td><kbd>K</kbd> <kbd>?</kbd></td><td>this card</td></tr>
|
|
707
|
+
</table>
|
|
708
|
+
<p>Drag to pan, scroll or pinch to zoom, click a card to fly to it.</p>
|
|
709
|
+
<p><a href="/help" target="_blank" rel="noopener">The full guide →</a> writing decks, sharing, recording, camera, review and cut.</p>
|
|
710
|
+
</div>
|
|
711
|
+
</div>
|
|
712
|
+
|
|
713
|
+
<div id="new-dialog" class="modal" role="dialog" aria-labelledby="new-title">
|
|
714
|
+
<div class="panel">
|
|
715
|
+
<button class="close" data-close aria-label="Close">✕</button>
|
|
716
|
+
<h2 id="new-title">Start a new deck</h2>
|
|
717
|
+
<p>Pick a template. It opens as it is; start typing and it becomes your own copy at <code>/edit</code>.</p>
|
|
718
|
+
<ul class="templates">
|
|
719
|
+
<li><a href="/new?template=blank"><strong>Blank</strong><span>A first card, a section and a detail.</span></a></li>
|
|
720
|
+
<li><a href="/new?template=talk"><strong>Talk</strong><span>Why it matters, the idea, trade-offs, summary.</span></a></li>
|
|
721
|
+
<li><a href="/new?template=recording"><strong>Recording</strong><span>Camera steps, an overview moment and a closing on camera.</span></a></li>
|
|
722
|
+
<li><a href="/examples"><strong>Examples</strong><span>Everything a deck can hold: diagrams, charts, images, YouTube.</span></a></li>
|
|
723
|
+
</ul>
|
|
724
|
+
<p>Or <strong>⇣ Load</strong> a deck from a link, or <strong>Open</strong> a file from this computer.</p>
|
|
725
|
+
</div>
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
<div id="open-dialog" class="modal" role="dialog" aria-labelledby="open-title">
|
|
729
|
+
<div class="panel">
|
|
730
|
+
<button class="close" data-close aria-label="Close">✕</button>
|
|
731
|
+
<h2 id="open-title">Load a deck from a link</h2>
|
|
732
|
+
<p>Paste a link to a markdown file: a GitHub file or folder, a gist, or any URL that allows other sites to read it.</p>
|
|
733
|
+
<form id="open-form" class="row">
|
|
734
|
+
<input type="text" id="open-url" placeholder="https://github.com/you/repo/blob/main/talk.md" spellcheck="false" autocomplete="off">
|
|
735
|
+
<button class="btn primary" type="submit">Load</button>
|
|
736
|
+
</form>
|
|
737
|
+
<p id="open-error" class="warn" hidden></p>
|
|
738
|
+
<h3>Try one</h3>
|
|
739
|
+
<ul id="open-examples">
|
|
740
|
+
<li><a href="/gh/slidetake/slidetake/examples/why-debt-is-not-bad.md">Why debt is a tool, not an enemy</a> (headings format)</li>
|
|
741
|
+
<li><a href="/gh/sakthipriyan/sakthipriyan.github.io/content/building-wealth/slides/2025/invest-in-gold/index.md">Invest in gold</a> (a reveal.js deck)</li>
|
|
742
|
+
</ul>
|
|
743
|
+
<h3>Short links</h3>
|
|
744
|
+
<p><code>slidetake.com/gh/owner/repo/path/deck.md</code> opens a file on GitHub (add <code>@branch</code> after the repo for another branch), and <code>slidetake.com/gist/<id></code> a gist. Images next to the deck load as they are.</p>
|
|
745
|
+
<p>A file on this computer? Use <strong>Open</strong>.</p>
|
|
746
|
+
</div>
|
|
747
|
+
</div>
|
|
748
|
+
|
|
749
|
+
<div id="rec-dialog" class="modal" role="dialog" aria-labelledby="rec-title">
|
|
750
|
+
<div class="panel">
|
|
751
|
+
<button class="close" data-close aria-label="Close">✕</button>
|
|
752
|
+
<h2 id="rec-title">Record a take</h2>
|
|
753
|
+
<p id="rec-deck-info"></p>
|
|
754
|
+
<p id="rec-screen"></p>
|
|
755
|
+
<h3>OBS</h3>
|
|
756
|
+
<div class="fields">
|
|
757
|
+
<label>Host<input type="text" id="obs-host" value="localhost" spellcheck="false"></label>
|
|
758
|
+
<label>Port<input type="text" id="obs-port" value="4455" inputmode="numeric"></label>
|
|
759
|
+
<label>Password<input type="password" id="obs-pass" autocomplete="off"></label>
|
|
760
|
+
</div>
|
|
761
|
+
<label class="check"><input type="checkbox" id="obs-remember"> Remember these on this computer</label>
|
|
762
|
+
<div class="row"><button class="btn" id="obs-connect">Connect</button><span id="obs-status">Not connected</span></div>
|
|
763
|
+
<p>In OBS: Tools → WebSocket Server Settings → enable it; the port and password are shown there. Point OBS at this browser window plus your microphone. No scenes are needed: the deck switches the camera itself.</p>
|
|
764
|
+
<h3>During the take</h3>
|
|
765
|
+
<ul>
|
|
766
|
+
<li><kbd>→</kbd> / clicker next: the next step. One more press after the last step ends the take and stops OBS.</li>
|
|
767
|
+
<li><kbd>←</kbd> / clicker back: <strong>take this slide again</strong>. Every attempt is kept; you pick the best one afterwards.</li>
|
|
768
|
+
<li><kbd>B</kbd> / clicker blank: pause and resume the recording.</li>
|
|
769
|
+
<li><kbd>Esc</kbd>: stop the take early.</li>
|
|
770
|
+
</ul>
|
|
771
|
+
<label style="margin-top:14px">Layout for this take
|
|
772
|
+
<select id="rec-layout">
|
|
773
|
+
<option value="path">Path: short, one-direction moves (recommended)</option>
|
|
774
|
+
<option value="focus">Focus: no travel, slides fade in</option>
|
|
775
|
+
<option value="current">Keep the current layout</option>
|
|
776
|
+
</select>
|
|
777
|
+
</label>
|
|
778
|
+
<div id="rec-sessions"></div>
|
|
779
|
+
<div class="row end">
|
|
780
|
+
<button class="btn" id="rec-rehearse">Rehearse (no recording)</button>
|
|
781
|
+
<button class="btn primary" id="rec-start" disabled>● Start recording</button>
|
|
782
|
+
</div>
|
|
783
|
+
</div>
|
|
784
|
+
</div>
|
|
785
|
+
|
|
786
|
+
<div id="review" class="modal" role="dialog" aria-labelledby="rv-title">
|
|
787
|
+
<div class="panel xwide">
|
|
788
|
+
<button class="close" data-close aria-label="Close">✕</button>
|
|
789
|
+
<h2 id="rv-title">Review the take</h2>
|
|
790
|
+
<p id="rv-info"></p>
|
|
791
|
+
<div class="rv-grid">
|
|
792
|
+
<div>
|
|
793
|
+
<div class="rv-video">
|
|
794
|
+
<video id="rv-video" controls playsinline preload="metadata"></video>
|
|
795
|
+
<div id="rv-novideo">
|
|
796
|
+
<div class="row" style="justify-content:center;margin:0">
|
|
797
|
+
<button class="btn primary" id="rv-open">Open the recording file…</button>
|
|
798
|
+
<button class="btn" id="rv-folder" hidden>Use my OBS recordings folder…</button>
|
|
799
|
+
</div>
|
|
800
|
+
<p>Pick the file OBS saved<span id="rv-file"></span> (.mov, .mp4 or .mkv) to preview takes. Or choose your OBS recordings folder once, and later takes load by themselves.</p>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
<div class="row"><button class="btn small" id="rv-play-final">▶ Play the final cut</button><span id="rv-now"></span></div>
|
|
804
|
+
</div>
|
|
805
|
+
<div class="rv-list" id="rv-list"></div>
|
|
806
|
+
</div>
|
|
807
|
+
<div class="rv-out">
|
|
808
|
+
<h3>ffmpeg
|
|
809
|
+
<select id="rv-mode">
|
|
810
|
+
<option value="accurate">Frame-accurate (x264)</option>
|
|
811
|
+
<option value="mac">Frame-accurate, Mac hardware encoder (faster)</option>
|
|
812
|
+
<option value="copy">No re-encode (only when nothing is cut out)</option>
|
|
813
|
+
</select>
|
|
814
|
+
<select id="rv-fps" title="Recording frame rate: cut points snap to its frames">
|
|
815
|
+
<option value="24">24 fps</option><option value="25">25 fps</option><option value="30">30 fps</option>
|
|
816
|
+
<option value="50">50 fps</option><option value="60">60 fps</option>
|
|
817
|
+
<option value="23.976">23.976 fps</option><option value="29.97">29.97 fps</option><option value="59.94">59.94 fps</option>
|
|
818
|
+
</select>
|
|
819
|
+
<button class="btn small" data-copy="rv-ffmpeg">Copy</button>
|
|
820
|
+
</h3>
|
|
821
|
+
<textarea id="rv-ffmpeg" rows="4" readonly spellcheck="false"></textarea>
|
|
822
|
+
<h3>YouTube</h3>
|
|
823
|
+
<div class="two">
|
|
824
|
+
<label>Title<input type="text" id="rv-yt-title"></label>
|
|
825
|
+
<label>Slides link (goes in the description)<input type="text" id="rv-link" placeholder="https://…/slides/…/" spellcheck="false"></label>
|
|
826
|
+
</div>
|
|
827
|
+
<h3>Description <button class="btn small" data-copy="rv-yt-desc">Copy</button></h3>
|
|
828
|
+
<textarea id="rv-yt-desc" rows="10" spellcheck="false"></textarea>
|
|
829
|
+
<p id="rv-chapters-note"></p>
|
|
830
|
+
<h3>Tags <button class="btn small" data-copy="rv-yt-tags">Copy</button></h3>
|
|
831
|
+
<input type="text" id="rv-yt-tags" spellcheck="false" style="width:100%">
|
|
832
|
+
</div>
|
|
833
|
+
<div class="row end">
|
|
834
|
+
<button class="btn" id="rv-download">↓ Download script + publish pack</button>
|
|
835
|
+
<button class="btn primary" data-close>Done</button>
|
|
836
|
+
</div>
|
|
837
|
+
</div>
|
|
838
|
+
</div>
|
|
839
|
+
<input type="file" id="rv-file-input" accept="video/*,video/quicktime,.mov,.mp4,.m4v,.mkv,.webm" hidden>
|
|
840
|
+
|
|
841
|
+
<div id="rec-countdown"><div class="num"></div><div class="hint">recording starts after the countdown · Esc to cancel</div></div>
|
|
842
|
+
<div id="rec-paused">Paused · press B to resume</div>
|
|
843
|
+
|
|
844
|
+
<!-- The sample deck. Plain markdown, nothing else. -->
|
|
845
|
+
<script>
|
|
846
|
+
"use strict";
|
|
847
|
+
(() => {
|
|
848
|
+
// src/sample.md
|
|
849
|
+
var sample_default = "---\ntitle: Slidetake \u2014 write in markdown, record without timeline editing\nbrand: slidetake\npip: bottom-right\n---\n\n<!-- camera: on, full, on -->\n\n#  Slidetake\n\n**Write in markdown. Present on a spatial canvas. Record without timeline editing.**\n\nFor developers and technical educators who explain things on video. You're inside a Slidetake deck right now: press \u2192 to walk it, **O** for the map.\n\n## \u2702\uFE0F Stop editing on a timeline\n\n**Retake by slide.** The slide is the timeline marker, so a fumbled line costs one press, not an editing session.\n\n### Every slide is a take\n\nStumbled on a slide? Press \u2190 and say it again. Every attempt is kept, and recording carries on.\n\n### Pick, don't scrub\n\nChoose the best take of each slide. Slidetake writes the frame-exact **ffmpeg** cut, the YouTube **chapters** and the description.\n\n## \u{1F5FA}\uFE0F A map, not a stack\n\n<!-- view: overview -->\n\nYour headings are the hierarchy: zoom out for the whole system, zoom in for one part. This slide just showed you the map.\n\n### Headings become cards\n\n`#` is the first card, `##` branches from it, `###` goes a level deeper. No layout to draw.\n\n### A path your viewer can follow\n\n\u2192 always walks the same order, and **path** lays it out as a staircase, so the audience never loses its place.\n\n## \u{1F3A5} The camera is part of the deck\n\n<!-- camera: on, full, on -->\n\nA comment in a slide moves you: corner, full screen, or off. Turn on **Camera** and watch this slide do it.\n\n### Broadcast-quality recording\n\n**[OBS](https://obsproject.com)** records at full quality; Slidetake drives it. No scenes to switch, no recording to watch.\n\n### One session, one finished video\n\nWrite, present and record in one sitting. What comes out is ready to upload.\n\n## \u270D\uFE0F Plain text in\n\nMarkdown you already know: headings, lists, tables, code, diagrams, charts, images and YouTube links. [See every example \u2192](/examples)\n\n### Your copy\n\nType in any deck, this one included, and it becomes your own copy. The original stays as it is.\n\n### Open and share\n\n**\u21E3 Load** a GitHub file or gist, start from a template, and **Share** a link with the deck inside it.\n\n## \u{1F49B} Free and open\n\nOpen source, Apache 2.0: [github.com/slidetake/slidetake](https://github.com/slidetake/slidetake).\n\nEverything else is in the guide: **[slidetake.com/help](/help)**.\n";
|
|
850
|
+
|
|
851
|
+
// src/help.md
|
|
852
|
+
var help_default = "---\ntitle: Slidetake help\nbrand: slidetake\npip: none\n---\n\n#  Slidetake help\n\nThe details behind the [home deck](/): writing, sharing, presenting, recording and the camera. Press \u2192 to read in order, \u2193 \u2191 to go into a section and back out, or **O** for the whole map.\n\n## \u270D\uFE0F Writing a deck\n\nA deck is an ordinary markdown file. **Every heading becomes a card**, and a heading branches off the nearest shallower heading above it.\n\n```md\n# Product \u2190 the first card\nIntro text.\n\n## Pricing \u2190 branches from Product\n### Enterprise \u2190 branches from Pricing\n## Roadmap {#plan} \u2190 branches from Product, id \"plan\"\n\nSee the [roadmap](#plan).\n```\n\n### Rules\n\n- Text before the first heading becomes a card of its own.\n- Headings inside fenced code blocks are ignored.\n- A card's id is its heading slugified (`## Moving around` \u2192 `moving-around`), or set one with `{#id}` at the end of the heading.\n- A link to `#id` flies to that card.\n\n### What a card can hold\n\nPlain markdown, and the layout follows from what's on the card. [See every one \u2192](/examples)\n\n| Write | Get |\n|---|---|\n| `<!-- steps -->` before a list | one item per press |\n| ` ```dot `, ` ```d2 ` | a Graphviz or D2 diagram |\n| ` ```echarts ` with JSON options | a chart, in the deck's colors for dark and light |\n| ` ```svg ` or `` | an SVG drawing |\n| an image alone | an image card: a phone shot sits beside the heading and caption, a landscape one spans the card between them, a 16:9 one fills it |\n| an image and text | a split card: the image sits on the side written first |\n| a list of images | a gallery; with `<!-- steps -->` a carousel, one image per press, laid out like an image card |\n| `<!-- view: full -->` in a card | the card fills the whole screen |\n| images in one paragraph | a grid, up to four a row |\n| a YouTube link alone on a line | the video: the next press plays it, leaving pauses it |\n\nThe first and last cards animate in on their own. The alt text of an image is its caption.\n\n### reveal.js decks\n\nDecks written for reveal.js open as they are: `---` starts a slide and `--` a vertical one beneath it, and the first slide becomes the root card.\n\nSupported: fragments (`fade-up`, `fade-in-then-out`, `grow`, \u2026, one per \u2192), `r-stack`, `<!-- .element: \u2026 -->`, `<section>` slides, `data-autoslide`, Graphviz `dot` diagrams, ECharts charts, `data-gsap` entrance animations and `title-scramble`.\n\n### Older +++ decks\n\nDecks that separate slides with `+++` and use `id`, `parent`, `x`, `y` frontmatter still load.\n\n### Wide content\n\nCards widen for wide tables, columns, diagrams and embeds; anything wider still is scaled to fit.\n\n## \u{1F517} Opening, editing and sharing\n\nEvery deck you open is **read-only**: Slidetake's own decks, templates, files on the web and shared links. Viewing one never changes anything.\n\n**Type in it**, and it becomes **your copy**, at `/edit`. Your copy lives in this browser, remembers where it came from, and is there whenever you come back: the **Your copy \u2192** button at the top takes you to it.\n\n### Where decks come from\n\nPress **\u270E Editor**, then **\u21E3 Load**, and paste a link: a GitHub file or folder, a gist, or any URL that lets other sites read it. Or link straight to a deck:\n\n| Link | Opens |\n|---|---|\n| `/gh/owner/repo/path/deck.md` | a GitHub file, default branch |\n| `/gh/owner/repo@branch/deck.md` | another branch or tag |\n| `/gist/<id>` | a gist's first markdown file |\n| `/?src=https://\u2026/deck.md` | anything else |\n| `/share#deflate:\u2026` | a shared deck, carried inside the link |\n| `/new` | a template: blank, talk or recording |\n\nImages next to the deck load as they are. **Open** opens a markdown file from your computer, straight into your copy.\n\n### Your copy\n\nThere's one working copy at a time. The editor bar says whose copy it is, and marks **edited** while it has changes you haven't saved or shared.\n\n- **Reset to original** throws your edits away and goes back to the deck you started from.\n- Starting a new copy, by typing in another deck or opening a file, asks first if the old one has edits you haven't kept.\n\n### Saving and sharing\n\n**Save** downloads your markdown as a file. **Share** copies a link: the short link while your copy still matches an online original, and otherwise a `/share#deflate:\u2026` link with the whole deck compressed inside it. That part of a link is never sent to a server, so nothing is uploaded. Shared links never include `?obs=`.\n\nFor a file from your computer whose images sit next to it online, add `base: https://\u2026/deck-folder/` to its top block.\n\n### Address options\n\n| Option | Does |\n|---|---|\n| `?edit=1` | opens the editor |\n| `?layout=tree` (radial, path, focus) | picks the layout |\n| `?mode=light` | light theme |\n| `?duration=10m` | talk length for the timer |\n| `#card-id` | opens at a card |\n\n## \u{1F9ED} Moving around\n\n| Key | Does |\n|---|---|\n| \u2192 \u2190 Space | next / previous step, in document order |\n| \u2193 \u2191 | first child / parent |\n| O | the whole map; O or Esc goes back to your slide |\n| 1 2 3 4 | tree, radial, path, focus |\n| F | fullscreen |\n| + \u2212 | bigger / smaller slides (remembered) |\n| E | editor |\n| L | light / dark |\n| K or ? | keys (also \u2328 Keys on screen) |\n| C \xB7 V \xB7 R | camera, camera layouts, record |\n\nClick a card to fly to it. Drag to pan; scroll or pinch to zoom. On a touch screen, the bottom bar adds \u2190 \u2192 buttons.\n\n### Layouts\n\n**Tree** is a top-down chart and **radial** rings out from the root.\n\n**Path** is made for video: a staircase in presenting order. Each section is a row, and the next one starts just below where the last ended, so every move is a short step right or down.\n\n**Focus** doesn't travel at all: the next slide fades in where the last one was.\n\n### Steady text\n\nText keeps one size within a section and only changes when the section does. Charts and diagrams are fitted on their own.\n\n### Map moments\n\n`<!-- view: overview -->` on a slide pulls back to the whole map for a beat before flying in: a good start to a chapter.\n\n## \u{1F3AC} Presenting\n\n**F** goes fullscreen. The current slide fills the screen, and the cursor and controls hide after two seconds without the mouse moving.\n\n### Progress and talk timer\n\nWhile presenting, a thin bar along the bottom fills with every press.\n\nGive the deck a length, `duration: 10m` (or `90s`, `1h`, `12:30`), and a lighter layer of the same colour grows behind it with the clock: if the lighter stretch shows past the solid fill, you're behind; if it reaches the end, the bar pulses.\n\nThe timer is for you, so recordings show progress only, unless the deck says `timer: always`. `progress: off` hides the bar.\n\n## \u23FA\uFE0F Recording\n\nRecording needs **[OBS Studio](https://obsproject.com)** (free) with its WebSocket server on: in OBS, Tools \u2192 WebSocket Server Settings. OBS records; Slidetake drives it.\n\n### Connecting to OBS\n\nPress **\u25CF Record** and enter where OBS is: host, port and the password from OBS's WebSocket settings. Tick *Remember* to skip this next time.\n\n`?obs=localhost:4455` (or `?obs=host:port:password`) in the address fills this in and connects as the page opens.\n\n### A 16:9 screen\n\nYouTube is 16:9, and many laptop screens aren't. The Record dialog checks yours: if it isn't 16:9, move the window to a screen that is, physical or virtual (say 1920\xD71080), and press **F** there.\n\n### OBS on another computer\n\nFrom https://slidetake.com, OBS must be on the same computer (`localhost`): browsers block secure pages from reaching plain `ws://` addresses elsewhere. For OBS on another machine, serve a local copy of [`dist/index.html`](https://github.com/slidetake/slidetake) over http.\n\n### Taking a take\n\n**\u25CF Record** (or **R**) connects to OBS, counts down and starts recording. From then on the deck drives everything: camera layouts, reveals and slides follow \u2192 (a Bluetooth clicker works).\n\n- **\u2190** takes the current slide again, keeping every attempt\n- **B** pauses and resumes\n- one press past the last step stops OBS\n\nClicks, dragging and the map are locked so the take only moves forward.\n\n### Review and cut\n\nThen the review opens: every slide with its takes (the last one picked), previews from the OBS file, a ready-to-run **ffmpeg** command for the picked takes (frame-exact), and the YouTube title, description with **chapters** and links, and tags.\n\nSessions are kept in this browser, so a take can be reviewed again later from \u25CF Record.\n\n## \u{1F4F7} Camera\n\n**C** (or **Camera** in the bottom bar) turns your webcam on in its box; a plain screen recording then captures you and the slides together. The camera is off every time the page opens, and until it's on, the deck's camera settings are ignored, so readers get slides using the whole screen.\n\n### Deck settings\n\nAn optional block at the top of the file:\n\n```yaml\n---\nbrand: example.com/talks \u2190 text in the top-right corner\nlogo: https://\u2026/logo.png \u2190 image beside it\npip: bottom-right \u2190 camera corner, or none\npip_size: 24% \u2190 camera box width\npip_shape: rect \u2190 rect (16:9) or circle\npip_mirror: yes \u2190 mirror the webcam\ncamera: 24%, 40%, full, off \u2190 layouts V cycles through\n---\n```\n\nSlides are always placed clear of the brand and the camera box.\n\n### Camera per slide\n\nA comment in a slide changes the camera from that slide on:\n\n```md\n## Intro\n<!-- camera: full --> \u2190 camera fills the screen\n\n## Pricing\n<!-- camera: 18% flip --> \u2190 small, on the other side\n```\n\nWords you can combine: `on`, `off`, `full`, a size like `30%`, a corner, `flip`, `circle` / `rect`, `mirror` / `unmirror`.\n\n### Several steps on one slide\n\nList layouts with commas to step through them: `full, on` opens full screen on you, and the next \u2192 shrinks the camera to its corner and shows the slide. `on, full, on, off` ends a closing slide on you, then the slide again, then without the camera.\n\n**V** steps through the deck's `camera:` list for the current slide.\n\n## \u{1F4CB} Publish pack\n\nThe review fills the YouTube description from the deck's top block:\n\n| Key | Used for |\n|---|---|\n| `title` | the video title |\n| `summary` | the description's first paragraph |\n| `related` | a list of `[Title](url)` links |\n| `tags` | tags (any other list ending in `_tags` is added too) |\n| `permalink` or `site` | the link back to the deck |\n\n## \u{1F512} Your data\n\nYour draft and settings stay in this browser. Decks inside links live in the part of the address after `#`, which browsers never send to a server. Slidetake has no accounts and stores no decks.\n\nslidetake.com counts visits with Google Analytics. What it records leaves out the `#` part and `?obs=`, so neither your deck nor an OBS password reaches it. Copies you host yourself send nothing.\n\nSlidetake is open source: [github.com/slidetake/slidetake](https://github.com/slidetake/slidetake).\n";
|
|
853
|
+
|
|
854
|
+
// examples/blank.md
|
|
855
|
+
var blank_default = "---\ntitle: My deck\n---\n\n# My deck\n\nStart typing: this becomes your own copy, and the template stays as it is.\n\n## A section\n\nEvery heading is a card. `##` sections branch from the first card.\n\n### A detail\n\n`###` branches from the section above it.\n";
|
|
856
|
+
|
|
857
|
+
// examples/talk.md
|
|
858
|
+
var talk_default = "---\ntitle: Talk title\nduration: 15m\n---\n\n# Talk title\n\nOne line on what the audience will take away.\n\n## \u{1F9ED} Why this matters\n\n- The problem, in the audience's words\n- Why now\n- What changes if it's solved\n\n## \u{1F4A1} The idea\n\nThe one thing to remember, stated plainly.\n\n### How it works\n\nThree steps, a diagram or a table.\n\n### An example\n\nSomething concrete the audience will recognise.\n\n## \u2696\uFE0F Trade-offs\n\n- What it costs\n- When not to use it\n\n## \u2705 Summary\n\n- Point one\n- Point two\n- Point three\n\n## \u{1F64F} Thank you\n\nWhere to find you, and the link to these slides.\n";
|
|
859
|
+
|
|
860
|
+
// examples/recording.md
|
|
861
|
+
var recording_default = "---\ntitle: Video title\nduration: 10m\npip: bottom-right\npip_size: 24%\ncamera: 24%, 40%, full, off\n---\n\n<!-- camera: full, on -->\n\n# Video title\n\nOpens full screen on you; the next press shows this slide with you in the corner.\n\n## \u{1F4CC} Disclaimer\n\n<!-- camera: off, on -->\n\nOpens without the camera, so the text has the whole screen; the next press brings you back.\n\n## \u{1F9ED} Contents\n\n- Part one\n- Part two\n- Part three\n\n## \u{1F539} Part one\n\n<!-- view: overview -->\n\nThe overview comment pulls back to the whole map first: a good start to a chapter.\n\n### A detail\n\nSlides you talk over in the corner.\n\n## \u{1F538} Part two\n\n### A detail\n\n## \u{1F537} Part three\n\n### A detail\n\n## \u{1F64F} Thanks for watching\n\n<!-- camera: on, full, on, off -->\n\nEnds on you full screen, then back to the slide, then without the camera.\n";
|
|
862
|
+
|
|
863
|
+
// examples/showcase.md
|
|
864
|
+
var showcase_default = '---\ntitle: Slidetake examples\nbrand: slidetake\nduration: 10m\n---\n\n# Slidetake examples\n\nEverything a deck can hold, written in plain markdown. Open **\u270E Editor** to see the source of any card, or press **O** for the map.\n\n## \u270D\uFE0F Text\n\nParagraphs, **bold**, *italic*, `code`, [links](https://slidetake.com) and lists, as markdown writes them.\n\n- One point\n- Another point\n - A detail under it\n\n### Steps\n\nPut `<!-- steps -->` before a list and it reveals one item per press:\n\n<!-- steps -->\n- First, the problem\n- Then, the idea\n- Finally, the result\n\n### Quotes and tables\n\n> A quote stands out from the text around it.\n\n| Plan | Price | Users |\n|---|---:|---:|\n| Free | \u20B90 | 1 |\n| Team | \u20B9499 | 10 |\n\n### Code\n\n```python\ndef take(slide):\n return slide.best_attempt()\n```\n\n## \u{1F9ED} Diagrams\n\nWrite the diagram in a fenced block named after its language.\n\n### Graphviz\n\n```dot\ndigraph {\n rankdir=LR\n node [shape=box style=rounded]\n Markdown -> Deck -> Takes -> Video\n}\n```\n\n### D2\n\n```d2\ndirection: right\nwrite: Write {shape: rectangle}\npresent: Present\nrecord: Record\nwrite -> present -> record: one session\n```\n\n### SVG\n\n```svg\n<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 120">\n <rect x="10" y="20" width="90" height="80" rx="10" fill="#e0b024"/>\n <rect x="115" y="20" width="90" height="80" rx="10" fill="#e0b024" opacity=".7"/>\n <rect x="220" y="20" width="90" height="80" rx="10" fill="#e0b024" opacity=".4"/>\n</svg>\n```\n\n## \u{1F4CA} Charts\n\nECharts, as a fenced `echarts` block of JSON options.\n\n### A bar chart\n\n```echarts\n{\n "xAxis": {"type": "category", "data": ["Jan", "Feb", "Mar", "Apr", "May"]},\n "yAxis": {"type": "value"},\n "series": [{"type": "bar", "data": [12, 19, 15, 24, 30]}]\n}\n```\n\n### A donut\n\n```echarts\n{\n "series": [{"type": "pie", "radius": ["45%", "70%"],\n "data": [{"name": "Equity", "value": 85}, {"name": "Debt", "value": 5}, {"name": "Gold", "value": 10}]}]\n}\n```\n\n## \u{1F5BC}\uFE0F Images\n\nThe layout comes from what\'s on the slide; the alt text is the caption.\n\n### One image\n\n\n\n### Image and text\n\n\n\nAn image beside text makes a split card. Write the text first and the image moves to the right.\n\n### A gallery\n\nA list of images is a gallery. With `<!-- steps -->` it becomes a carousel: one image at a time, the next on each press.\n\n<!-- steps -->\n- \n- \n- \n\n### A grid\n\nSeveral images in one paragraph sit side by side, up to four a row:\n\n  \n\n### Full screen\n\n<!-- view: full -->\n\n\n\n## \u25B6\uFE0F YouTube\n\nA YouTube link alone on a line becomes the video. The next press plays it; leaving the slide pauses it.\n\nhttps://www.youtube.com/watch?v=jNQXAC9IVRw\n\n## \u{1F3A5} Camera and map\n\n<!-- camera: on, full, on -->\n<!-- view: overview -->\n\nTwo comments do what markdown can\'t: `<!-- camera: on, full, on -->` moves the presenter\'s camera, and `<!-- view: overview -->` shows the whole map first.\n\n## \u{1F680} Start your own\n\nPress **New** for a template (blank, talk or recording), or type in this deck to make it your copy.\n\nThe templates and this deck live in [examples/](https://github.com/slidetake/slidetake/tree/main/examples) on GitHub.\n';
|
|
865
|
+
|
|
866
|
+
// src/core/text.js
|
|
867
|
+
function slugify(s) {
|
|
868
|
+
return s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "") || "card";
|
|
869
|
+
}
|
|
870
|
+
function plainText(s) {
|
|
871
|
+
return s.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[*_`~]/g, "").trim();
|
|
872
|
+
}
|
|
873
|
+
function escapeHtml(s) {
|
|
874
|
+
return String(s).replace(/[&<>"]/g, (c) => (
|
|
875
|
+
/** @type {Record<string,string>} */
|
|
876
|
+
{ "&": "&", "<": "<", ">": ">", '"': """ }[c]
|
|
877
|
+
));
|
|
878
|
+
}
|
|
879
|
+
var ENTITIES = (
|
|
880
|
+
/** @type {Record<string,string>} */
|
|
881
|
+
{ amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", rsquo: "\u2019", lsquo: "\u2018", rdquo: "\u201D", ldquo: "\u201C" }
|
|
882
|
+
);
|
|
883
|
+
function decodeEntities(s) {
|
|
884
|
+
if (typeof document !== "undefined") {
|
|
885
|
+
const t = document.createElement("textarea");
|
|
886
|
+
t.innerHTML = s;
|
|
887
|
+
return t.value;
|
|
888
|
+
}
|
|
889
|
+
return s.replace(/&(#x[\da-f]+|#\d+|\w+);/gi, (m, e) => {
|
|
890
|
+
if (e[0] === "#") return String.fromCodePoint(e[1].toLowerCase() === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10));
|
|
891
|
+
return ENTITIES[e.toLowerCase()] ?? m;
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
function attrsOf(text) {
|
|
895
|
+
const a = {};
|
|
896
|
+
for (const x of text.matchAll(/([\w-]+)="([^"]*)"/g)) a[x[1]] = x[2];
|
|
897
|
+
return a;
|
|
898
|
+
}
|
|
899
|
+
function splitOutsideFences(text, sep) {
|
|
900
|
+
const out = [[]];
|
|
901
|
+
let fence = null;
|
|
902
|
+
text.split("\n").forEach((line) => {
|
|
903
|
+
const f = line.match(/^\s{0,3}(`{3,}|~{3,})/);
|
|
904
|
+
if (f) {
|
|
905
|
+
if (!fence) fence = f[1];
|
|
906
|
+
else if (f[1][0] === fence[0] && f[1].length >= fence.length) fence = null;
|
|
907
|
+
}
|
|
908
|
+
if (!fence && !f && sep.test(line)) out.push([]);
|
|
909
|
+
else out[out.length - 1].push(line);
|
|
910
|
+
});
|
|
911
|
+
return out.map((l) => l.join("\n"));
|
|
912
|
+
}
|
|
913
|
+
function parseDuration(v) {
|
|
914
|
+
const t = String(v ?? "").trim().toLowerCase();
|
|
915
|
+
if (!t) return 0;
|
|
916
|
+
let m = t.match(/^(\d+):(\d{1,2})$/);
|
|
917
|
+
if (m) return (+m[1] * 60 + +m[2]) * 1e3;
|
|
918
|
+
m = t.match(/^(\d+(?:\.\d+)?)\s*(h|hrs?|hours?|m|mins?|minutes?|s|secs?|seconds?)?$/);
|
|
919
|
+
if (!m) return 0;
|
|
920
|
+
const unit = (m[2] || "m")[0];
|
|
921
|
+
return parseFloat(m[1]) * (unit === "h" ? 3600 : unit === "s" ? 1 : 60) * 1e3;
|
|
922
|
+
}
|
|
923
|
+
function fmtTime(ms) {
|
|
924
|
+
const s = Math.max(0, Math.round(ms / 1e3)), h = Math.floor(s / 3600), m = Math.floor(s % 3600 / 60), sec = s % 60;
|
|
925
|
+
return (h ? h + ":" + String(m).padStart(2, "0") : m) + ":" + String(sec).padStart(2, "0");
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/core/parse.js
|
|
929
|
+
function directiveText(body) {
|
|
930
|
+
let fence = null;
|
|
931
|
+
return body.split("\n").filter((line) => {
|
|
932
|
+
const f = line.match(/^\s{0,3}(`{3,}|~{3,})/);
|
|
933
|
+
if (f) {
|
|
934
|
+
if (!fence) fence = f[1];
|
|
935
|
+
else if (f[1][0] === fence[0] && f[1].length >= fence.length) fence = null;
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
return !fence;
|
|
939
|
+
}).join("\n").replace(/`[^`\n]*`/g, "");
|
|
940
|
+
}
|
|
941
|
+
function mapDirective(body) {
|
|
942
|
+
return /<!--\s*view\s*:\s*(overview|map)\s*-->/i.test(directiveText(body));
|
|
943
|
+
}
|
|
944
|
+
function cameraDirective(body) {
|
|
945
|
+
const m = directiveText(body).match(/<!--\s*camera\s*:\s*([\s\S]*?)\s*-->/i);
|
|
946
|
+
return m ? m[1].trim() : null;
|
|
947
|
+
}
|
|
948
|
+
function parseDeckSettings(src) {
|
|
949
|
+
const deck2 = {};
|
|
950
|
+
const fm = src.match(/^---[ \t]*\n([\s\S]*?)\n---[ \t]*(?:\n|$)/);
|
|
951
|
+
if (!fm) return { deck: deck2, body: src };
|
|
952
|
+
let listKey = null;
|
|
953
|
+
fm[1].split("\n").forEach((l) => {
|
|
954
|
+
const item = l.match(/^\s+-\s+(.*)$/);
|
|
955
|
+
if (item && listKey) {
|
|
956
|
+
deck2[listKey].push(item[1].trim().replace(/^["']|["']$/g, ""));
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
const m = l.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);
|
|
960
|
+
if (!m) {
|
|
961
|
+
listKey = null;
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
const key = m[1].toLowerCase(), val = m[2].trim().replace(/^["']|["']$/g, "");
|
|
965
|
+
if (val === "") {
|
|
966
|
+
deck2[key] = [];
|
|
967
|
+
listKey = key;
|
|
968
|
+
} else {
|
|
969
|
+
deck2[key] = val;
|
|
970
|
+
listKey = null;
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
return { deck: deck2, body: src.slice(fm[0].length) };
|
|
974
|
+
}
|
|
975
|
+
function settingsBlock(settings) {
|
|
976
|
+
const plain = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
|
|
977
|
+
const line = (v) => String(v).replace(/\s*\n\s*/g, " ");
|
|
978
|
+
const lines = [];
|
|
979
|
+
for (const [k, v] of Object.entries(settings || {})) {
|
|
980
|
+
if (!/^[A-Za-z_][\w-]*$/.test(k)) continue;
|
|
981
|
+
if (plain(v)) lines.push(k + ": " + line(v));
|
|
982
|
+
else if (Array.isArray(v) && v.every(plain)) {
|
|
983
|
+
lines.push(k + ":");
|
|
984
|
+
v.forEach((x) => lines.push(" - " + line(x)));
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return lines.length ? "---\n" + lines.join("\n") + "\n---\n" : "";
|
|
988
|
+
}
|
|
989
|
+
function parseFrontmatter(block) {
|
|
990
|
+
const lines = block.split("\n");
|
|
991
|
+
const meta = {};
|
|
992
|
+
let body = block;
|
|
993
|
+
if (lines[0] !== void 0 && lines[0].trim() === "---") {
|
|
994
|
+
let end = -1;
|
|
995
|
+
for (let i = 1; i < lines.length; i++) {
|
|
996
|
+
if (lines[i].trim() === "---") {
|
|
997
|
+
end = i;
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (end !== -1) {
|
|
1002
|
+
lines.slice(1, end).forEach((l) => {
|
|
1003
|
+
const idx = l.indexOf(":");
|
|
1004
|
+
if (idx > -1) meta[l.slice(0, idx).trim()] = l.slice(idx + 1).trim().replace(/^["']|["']$/g, "");
|
|
1005
|
+
});
|
|
1006
|
+
body = lines.slice(end + 1).join("\n").replace(/^\n+/, "");
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
return { meta, body };
|
|
1010
|
+
}
|
|
1011
|
+
function slideTitle(body) {
|
|
1012
|
+
const clean = body.replace(/<!--[\s\S]*?-->/g, "");
|
|
1013
|
+
const h = clean.match(/^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/m);
|
|
1014
|
+
const t = clean.match(/<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>/i);
|
|
1015
|
+
let raw = null;
|
|
1016
|
+
if (h && (!t || /** @type {number} */
|
|
1017
|
+
h.index < /** @type {number} */
|
|
1018
|
+
t.index)) raw = h[1];
|
|
1019
|
+
else if (t) raw = t[1].replace(/<[^>]+>/g, " ");
|
|
1020
|
+
if (!raw) {
|
|
1021
|
+
const line = clean.split("\n").map((l) => l.replace(/<[^>]+>/g, "").trim()).find((l) => l && !/^[-|:\s]+$/.test(l));
|
|
1022
|
+
raw = line ? line.slice(0, 60) : null;
|
|
1023
|
+
}
|
|
1024
|
+
return raw ? decodeEntities(plainText(raw)).replace(/\s+/g, " ").trim() : null;
|
|
1025
|
+
}
|
|
1026
|
+
function slideAttrs(body) {
|
|
1027
|
+
const m = body.match(/<!--\s*\.slide:([\s\S]*?)-->/i);
|
|
1028
|
+
return m ? attrsOf(m[1]) : {};
|
|
1029
|
+
}
|
|
1030
|
+
function parseDeck(src, { render = (md) => ({ html: md, err: null }) } = {}) {
|
|
1031
|
+
const nodes2 = /* @__PURE__ */ new Map();
|
|
1032
|
+
const uniqueId = (base) => {
|
|
1033
|
+
let id = base, i = 2;
|
|
1034
|
+
while (nodes2.has(id)) id = base + "-" + i++;
|
|
1035
|
+
return id;
|
|
1036
|
+
};
|
|
1037
|
+
const add = (c) => {
|
|
1038
|
+
nodes2.set(c.id, { x: null, y: null, children: [], ...c });
|
|
1039
|
+
return c.id;
|
|
1040
|
+
};
|
|
1041
|
+
src = src.replace(/\r\n?/g, "\n");
|
|
1042
|
+
const legacy = /^\+\+\+[ \t]*$/m.test(src);
|
|
1043
|
+
let deck2 = {};
|
|
1044
|
+
if (!legacy) ({ deck: deck2, body: src } = parseDeckSettings(src));
|
|
1045
|
+
const slideType = /^slides?$/i.test(String(deck2.layout || "")) || /^slides?$/i.test(String(deck2.type || ""));
|
|
1046
|
+
const reveal = !legacy && (splitOutsideFences(src, /^--\s*$/).length > 1 || slideType && splitOutsideFences(src, /^---\s*$/).length > 1);
|
|
1047
|
+
const errCount = legacy ? parseLegacy() : reveal ? parseReveal() : parseHeadings();
|
|
1048
|
+
nodes2.forEach((n) => {
|
|
1049
|
+
if (!n.parent || n.parent === n.id || !nodes2.has(n.parent)) n.parent = null;
|
|
1050
|
+
});
|
|
1051
|
+
nodes2.forEach((n) => {
|
|
1052
|
+
const seen = /* @__PURE__ */ new Set([n.id]);
|
|
1053
|
+
let p = n.parent;
|
|
1054
|
+
while (p) {
|
|
1055
|
+
if (seen.has(p)) {
|
|
1056
|
+
n.parent = null;
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
seen.add(p);
|
|
1060
|
+
p = /** @type {Card} */
|
|
1061
|
+
nodes2.get(p).parent;
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
nodes2.forEach((n) => {
|
|
1065
|
+
if (n.parent) nodes2.get(n.parent).children.push(n.id);
|
|
1066
|
+
});
|
|
1067
|
+
return { deck: deck2, nodes: nodes2, format: legacy ? "+++" : reveal ? "reveal" : "headings", errCount };
|
|
1068
|
+
function parseHeadings() {
|
|
1069
|
+
const sections = [];
|
|
1070
|
+
let cur = null;
|
|
1071
|
+
let fence = null;
|
|
1072
|
+
const preface = { level: 0, title: null, explicitId: null, lines: [] };
|
|
1073
|
+
src.split("\n").forEach((line) => {
|
|
1074
|
+
const f = line.match(/^\s{0,3}(`{3,}|~{3,})/);
|
|
1075
|
+
if (f) {
|
|
1076
|
+
if (!fence) fence = f[1];
|
|
1077
|
+
else if (f[1][0] === fence[0] && f[1].length >= fence.length) fence = null;
|
|
1078
|
+
}
|
|
1079
|
+
const h = !fence && !f ? line.match(/^\s{0,3}(#{1,6})\s+(.+?)\s*#*\s*$/) : null;
|
|
1080
|
+
if (h) {
|
|
1081
|
+
let text = h[2];
|
|
1082
|
+
let explicitId = null;
|
|
1083
|
+
const attr = text.match(/\s*\{#([\w\-:.]+)\}\s*$/);
|
|
1084
|
+
if (attr) {
|
|
1085
|
+
explicitId = attr[1];
|
|
1086
|
+
text = text.slice(0, attr.index);
|
|
1087
|
+
}
|
|
1088
|
+
cur = { level: h[1].length, title: plainText(text), explicitId, lines: [h[1] + " " + text] };
|
|
1089
|
+
sections.push(cur);
|
|
1090
|
+
} else (cur || preface).lines.push(line);
|
|
1091
|
+
});
|
|
1092
|
+
const prefaceText = preface.lines.join("\n");
|
|
1093
|
+
if (prefaceText.trim()) {
|
|
1094
|
+
if (sections.length && !prefaceText.replace(/<!--[\s\S]*?-->/g, "").trim()) sections[0].lines.splice(1, 0, ...preface.lines);
|
|
1095
|
+
else sections.unshift(preface);
|
|
1096
|
+
}
|
|
1097
|
+
const stack = [];
|
|
1098
|
+
sections.forEach((s) => {
|
|
1099
|
+
while (stack.length && stack[stack.length - 1].level >= s.level) stack.pop();
|
|
1100
|
+
const parent = stack.length ? (
|
|
1101
|
+
/** @type {string} */
|
|
1102
|
+
stack[stack.length - 1].id
|
|
1103
|
+
) : null;
|
|
1104
|
+
const body = s.lines.join("\n").trim();
|
|
1105
|
+
const title = s.title || plainText((body.split("\n").find((l) => l.trim()) || "Intro").slice(0, 48));
|
|
1106
|
+
s.id = uniqueId(s.explicitId || slugify(title));
|
|
1107
|
+
const { html, err } = render(body);
|
|
1108
|
+
add({ id: s.id, parent, title, html, err, camera: cameraDirective(body), mapFirst: mapDirective(body) });
|
|
1109
|
+
stack.push(s);
|
|
1110
|
+
});
|
|
1111
|
+
return 0;
|
|
1112
|
+
}
|
|
1113
|
+
function parseLegacy() {
|
|
1114
|
+
const blocks = src.split(/\n\+\+\+[ \t]*\n/).map((b) => b.trim()).filter((b) => b.length);
|
|
1115
|
+
let prevId = null, errs = 0;
|
|
1116
|
+
blocks.forEach((raw, i) => {
|
|
1117
|
+
const { meta, body } = parseFrontmatter(raw);
|
|
1118
|
+
const id = uniqueId(meta.id || "slide-" + (i + 1));
|
|
1119
|
+
const parent = "parent" in meta ? meta.parent || null : prevId;
|
|
1120
|
+
const m = body.match(/^#{1,6}\s+(.+)$/m);
|
|
1121
|
+
const title = meta.title || (m ? plainText(m[1]) : id);
|
|
1122
|
+
const { html, err } = render(body);
|
|
1123
|
+
if (err) errs++;
|
|
1124
|
+
add({
|
|
1125
|
+
id,
|
|
1126
|
+
parent,
|
|
1127
|
+
title,
|
|
1128
|
+
html,
|
|
1129
|
+
err,
|
|
1130
|
+
camera: meta.camera || cameraDirective(body),
|
|
1131
|
+
mapFirst: mapDirective(body),
|
|
1132
|
+
x: meta.x !== void 0 ? parseFloat(meta.x) : null,
|
|
1133
|
+
y: meta.y !== void 0 ? parseFloat(meta.y) : null
|
|
1134
|
+
});
|
|
1135
|
+
prevId = id;
|
|
1136
|
+
});
|
|
1137
|
+
return (
|
|
1138
|
+
/** @type {number} */
|
|
1139
|
+
errs
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
function parseReveal() {
|
|
1143
|
+
let errs = 0, slideNo = 0;
|
|
1144
|
+
let root = null;
|
|
1145
|
+
function addSlide(slide, parent) {
|
|
1146
|
+
const body = slide.body.trim();
|
|
1147
|
+
slideNo++;
|
|
1148
|
+
let title = slideTitle(body) || "Slide " + slideNo;
|
|
1149
|
+
const pTitle = parent ? (
|
|
1150
|
+
/** @type {Card} */
|
|
1151
|
+
nodes2.get(parent).title
|
|
1152
|
+
) : null;
|
|
1153
|
+
if (pTitle && title.startsWith(pTitle + " / ")) title = title.slice(pTitle.length + 3);
|
|
1154
|
+
const id = uniqueId(slugify(title));
|
|
1155
|
+
const { html, err } = render(body);
|
|
1156
|
+
if (err) errs++;
|
|
1157
|
+
return add({
|
|
1158
|
+
id,
|
|
1159
|
+
parent,
|
|
1160
|
+
title,
|
|
1161
|
+
html,
|
|
1162
|
+
err,
|
|
1163
|
+
camera: cameraDirective(body),
|
|
1164
|
+
mapFirst: mapDirective(body),
|
|
1165
|
+
autoslide: parseInt(slide.attrs["data-autoslide"], 10) || 0
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
const stacks = [];
|
|
1169
|
+
splitOutsideFences(src, /^---\s*$/).forEach((chunk) => {
|
|
1170
|
+
if (/<section\b/i.test(chunk)) {
|
|
1171
|
+
for (const m of chunk.matchAll(/<section\b([^>]*)>([\s\S]*?)<\/section>/gi)) stacks.push([{ body: m[2], attrs: attrsOf(m[1]) }]);
|
|
1172
|
+
const rest = chunk.replace(/<section\b[^>]*>[\s\S]*?<\/section>/gi, "");
|
|
1173
|
+
if (rest.trim()) stacks.push([{ body: rest, attrs: slideAttrs(rest) }]);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const stack = splitOutsideFences(chunk, /^--\s*$/).filter((b) => b.trim()).map((b) => ({ body: b, attrs: slideAttrs(b) }));
|
|
1177
|
+
if (stack.length) stacks.push(stack);
|
|
1178
|
+
});
|
|
1179
|
+
stacks.forEach((stack) => {
|
|
1180
|
+
let top = null;
|
|
1181
|
+
stack.forEach((slide, i) => {
|
|
1182
|
+
if (!root) {
|
|
1183
|
+
root = top = addSlide(slide, null);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
if (i === 0) top = addSlide(slide, root);
|
|
1187
|
+
else addSlide(slide, top);
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
return errs;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/core/steps.js
|
|
1195
|
+
var CORNERS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
1196
|
+
var clampPipSize = (v) => Math.max(8, Math.min(60, v));
|
|
1197
|
+
function applyPreset(st, preset) {
|
|
1198
|
+
String(preset || "").toLowerCase().split(/\s+/).forEach((t) => {
|
|
1199
|
+
if (!t) return;
|
|
1200
|
+
if (t === "off" || t === "hide") {
|
|
1201
|
+
st.off = true;
|
|
1202
|
+
} else if (t === "on" || t === "pip" || t === "show") {
|
|
1203
|
+
st.off = false;
|
|
1204
|
+
st.full = false;
|
|
1205
|
+
st.used = true;
|
|
1206
|
+
} else if (t === "full" || t === "fullscreen") {
|
|
1207
|
+
st.full = true;
|
|
1208
|
+
st.off = false;
|
|
1209
|
+
st.used = true;
|
|
1210
|
+
} else if (/^\d+(\.\d+)?%?$/.test(t)) {
|
|
1211
|
+
st.size = clampPipSize(parseFloat(t));
|
|
1212
|
+
st.used = true;
|
|
1213
|
+
} else if (CORNERS.includes(t)) {
|
|
1214
|
+
st.corner = t;
|
|
1215
|
+
st.used = true;
|
|
1216
|
+
} else if (t === "flip") {
|
|
1217
|
+
st.flip = !st.flip;
|
|
1218
|
+
st.used = true;
|
|
1219
|
+
} else if (t === "circle") {
|
|
1220
|
+
st.circle = true;
|
|
1221
|
+
} else if (t === "rect") {
|
|
1222
|
+
st.circle = false;
|
|
1223
|
+
} else if (t === "mirror") {
|
|
1224
|
+
st.mirror = true;
|
|
1225
|
+
} else if (t === "unmirror" || t === "no-mirror") {
|
|
1226
|
+
st.mirror = false;
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
return st;
|
|
1230
|
+
}
|
|
1231
|
+
function cameraPresets(directive) {
|
|
1232
|
+
return directive ? directive.split(",").map((x) => x.trim()).filter(Boolean) : [];
|
|
1233
|
+
}
|
|
1234
|
+
function stepsFor(cams, frags) {
|
|
1235
|
+
const out = [];
|
|
1236
|
+
if (!cams.length) {
|
|
1237
|
+
for (let f = 0; f <= frags; f++) out.push({ cam: 0, frag: f });
|
|
1238
|
+
return out;
|
|
1239
|
+
}
|
|
1240
|
+
let k = cams.findIndex((c) => !applyPreset({}, c).full);
|
|
1241
|
+
if (k < 0) k = cams.length - 1;
|
|
1242
|
+
for (let i = 0; i <= k; i++) out.push({ cam: i, frag: 0 });
|
|
1243
|
+
for (let f = 1; f <= frags; f++) out.push({ cam: k, frag: f });
|
|
1244
|
+
for (let i = k + 1; i < cams.length; i++) out.push({ cam: i, frag: frags });
|
|
1245
|
+
return out;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// src/core/source.js
|
|
1249
|
+
var RAW = "https://raw.githubusercontent.com/";
|
|
1250
|
+
function normalizeSource(input) {
|
|
1251
|
+
const text = String(input || "").trim();
|
|
1252
|
+
if (!text) return null;
|
|
1253
|
+
let u;
|
|
1254
|
+
try {
|
|
1255
|
+
u = new URL(/^[a-z]+:\/\//i.test(text) ? text : "https://" + text);
|
|
1256
|
+
} catch (e) {
|
|
1257
|
+
return null;
|
|
1258
|
+
}
|
|
1259
|
+
const parts = u.pathname.split("/").filter(Boolean);
|
|
1260
|
+
if (u.hostname === "github.com" || u.hostname === "www.github.com") {
|
|
1261
|
+
const [owner, repo, kind, ref, ...rest] = parts;
|
|
1262
|
+
if (owner && repo && (kind === "blob" || kind === "raw" || kind === "tree") && ref) {
|
|
1263
|
+
let path = rest.join("/");
|
|
1264
|
+
if (kind === "tree" || !/\.(md|markdown|txt)$/i.test(path)) path = (path ? path + "/" : "") + "index.md";
|
|
1265
|
+
return { kind: "url", url: RAW + [owner, repo, ref].join("/") + "/" + path };
|
|
1266
|
+
}
|
|
1267
|
+
if (owner && repo && !kind) return { kind: "url", url: RAW + owner + "/" + repo + "/HEAD/README.md" };
|
|
1268
|
+
}
|
|
1269
|
+
if (u.hostname === "gist.github.com") {
|
|
1270
|
+
const id = parts.length >= 2 ? parts[1] : parts[0];
|
|
1271
|
+
if (id && /^[\da-f]+$/i.test(id)) return { kind: "gist", id };
|
|
1272
|
+
}
|
|
1273
|
+
if (u.hostname === "slidetake.com" || u.hostname === "www.slidetake.com") {
|
|
1274
|
+
const fromPath = sourceFromPath(u.pathname);
|
|
1275
|
+
if (fromPath) return fromPath;
|
|
1276
|
+
const src = u.searchParams.get("src");
|
|
1277
|
+
if (src) return { kind: "url", url: src };
|
|
1278
|
+
}
|
|
1279
|
+
return { kind: "url", url: u.href };
|
|
1280
|
+
}
|
|
1281
|
+
function sourceFromPath(pathname) {
|
|
1282
|
+
const parts = String(pathname || "").split("/").filter(Boolean).map((p) => {
|
|
1283
|
+
try {
|
|
1284
|
+
return decodeURIComponent(p);
|
|
1285
|
+
} catch (e) {
|
|
1286
|
+
return p;
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
if (parts[0] === "gh" && parts.length >= 4) {
|
|
1290
|
+
const [, owner, repoRef, ...rest] = parts;
|
|
1291
|
+
const at = repoRef.indexOf("@");
|
|
1292
|
+
const repo = at < 0 ? repoRef : repoRef.slice(0, at);
|
|
1293
|
+
const ref = at < 0 ? "HEAD" : repoRef.slice(at + 1);
|
|
1294
|
+
if (!owner || !repo || !ref) return null;
|
|
1295
|
+
return { kind: "url", url: RAW + [owner, repo, ref, ...rest].map(encodeURIComponent).join("/") };
|
|
1296
|
+
}
|
|
1297
|
+
if (parts.length === 1 && parts[0] === "help") return { kind: "builtin", id: "help" };
|
|
1298
|
+
if (parts.length === 1 && parts[0] === "examples") return { kind: "builtin", id: "showcase" };
|
|
1299
|
+
if (parts[0] === "gist" && parts[1] && /^[\da-f]+$/i.test(parts[1])) {
|
|
1300
|
+
return parts[2] ? { kind: "gist", id: parts[1], file: parts[2] } : { kind: "gist", id: parts[1] };
|
|
1301
|
+
}
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
function shortLink(source) {
|
|
1305
|
+
if (source.kind === "builtin") {
|
|
1306
|
+
if (source.id === "home") return "/";
|
|
1307
|
+
if (source.id === "showcase") return "/examples";
|
|
1308
|
+
if (source.id.startsWith("template:")) return "/new?template=" + source.id.slice(9);
|
|
1309
|
+
return "/" + source.id;
|
|
1310
|
+
}
|
|
1311
|
+
if (source.kind === "gist") return "/gist/" + source.id + (source.file ? "/" + encodeURIComponent(source.file) : "");
|
|
1312
|
+
const m = source.url.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)\/(.+)$/);
|
|
1313
|
+
if (m) {
|
|
1314
|
+
const [, owner, repo, ref, path] = m;
|
|
1315
|
+
if (!/^refs$/.test(ref)) return "/gh/" + owner + "/" + repo + (ref === "HEAD" ? "" : "@" + ref) + "/" + path;
|
|
1316
|
+
}
|
|
1317
|
+
return "/?src=" + encodeURIComponent(source.url);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// src/core/share.js
|
|
1321
|
+
var PREFIX = "deflate:";
|
|
1322
|
+
function toBase64Url(bytes) {
|
|
1323
|
+
let bin = "";
|
|
1324
|
+
for (let i = 0; i < bytes.length; i += 32768) bin += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
1325
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1326
|
+
}
|
|
1327
|
+
function fromBase64Url(s) {
|
|
1328
|
+
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + "===".slice((s.length + 3) % 4));
|
|
1329
|
+
return Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
1330
|
+
}
|
|
1331
|
+
async function pipe(bytes, stream) {
|
|
1332
|
+
const out = new Response(new Blob([
|
|
1333
|
+
/** @type {BlobPart} */
|
|
1334
|
+
bytes
|
|
1335
|
+
]).stream().pipeThrough(stream));
|
|
1336
|
+
return new Uint8Array(await out.arrayBuffer());
|
|
1337
|
+
}
|
|
1338
|
+
async function encodeDeck(markdown) {
|
|
1339
|
+
return toBase64Url(await pipe(new TextEncoder().encode(markdown), new CompressionStream("deflate-raw")));
|
|
1340
|
+
}
|
|
1341
|
+
async function decodeDeck(data) {
|
|
1342
|
+
return new TextDecoder().decode(await pipe(fromBase64Url(data), new DecompressionStream("deflate-raw")));
|
|
1343
|
+
}
|
|
1344
|
+
function parseHash(hash) {
|
|
1345
|
+
const h = hash.replace(/^#/, "");
|
|
1346
|
+
if (!h.startsWith(PREFIX)) {
|
|
1347
|
+
let slide2 = h;
|
|
1348
|
+
try {
|
|
1349
|
+
slide2 = decodeURIComponent(h);
|
|
1350
|
+
} catch (e) {
|
|
1351
|
+
}
|
|
1352
|
+
return { data: null, slide: slide2 };
|
|
1353
|
+
}
|
|
1354
|
+
const rest = h.slice(PREFIX.length), at = rest.indexOf("~");
|
|
1355
|
+
let slide = at < 0 ? "" : rest.slice(at + 1);
|
|
1356
|
+
try {
|
|
1357
|
+
slide = decodeURIComponent(slide);
|
|
1358
|
+
} catch (e) {
|
|
1359
|
+
}
|
|
1360
|
+
return { data: at < 0 ? rest : rest.slice(0, at), slide };
|
|
1361
|
+
}
|
|
1362
|
+
function deckHash(data, slide) {
|
|
1363
|
+
return "#" + PREFIX + data + (slide ? "~" + encodeURIComponent(slide) : "");
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// src/core/doc.js
|
|
1367
|
+
var TEMPLATES = (
|
|
1368
|
+
/** @type {const} */
|
|
1369
|
+
["blank", "talk", "recording"]
|
|
1370
|
+
);
|
|
1371
|
+
function routeOf(pathname, search, hash) {
|
|
1372
|
+
const path = pathname.replace(/\/+$/, "") || "/";
|
|
1373
|
+
const q = new URLSearchParams(search);
|
|
1374
|
+
const { data, slide } = parseHash(hash);
|
|
1375
|
+
if (path === "/share") return data ? { page: "share", data, slide } : { page: "source", source: { kind: "builtin", id: "home" }, slide: "" };
|
|
1376
|
+
if (path === "/edit") return { page: "edit", slide };
|
|
1377
|
+
if (path === "/new") {
|
|
1378
|
+
const t = q.get("template");
|
|
1379
|
+
return t && /** @type {readonly string[]} */
|
|
1380
|
+
TEMPLATES.includes(t) ? { page: "source", source: { kind: "builtin", id: "template:" + t }, slide } : { page: "pick" };
|
|
1381
|
+
}
|
|
1382
|
+
const fromPath = sourceFromPath(path);
|
|
1383
|
+
if (fromPath) return { page: "source", source: fromPath, slide };
|
|
1384
|
+
const src = q.get("src");
|
|
1385
|
+
if (path === "/" && src) return { page: "source", source: { kind: "url", url: src }, slide };
|
|
1386
|
+
return { page: "source", source: { kind: "builtin", id: "home" }, slide };
|
|
1387
|
+
}
|
|
1388
|
+
function originLabel(origin) {
|
|
1389
|
+
switch (origin.kind) {
|
|
1390
|
+
case "builtin":
|
|
1391
|
+
if (origin.id === "home") return "Home";
|
|
1392
|
+
if (origin.id === "help") return "Help";
|
|
1393
|
+
if (origin.id === "showcase") return "the examples";
|
|
1394
|
+
return "the " + origin.id.replace(/^template:/, "") + " template";
|
|
1395
|
+
case "gist":
|
|
1396
|
+
return "a gist" + (origin.file ? " (" + origin.file + ")" : "");
|
|
1397
|
+
case "shared":
|
|
1398
|
+
return "a shared deck";
|
|
1399
|
+
case "file":
|
|
1400
|
+
return origin.name;
|
|
1401
|
+
case "url": {
|
|
1402
|
+
const m = origin.url.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/[^/]+\/(.+)$/);
|
|
1403
|
+
if (m) return m[1] + "/" + m[2] + "/" + m[3];
|
|
1404
|
+
try {
|
|
1405
|
+
const u = new URL(origin.url);
|
|
1406
|
+
return u.hostname + u.pathname;
|
|
1407
|
+
} catch (e) {
|
|
1408
|
+
return origin.url;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function makeCopy(text, origin, { exported = false } = {}) {
|
|
1414
|
+
const copy2 = { text, origin, originText: text, exported: exported ? text : null };
|
|
1415
|
+
return copy2;
|
|
1416
|
+
}
|
|
1417
|
+
function isEdited(copy2) {
|
|
1418
|
+
return copy2.text !== (copy2.exported ?? copy2.originText);
|
|
1419
|
+
}
|
|
1420
|
+
function matchesOrigin(copy2) {
|
|
1421
|
+
return copy2.text === copy2.originText;
|
|
1422
|
+
}
|
|
1423
|
+
function parseCopy(json) {
|
|
1424
|
+
try {
|
|
1425
|
+
const c = JSON.parse(json || "null");
|
|
1426
|
+
if (!c || typeof c.text !== "string" || !c.origin || typeof c.origin.kind !== "string") return null;
|
|
1427
|
+
return {
|
|
1428
|
+
text: c.text,
|
|
1429
|
+
origin: c.origin,
|
|
1430
|
+
originText: typeof c.originText === "string" ? c.originText : c.text,
|
|
1431
|
+
exported: typeof c.exported === "string" ? c.exported : null
|
|
1432
|
+
};
|
|
1433
|
+
} catch (e) {
|
|
1434
|
+
return null;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// src/core/media.js
|
|
1439
|
+
function youtubeVideo(href) {
|
|
1440
|
+
let u;
|
|
1441
|
+
try {
|
|
1442
|
+
u = new URL(href);
|
|
1443
|
+
} catch (e) {
|
|
1444
|
+
return null;
|
|
1445
|
+
}
|
|
1446
|
+
const host = u.hostname.replace(/^(www\.|m\.)/, "");
|
|
1447
|
+
let id = null, portrait = false;
|
|
1448
|
+
if (host === "youtu.be") id = u.pathname.slice(1).split("/")[0];
|
|
1449
|
+
else if (host === "youtube.com" || host === "youtube-nocookie.com") {
|
|
1450
|
+
const parts = u.pathname.split("/").filter(Boolean);
|
|
1451
|
+
if (parts[0] === "watch") id = u.searchParams.get("v");
|
|
1452
|
+
else if (["shorts", "live", "embed"].includes(parts[0])) {
|
|
1453
|
+
id = parts[1] || null;
|
|
1454
|
+
portrait = parts[0] === "shorts";
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
if (!id || !/^[\w-]{6,}$/.test(id)) return null;
|
|
1458
|
+
return { id, start: parseStart(u.searchParams.get("t") || u.searchParams.get("start") || ""), portrait };
|
|
1459
|
+
}
|
|
1460
|
+
function parseStart(t) {
|
|
1461
|
+
if (/^\d+$/.test(t)) return +t;
|
|
1462
|
+
const m = t.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);
|
|
1463
|
+
return m && t ? +(m[1] || 0) * 3600 + +(m[2] || 0) * 60 + +(m[3] || 0) : 0;
|
|
1464
|
+
}
|
|
1465
|
+
function embedUrl(v) {
|
|
1466
|
+
return "https://www.youtube-nocookie.com/embed/" + encodeURIComponent(v.id) + "?enablejsapi=1&rel=0&playsinline=1" + (v.start ? "&start=" + v.start : "");
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// src/core/cut.js
|
|
1470
|
+
var evTime = (e) => e.obsT ?? e.t;
|
|
1471
|
+
var sessionFps = (sess) => sess.fps || 60;
|
|
1472
|
+
var toFrame = (ms, fps) => Math.round(ms * fps / 1e3);
|
|
1473
|
+
function takesOf(sess) {
|
|
1474
|
+
const out = /* @__PURE__ */ new Map();
|
|
1475
|
+
const end = sess.totalObs ?? sess.total;
|
|
1476
|
+
sess.events.forEach((e, i) => {
|
|
1477
|
+
if (!out.has(e.id)) out.set(e.id, { id: e.id, title: e.title, takes: [] });
|
|
1478
|
+
const slide = (
|
|
1479
|
+
/** @type {SlideTakes} */
|
|
1480
|
+
out.get(e.id)
|
|
1481
|
+
);
|
|
1482
|
+
const next = sess.events[i + 1];
|
|
1483
|
+
slide.takes.push({ no: slide.takes.length + 1, start: evTime(e), end: next ? evTime(next) : end });
|
|
1484
|
+
});
|
|
1485
|
+
return out;
|
|
1486
|
+
}
|
|
1487
|
+
function pickedRanges(sess) {
|
|
1488
|
+
const ranges = [];
|
|
1489
|
+
const fps = sessionFps(sess);
|
|
1490
|
+
takesOf(sess).forEach((slide) => {
|
|
1491
|
+
const pick = sess.picks[slide.id] ?? slide.takes.length;
|
|
1492
|
+
if (!pick) return;
|
|
1493
|
+
const t = slide.takes[pick - 1];
|
|
1494
|
+
if (!t) return;
|
|
1495
|
+
const f0 = toFrame(t.start, fps), f1 = toFrame(t.end, fps);
|
|
1496
|
+
if (f1 > f0) ranges.push({ id: slide.id, title: slide.title, f0, f1, start: f0 * 1e3 / fps, end: f1 * 1e3 / fps });
|
|
1497
|
+
});
|
|
1498
|
+
return ranges;
|
|
1499
|
+
}
|
|
1500
|
+
function mergedRanges(ranges) {
|
|
1501
|
+
const out = [];
|
|
1502
|
+
ranges.forEach((r) => {
|
|
1503
|
+
const last = out[out.length - 1];
|
|
1504
|
+
if (last && r.f0 === last.f1) {
|
|
1505
|
+
last.f1 = r.f1;
|
|
1506
|
+
last.end = r.end;
|
|
1507
|
+
} else out.push({ f0: r.f0, f1: r.f1, start: r.start, end: r.end });
|
|
1508
|
+
});
|
|
1509
|
+
return out;
|
|
1510
|
+
}
|
|
1511
|
+
function sectionChapters(sess, sectionOf2) {
|
|
1512
|
+
let at = 0;
|
|
1513
|
+
const list = [];
|
|
1514
|
+
pickedRanges(sess).forEach((r) => {
|
|
1515
|
+
const { sec, title } = sectionOf2(r.id, r.title);
|
|
1516
|
+
const last = list[list.length - 1];
|
|
1517
|
+
if (!last || last.sec !== sec && last.title !== title) list.push({ sec, title, t: at });
|
|
1518
|
+
at += r.end - r.start;
|
|
1519
|
+
});
|
|
1520
|
+
return { list, length: at };
|
|
1521
|
+
}
|
|
1522
|
+
function finalChapters(sess, sectionOf2) {
|
|
1523
|
+
const { list, length: at } = sectionChapters(sess, sectionOf2);
|
|
1524
|
+
const kept = list.filter((c, i) => i === 0 || (list[i + 1] ? list[i + 1].t : at) - c.t >= 1e4);
|
|
1525
|
+
if (kept.length) kept[0].t = 0;
|
|
1526
|
+
return { lines: kept.map((c) => fmtTime(c.t) + " " + c.title), dropped: list.length - kept.length, length: at };
|
|
1527
|
+
}
|
|
1528
|
+
var baseName = (p) => String(p || "").split(/[\\/]/).pop() || "";
|
|
1529
|
+
var dirName = (p) => {
|
|
1530
|
+
const i = Math.max(String(p).lastIndexOf("/"), String(p).lastIndexOf("\\"));
|
|
1531
|
+
return i >= 0 ? String(p).slice(0, i + 1) : "";
|
|
1532
|
+
};
|
|
1533
|
+
var shq = (p) => "'" + String(p).replace(/'/g, "'\\''") + "'";
|
|
1534
|
+
var secs = (ms) => (ms / 1e3).toFixed(3);
|
|
1535
|
+
function ffmpegScript(sess, mode, { input, outputName, sectionOf: sectionOf2 }) {
|
|
1536
|
+
const ranges = mergedRanges(pickedRanges(sess));
|
|
1537
|
+
if (!sess.withObs) return "# This was a rehearsal: nothing was recorded.";
|
|
1538
|
+
if (!ranges.length) return "# Every slide is left out: nothing to render.";
|
|
1539
|
+
const output = dirName(input) + outputName;
|
|
1540
|
+
const { list, length } = sectionChapters(sess, sectionOf2);
|
|
1541
|
+
const esc = (v) => String(v).replace(/[=;#\\\n]/g, (m) => "\\" + m);
|
|
1542
|
+
const meta = ";FFMETADATA1\ntitle=" + esc(sess.deckTitle) + "\n" + list.map((c, i) => "[CHAPTER]\nTIMEBASE=1/1000\nSTART=" + Math.round(c.t) + "\nEND=" + Math.round(list[i + 1] ? list[i + 1].t : length) + "\ntitle=" + esc(c.title)).join("\n");
|
|
1543
|
+
const chapters = "cat > /tmp/slidetake-chapters.txt <<'EOF'\n" + meta + "\nEOF\n";
|
|
1544
|
+
const maps = " -map 0:v:0 -map 0:a:0 -map_metadata 1 -map_chapters 1";
|
|
1545
|
+
if (mode === "copy") {
|
|
1546
|
+
const cuts = ranges.map((r) => "file " + shq(input) + "\ninpoint " + secs(r.start) + "\noutpoint " + secs(r.end)).join("\n");
|
|
1547
|
+
const warn = ranges.length > 1 ? "# Careful: without re-encoding, cuts can only land on keyframes (OBS puts one about every 2 s),\n# so " + (ranges.length === 2 ? "the cut" : "each of the " + (ranges.length - 1) + " cuts") + " here may keep or lose up to ~2 s. Use a frame-accurate option for retakes.\n" : "";
|
|
1548
|
+
return warn + "cat > /tmp/slidetake-cuts.txt <<'EOF'\n" + cuts + "\nEOF\n" + chapters + "ffmpeg -f concat -safe 0 -i /tmp/slidetake-cuts.txt -i /tmp/slidetake-chapters.txt" + maps + " -c copy -movflags +faststart " + shq(output);
|
|
1549
|
+
}
|
|
1550
|
+
const fps = sessionFps(sess);
|
|
1551
|
+
const at = (f) => (f / fps).toFixed(6);
|
|
1552
|
+
const half = (f) => ((f - 0.5) / fps).toFixed(6);
|
|
1553
|
+
const vKeep = ranges.map((r) => "gte(t," + half(r.f0) + ")*lt(t," + half(r.f1) + ")").join("+");
|
|
1554
|
+
const aKeep = ranges.map((r) => "gte(t," + at(r.f0) + ")*lt(t," + at(r.f1) + ")").join("+");
|
|
1555
|
+
const video = mode === "mac" ? "-c:v h264_videotoolbox -b:v 12M" : "-c:v libx264 -crf 18 -preset medium";
|
|
1556
|
+
return chapters + "ffmpeg -i " + shq(input) + " -i /tmp/slidetake-chapters.txt" + maps + ` -vf "select='` + vKeep + `',setpts=N/FRAME_RATE/TB" -af "asetnsamples=n=48:p=0,aselect='` + aKeep + `',asetpts=N/SR/TB" ` + video + " -c:a aac -b:a 192k -movflags +faststart " + shq(output);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// src/app.js
|
|
1560
|
+
var EMBED = window.SLIDETAKE || null;
|
|
1561
|
+
var LOGO = document.querySelector("header .mark .logo").outerHTML;
|
|
1562
|
+
document.documentElement.classList.toggle("embed", !!EMBED);
|
|
1563
|
+
var RECORDING_UI = !EMBED || EMBED.recording === true || new URLSearchParams(location.search).has("obs");
|
|
1564
|
+
document.documentElement.classList.toggle("no-record", !RECORDING_UI);
|
|
1565
|
+
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1566
|
+
var BUILTIN = { home: sample_default, help: help_default, showcase: showcase_default, "template:blank": blank_default, "template:talk": talk_default, "template:recording": recording_default };
|
|
1567
|
+
var editor = document.getElementById("editor");
|
|
1568
|
+
var stage = document.getElementById("stage");
|
|
1569
|
+
var world = document.getElementById("world");
|
|
1570
|
+
var svg = document.getElementById("connectors");
|
|
1571
|
+
var breadcrumbs = document.getElementById("breadcrumbs");
|
|
1572
|
+
var statusCount = document.getElementById("status-count");
|
|
1573
|
+
var statusErr = document.getElementById("status-err");
|
|
1574
|
+
var mmSvg = document.getElementById("mm-svg");
|
|
1575
|
+
var mmLabel = document.getElementById("mm-label");
|
|
1576
|
+
var editorPane = document.getElementById("editor-pane");
|
|
1577
|
+
var BLEED_H = 540;
|
|
1578
|
+
var BLEED_BANDS = 96;
|
|
1579
|
+
var NODE_W = 440;
|
|
1580
|
+
var WIDE_W = 720;
|
|
1581
|
+
var XWIDE_W = 960;
|
|
1582
|
+
var NODE_H_EST = 180;
|
|
1583
|
+
var SPACING_X = 540;
|
|
1584
|
+
var VERTICAL_GAP = 100;
|
|
1585
|
+
var RADIAL_GAP = 110;
|
|
1586
|
+
var RADIAL_MIN_STEP = 420;
|
|
1587
|
+
var SLIDE_FILL_MIN = 0.35;
|
|
1588
|
+
var SLIDE_FILL_MAX = 1;
|
|
1589
|
+
var slideFill = parseFloat(load("slidetake:slideSize")) || 0.92;
|
|
1590
|
+
var nodes = /* @__PURE__ */ new Map();
|
|
1591
|
+
var order = [];
|
|
1592
|
+
var roots = [];
|
|
1593
|
+
var currentId = null;
|
|
1594
|
+
var layoutMode = "tree";
|
|
1595
|
+
var presenting = false;
|
|
1596
|
+
var deck = {};
|
|
1597
|
+
var cameraOff = true;
|
|
1598
|
+
var cameraStream = null;
|
|
1599
|
+
var brandEl = document.getElementById("brand");
|
|
1600
|
+
var pipEl = document.getElementById("pip");
|
|
1601
|
+
var stageWrap = document.getElementById("stage-wrap");
|
|
1602
|
+
var cam = { x: 0, y: 0, zoom: 0.6 };
|
|
1603
|
+
var camTween = null;
|
|
1604
|
+
function load(k) {
|
|
1605
|
+
try {
|
|
1606
|
+
const v = localStorage.getItem(k);
|
|
1607
|
+
if (v !== null || !k.startsWith("slidetake:")) return v;
|
|
1608
|
+
const rest = k.slice(10);
|
|
1609
|
+
return localStorage.getItem("slidetake:" + rest) ?? localStorage.getItem("traverse:" + rest);
|
|
1610
|
+
} catch (e) {
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
function save(k, v) {
|
|
1615
|
+
try {
|
|
1616
|
+
localStorage.setItem(k, v);
|
|
1617
|
+
} catch (e) {
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function renderMd(body) {
|
|
1621
|
+
try {
|
|
1622
|
+
return { html: window.marked ? window.marked.parse(body) : "<pre>" + escapeHtml(body) + "</pre>", err: null };
|
|
1623
|
+
} catch (e) {
|
|
1624
|
+
return { html: "<p>(could not render)</p>", err: "render error" };
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function applyDeckSettings() {
|
|
1628
|
+
const name = deck.brand || "", logo = deck.logo || "";
|
|
1629
|
+
const chip = /^chip$/i.test(deck.brand_style || "");
|
|
1630
|
+
const html = /^slidetake$/i.test(name) ? '<span class="st-mark">' + LOGO + '<span class="word">Slide<span>take</span></span></span>' : (logo ? '<img alt="" src="' + escapeHtml(logo) + '">' : "") + (name ? "<span" + (chip ? ' class="chip"' : "") + ">" + escapeHtml(name) + "</span>" : "");
|
|
1631
|
+
if (brandEl.dataset.html !== html) {
|
|
1632
|
+
brandEl.dataset.html = html;
|
|
1633
|
+
brandEl.innerHTML = html;
|
|
1634
|
+
const img = brandEl.querySelector("img");
|
|
1635
|
+
if (img) img.onload = img.onerror = () => refocus(true);
|
|
1636
|
+
}
|
|
1637
|
+
brandEl.hidden = !html;
|
|
1638
|
+
applyPipState();
|
|
1639
|
+
document.title = deck.title || "Slidetake";
|
|
1640
|
+
const palette = String(deck.theme || deck.palette || "").toLowerCase();
|
|
1641
|
+
if (palette) document.body.dataset.palette = palette;
|
|
1642
|
+
else delete document.body.dataset.palette;
|
|
1643
|
+
applyMode();
|
|
1644
|
+
}
|
|
1645
|
+
var urlMode = new URLSearchParams(location.search).get("mode");
|
|
1646
|
+
function currentMode() {
|
|
1647
|
+
if (EMBED && EMBED.themeKey && !urlMode) {
|
|
1648
|
+
const v = load(EMBED.themeKey);
|
|
1649
|
+
if (v === "light" || v === "dark") return v;
|
|
1650
|
+
return matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1651
|
+
}
|
|
1652
|
+
const m = String(urlMode || load("slidetake:mode") || deck.mode || "dark").toLowerCase();
|
|
1653
|
+
return m === "light" ? "light" : "dark";
|
|
1654
|
+
}
|
|
1655
|
+
function applyMode() {
|
|
1656
|
+
const light = currentMode() === "light";
|
|
1657
|
+
if (light) document.body.dataset.mode = "light";
|
|
1658
|
+
else delete document.body.dataset.mode;
|
|
1659
|
+
const b = document.getElementById("btn-mode");
|
|
1660
|
+
if (b) {
|
|
1661
|
+
b.innerHTML = light ? '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>' : '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4.5"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>';
|
|
1662
|
+
b.title = (light ? "Dark theme" : "Light theme") + " (L)";
|
|
1663
|
+
b.setAttribute("aria-label", b.title);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function toggleMode() {
|
|
1667
|
+
const next = currentMode() === "light" ? "dark" : "light";
|
|
1668
|
+
if (EMBED && EMBED.themeKey) {
|
|
1669
|
+
save(EMBED.themeKey, next);
|
|
1670
|
+
document.documentElement.classList.toggle("dark", next === "dark");
|
|
1671
|
+
} else save("slidetake:mode", next);
|
|
1672
|
+
applyMode();
|
|
1673
|
+
if (world.querySelector(".echarts-container, .diagram.d2")) rebuild(true);
|
|
1674
|
+
}
|
|
1675
|
+
function cameraList() {
|
|
1676
|
+
const raw = (deck.camera || "").replace(/^\[|\]$/g, "");
|
|
1677
|
+
const list = raw.split(",").map((x) => x.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
1678
|
+
return list.length ? list : ["on", "full", "off"];
|
|
1679
|
+
}
|
|
1680
|
+
function cameraSteps(n) {
|
|
1681
|
+
return !cameraOff && n ? cameraPresets(n.camera) : [];
|
|
1682
|
+
}
|
|
1683
|
+
var stepPos = 0;
|
|
1684
|
+
function slideSteps(n) {
|
|
1685
|
+
return stepsFor(cameraSteps(n), n && n.frags ? n.frags.length : 0);
|
|
1686
|
+
}
|
|
1687
|
+
function currentStep() {
|
|
1688
|
+
const steps = slideSteps(nodes.get(currentId));
|
|
1689
|
+
return steps[Math.min(stepPos, steps.length - 1)] || { cam: 0, frag: 0 };
|
|
1690
|
+
}
|
|
1691
|
+
function slideCameraPreset() {
|
|
1692
|
+
if (!currentId) return null;
|
|
1693
|
+
const own = cameraSteps(nodes.get(currentId));
|
|
1694
|
+
if (own.length) return own[Math.min(currentStep().cam, own.length - 1)];
|
|
1695
|
+
for (let i = order.indexOf(currentId) - 1; i >= 0; i--) {
|
|
1696
|
+
const steps = cameraSteps(nodes.get(order[i]));
|
|
1697
|
+
if (steps.length) return steps[steps.length - 1];
|
|
1698
|
+
}
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
var camManual = null;
|
|
1702
|
+
var camCycle = -1;
|
|
1703
|
+
var pipState = null;
|
|
1704
|
+
function computePipState() {
|
|
1705
|
+
const st = {
|
|
1706
|
+
corner: (deck.pip || "none").toLowerCase(),
|
|
1707
|
+
size: clampPipSize(parseFloat(deck.pip_size) || 24),
|
|
1708
|
+
circle: (deck.pip_shape || "").toLowerCase() === "circle",
|
|
1709
|
+
mirror: !/^(no|false|off)$/i.test(deck.pip_mirror || ""),
|
|
1710
|
+
full: false,
|
|
1711
|
+
off: false,
|
|
1712
|
+
flip: false,
|
|
1713
|
+
used: false
|
|
1714
|
+
};
|
|
1715
|
+
applyPreset(st, slideCameraPreset());
|
|
1716
|
+
applyPreset(st, camManual);
|
|
1717
|
+
if (!CORNERS.includes(st.corner) && (cameraStream || st.used)) st.corner = "bottom-right";
|
|
1718
|
+
if (st.flip && CORNERS.includes(st.corner))
|
|
1719
|
+
st.corner = st.corner.includes("left") ? st.corner.replace("left", "right") : st.corner.replace("right", "left");
|
|
1720
|
+
return st;
|
|
1721
|
+
}
|
|
1722
|
+
function applyPipState() {
|
|
1723
|
+
const first = !pipEl.hidden && pipEl.offsetWidth ? pipEl.getBoundingClientRect() : null;
|
|
1724
|
+
const st = pipState = computePipState();
|
|
1725
|
+
const valid = CORNERS.includes(st.corner);
|
|
1726
|
+
pipEl.className = valid ? [st.corner, st.circle && "circle", cameraStream && "live", st.mirror && "mirror", st.full && "full"].filter(Boolean).join(" ") : "";
|
|
1727
|
+
pipEl.style.width = st.size + "%";
|
|
1728
|
+
pipEl.hidden = !valid || cameraOff || st.off;
|
|
1729
|
+
stageWrap.dataset.pip = pipEl.hidden || st.full ? "none" : st.corner;
|
|
1730
|
+
if (pipEl.hidden || reduceMotion || !pipEl.animate) return;
|
|
1731
|
+
const ease = "cubic-bezier(.65,0,.35,1)";
|
|
1732
|
+
if (!first) {
|
|
1733
|
+
pipEl.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 300, easing: "ease-out" });
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const last = pipEl.getBoundingClientRect();
|
|
1737
|
+
if (Math.abs(first.left - last.left) + Math.abs(first.top - last.top) + Math.abs(first.width - last.width) + Math.abs(first.height - last.height) < 2) return;
|
|
1738
|
+
pipEl.animate([
|
|
1739
|
+
{ transformOrigin: "0 0", transform: "translate(" + (first.left - last.left) + "px," + (first.top - last.top) + "px) scale(" + first.width / last.width + "," + first.height / last.height + ")" },
|
|
1740
|
+
{ transformOrigin: "0 0", transform: "none" }
|
|
1741
|
+
], { duration: 600, easing: ease });
|
|
1742
|
+
}
|
|
1743
|
+
function pipRect() {
|
|
1744
|
+
const st = pipState;
|
|
1745
|
+
if (!st || pipEl.hidden || st.full) return null;
|
|
1746
|
+
const vw = stage.clientWidth, vh = stage.clientHeight, m = 16;
|
|
1747
|
+
const w = vw * st.size / 100, h = st.circle ? w : w * 9 / 16;
|
|
1748
|
+
const x0 = st.corner.includes("left") ? m : vw - m - w;
|
|
1749
|
+
const y0 = st.corner.includes("top") ? m : vh - m - h;
|
|
1750
|
+
return { x0, y0, x1: x0 + w, y1: y0 + h };
|
|
1751
|
+
}
|
|
1752
|
+
function cycleCamera() {
|
|
1753
|
+
if (!RECORDING_UI) return;
|
|
1754
|
+
if (cameraOff) {
|
|
1755
|
+
setCameraEnabled(true);
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
const list = cameraList();
|
|
1759
|
+
camCycle = (camCycle + 1) % list.length;
|
|
1760
|
+
camManual = list[camCycle];
|
|
1761
|
+
applyPipState();
|
|
1762
|
+
if (!presenting) showPipMsg("Camera: " + camManual);
|
|
1763
|
+
if (!cameraStream && !pipEl.hidden) startWebcam();
|
|
1764
|
+
else refocus();
|
|
1765
|
+
}
|
|
1766
|
+
function parseDeck2(src) {
|
|
1767
|
+
const parsed = parseDeck(src, { render: renderMd });
|
|
1768
|
+
deck = parsed.deck;
|
|
1769
|
+
nodes = parsed.nodes;
|
|
1770
|
+
applyDeckSettings();
|
|
1771
|
+
const format = { "+++": "+++ format", reveal: "reveal.js format", headings: "headings" }[parsed.format];
|
|
1772
|
+
statusCount.textContent = nodes.size + (nodes.size === 1 ? " card" : " cards") + " \xB7 " + format;
|
|
1773
|
+
statusErr.textContent = parsed.errCount ? parsed.errCount + " card(s) had errors" : "";
|
|
1774
|
+
}
|
|
1775
|
+
function computeTopology() {
|
|
1776
|
+
roots = [...nodes.values()].filter((n) => !n.parent).map((n) => n.id);
|
|
1777
|
+
let leafCounter = 0;
|
|
1778
|
+
function assign(id, depth) {
|
|
1779
|
+
const n = nodes.get(id);
|
|
1780
|
+
n.depth = depth;
|
|
1781
|
+
if (n.children.length === 0) {
|
|
1782
|
+
n._slot = leafCounter++;
|
|
1783
|
+
} else {
|
|
1784
|
+
n.children.forEach((c) => assign(c, depth + 1));
|
|
1785
|
+
const slots = n.children.map((c) => nodes.get(c)._slot);
|
|
1786
|
+
n._slot = (Math.min(...slots) + Math.max(...slots)) / 2;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
roots.forEach((r) => assign(r, 0));
|
|
1790
|
+
order = [];
|
|
1791
|
+
function dfs(id) {
|
|
1792
|
+
order.push(id);
|
|
1793
|
+
nodes.get(id).children.forEach(dfs);
|
|
1794
|
+
}
|
|
1795
|
+
roots.forEach(dfs);
|
|
1796
|
+
return Math.max(1, leafCounter);
|
|
1797
|
+
}
|
|
1798
|
+
function depthStats() {
|
|
1799
|
+
const maxH = [], maxW = [], count = [];
|
|
1800
|
+
nodes.forEach((n) => {
|
|
1801
|
+
maxH[n.depth] = Math.max(maxH[n.depth] || 0, n._h);
|
|
1802
|
+
maxW[n.depth] = Math.max(maxW[n.depth] || 0, n._w);
|
|
1803
|
+
count[n.depth] = (count[n.depth] || 0) + 1;
|
|
1804
|
+
});
|
|
1805
|
+
return { maxH, maxW, count, maxDepth: maxH.length - 1 };
|
|
1806
|
+
}
|
|
1807
|
+
function applyManual(n) {
|
|
1808
|
+
if (n.x !== null && !isNaN(n.x)) n.cx = n.x + n._w / 2;
|
|
1809
|
+
if (n.y !== null && !isNaN(n.y)) n.cy = n.y + n._h / 2;
|
|
1810
|
+
}
|
|
1811
|
+
function layoutTree() {
|
|
1812
|
+
const { maxH, maxDepth } = depthStats();
|
|
1813
|
+
const rowTop = [0];
|
|
1814
|
+
for (let d = 1; d <= maxDepth; d++) rowTop[d] = rowTop[d - 1] + maxH[d - 1] + VERTICAL_GAP;
|
|
1815
|
+
const GAP = SPACING_X - NODE_W;
|
|
1816
|
+
const rightEdge = [];
|
|
1817
|
+
const shift = (id, dx) => {
|
|
1818
|
+
const n = nodes.get(id);
|
|
1819
|
+
n.cx += dx;
|
|
1820
|
+
n.children.forEach((c) => shift(c, dx));
|
|
1821
|
+
};
|
|
1822
|
+
const mark = (id) => {
|
|
1823
|
+
const n = nodes.get(id);
|
|
1824
|
+
rightEdge[n.depth] = Math.max(rightEdge[n.depth] ?? -Infinity, n.cx + n._w / 2);
|
|
1825
|
+
n.children.forEach(mark);
|
|
1826
|
+
};
|
|
1827
|
+
function place(id) {
|
|
1828
|
+
const n = nodes.get(id);
|
|
1829
|
+
const minLeft = rightEdge[n.depth] !== void 0 ? rightEdge[n.depth] + GAP : -Infinity;
|
|
1830
|
+
if (!n.children.length) {
|
|
1831
|
+
n.cx = (minLeft === -Infinity ? 0 : minLeft) + n._w / 2;
|
|
1832
|
+
} else {
|
|
1833
|
+
n.children.forEach(place);
|
|
1834
|
+
n.cx = (nodes.get(n.children[0]).cx + nodes.get(n.children[n.children.length - 1]).cx) / 2;
|
|
1835
|
+
if (n.cx - n._w / 2 < minLeft) shift(id, minLeft - (n.cx - n._w / 2));
|
|
1836
|
+
}
|
|
1837
|
+
mark(id);
|
|
1838
|
+
}
|
|
1839
|
+
roots.forEach(place);
|
|
1840
|
+
nodes.forEach((n) => {
|
|
1841
|
+
n.cy = rowTop[n.depth] + n._h / 2;
|
|
1842
|
+
applyManual(n);
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
function layoutRadial(totalLeaves) {
|
|
1846
|
+
const angleStep = Math.PI * 2 / totalLeaves;
|
|
1847
|
+
const GAP = 32;
|
|
1848
|
+
const placed = [];
|
|
1849
|
+
const overlaps = (a, b) => Math.abs(a.cx - b.cx) < (a._w + b._w) / 2 + GAP && Math.abs(a.cy - b.cy) < (a._h + b._h) / 2 + GAP;
|
|
1850
|
+
const maxDepth = Math.max(0, ...[...nodes.values()].map((n) => n.depth));
|
|
1851
|
+
let prevR = 0;
|
|
1852
|
+
for (let d = 0; d <= maxDepth; d++) {
|
|
1853
|
+
const ring = [...nodes.values()].filter((n) => n.depth === d);
|
|
1854
|
+
if (!ring.length) continue;
|
|
1855
|
+
let radius = d === 0 ? roots.length > 1 ? RADIAL_MIN_STEP * 0.5 : 0 : prevR + RADIAL_GAP;
|
|
1856
|
+
for (let tries = 0; tries < 400; tries++) {
|
|
1857
|
+
ring.forEach((n) => {
|
|
1858
|
+
const angle = (n._slot + 0.5) * angleStep - Math.PI / 2;
|
|
1859
|
+
n.cx = radius * Math.cos(angle);
|
|
1860
|
+
n.cy = radius * Math.sin(angle);
|
|
1861
|
+
applyManual(n);
|
|
1862
|
+
});
|
|
1863
|
+
const clash = ring.some((n, i) => ring.some((m, j) => j > i && overlaps(n, m)) || placed.some((m) => overlaps(n, m)));
|
|
1864
|
+
if (!clash) break;
|
|
1865
|
+
radius = radius * 1.02 + 10;
|
|
1866
|
+
}
|
|
1867
|
+
prevR = radius;
|
|
1868
|
+
placed.push(...ring);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
function applyElementComments(root) {
|
|
1872
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
|
|
1873
|
+
const list = [];
|
|
1874
|
+
while (walker.nextNode()) list.push(walker.currentNode);
|
|
1875
|
+
list.forEach((c) => {
|
|
1876
|
+
const m = c.data.match(/^\s*\.element:\s*([\s\S]*)$/);
|
|
1877
|
+
if (!m) return;
|
|
1878
|
+
let prev = c.previousSibling;
|
|
1879
|
+
while (prev && prev.nodeType === 3 && !prev.data.trim()) prev = prev.previousSibling;
|
|
1880
|
+
const target = prev && prev.nodeType === 1 ? prev : c.parentElement;
|
|
1881
|
+
if (!target) return;
|
|
1882
|
+
Object.entries(attrsOf(m[1])).forEach(([k, v]) => {
|
|
1883
|
+
if (k === "class") target.classList.add(...v.split(/\s+/).filter(Boolean));
|
|
1884
|
+
else if (k === "style") target.style.cssText += ";" + v;
|
|
1885
|
+
else target.setAttribute(k, v);
|
|
1886
|
+
});
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
function figureFor(img) {
|
|
1890
|
+
const fig = document.createElement("figure");
|
|
1891
|
+
fig.className = "media";
|
|
1892
|
+
img.replaceWith(fig);
|
|
1893
|
+
fig.appendChild(img);
|
|
1894
|
+
const alt = img.getAttribute("alt");
|
|
1895
|
+
if (alt) fig.insertAdjacentHTML("beforeend", "<figcaption>" + escapeHtml(alt) + "</figcaption>");
|
|
1896
|
+
return fig;
|
|
1897
|
+
}
|
|
1898
|
+
function youtubeFigure(v, caption) {
|
|
1899
|
+
const fig = document.createElement("figure");
|
|
1900
|
+
fig.className = "media yt fragment yt-play" + (v.portrait ? " portrait" : "");
|
|
1901
|
+
fig.innerHTML = '<div class="frame"><iframe src="' + embedUrl(v) + '" title="' + escapeHtml(caption || "YouTube video") + '" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen loading="lazy"></iframe></div>' + (caption ? "<figcaption>" + escapeHtml(caption) + "</figcaption>" : "");
|
|
1902
|
+
return fig;
|
|
1903
|
+
}
|
|
1904
|
+
function gridSize(el, n) {
|
|
1905
|
+
const cols = n <= 4 ? n : n <= 6 ? 3 : 4;
|
|
1906
|
+
el.style.setProperty("--cols", cols);
|
|
1907
|
+
el.style.setProperty("--rows", Math.ceil(n / cols));
|
|
1908
|
+
}
|
|
1909
|
+
var onlyImages = (p) => p.querySelector("img") && !p.textContent.trim() && [...p.children].every((c) => /^(IMG|BR)$/.test(c.tagName));
|
|
1910
|
+
function applyMedia(el, body) {
|
|
1911
|
+
body.querySelectorAll("pre > code.language-svg").forEach((code) => {
|
|
1912
|
+
const img = document.createElement("img");
|
|
1913
|
+
img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(code.textContent.trim());
|
|
1914
|
+
img.alt = "";
|
|
1915
|
+
const p = document.createElement("p");
|
|
1916
|
+
p.appendChild(img);
|
|
1917
|
+
code.parentElement.replaceWith(p);
|
|
1918
|
+
});
|
|
1919
|
+
body.querySelectorAll(":scope > p").forEach((p) => {
|
|
1920
|
+
const only = p.children.length === 1 ? p.children[0] : null;
|
|
1921
|
+
if (!only) return;
|
|
1922
|
+
const href = only.tagName === "A" && p.textContent.trim() === only.textContent.trim() ? only.getAttribute("href") : only.tagName === "IMG" ? only.getAttribute("src") : null;
|
|
1923
|
+
const v = href && youtubeVideo(href);
|
|
1924
|
+
if (v) p.replaceWith(youtubeFigure(v, only.tagName === "IMG" ? only.getAttribute("alt") : ""));
|
|
1925
|
+
});
|
|
1926
|
+
body.querySelectorAll(":scope > ul, :scope > ol").forEach((list) => {
|
|
1927
|
+
const items = [...list.children];
|
|
1928
|
+
if (!items.length || !items.every((li) => li.querySelector("img") && !li.textContent.trim())) return;
|
|
1929
|
+
list.classList.add("gallery");
|
|
1930
|
+
items.forEach((li) => {
|
|
1931
|
+
const img = li.querySelector("img");
|
|
1932
|
+
li.innerHTML = "";
|
|
1933
|
+
li.appendChild(img);
|
|
1934
|
+
figureFor(img);
|
|
1935
|
+
});
|
|
1936
|
+
if (items.length > 1 && items.every((li) => li.classList.contains("fragment"))) {
|
|
1937
|
+
list.classList.add("carousel");
|
|
1938
|
+
items[0].classList.remove("fragment", "fade-up");
|
|
1939
|
+
items.forEach((li, i) => {
|
|
1940
|
+
li.classList.replace("fade-up", "current-visible");
|
|
1941
|
+
const cap = li.querySelector("figcaption");
|
|
1942
|
+
if (cap) cap.dataset.count = i + 1 + " / " + items.length;
|
|
1943
|
+
});
|
|
1944
|
+
} else gridSize(list, items.length);
|
|
1945
|
+
});
|
|
1946
|
+
body.querySelectorAll(":scope > p").forEach((p) => {
|
|
1947
|
+
if (!onlyImages(p)) return;
|
|
1948
|
+
const imgs = [...p.querySelectorAll("img")];
|
|
1949
|
+
if (imgs.length === 1) {
|
|
1950
|
+
p.replaceWith(imgs[0]);
|
|
1951
|
+
figureFor(imgs[0]);
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
const grid = document.createElement("div");
|
|
1955
|
+
grid.className = "gallery grid";
|
|
1956
|
+
p.replaceWith(grid);
|
|
1957
|
+
imgs.forEach((img) => {
|
|
1958
|
+
grid.appendChild(img);
|
|
1959
|
+
figureFor(img);
|
|
1960
|
+
});
|
|
1961
|
+
gridSize(grid, imgs.length);
|
|
1962
|
+
});
|
|
1963
|
+
const parts = [...body.children].filter((c) => !/^H[1-6]$/.test(c.tagName) && !(c.nodeType === 1 && c.tagName === "HR"));
|
|
1964
|
+
const media = parts.filter((c) => c.matches("figure.media"));
|
|
1965
|
+
if (media.length === 1 && parts.length === 1) el.classList.add("card-media");
|
|
1966
|
+
if (parts.length === 1 && (parts[0].matches("figure.media:not(.yt)") || parts[0].matches(".gallery.carousel"))) el.classList.add("card-bleed");
|
|
1967
|
+
const walker = document.createTreeWalker(body, NodeFilter.SHOW_COMMENT);
|
|
1968
|
+
while (walker.nextNode()) if (/^\s*view\s*:\s*full\s*$/i.test(walker.currentNode.data)) el.classList.add("card-full");
|
|
1969
|
+
else if (media.length === 1) {
|
|
1970
|
+
el.classList.add("card-split", parts.indexOf(media[0]) === 0 ? "media-first" : "media-last");
|
|
1971
|
+
const text = document.createElement("div");
|
|
1972
|
+
text.className = "split-text";
|
|
1973
|
+
parts.filter((c) => c !== media[0]).forEach((c) => text.appendChild(c));
|
|
1974
|
+
media[0].after(text);
|
|
1975
|
+
if (parts.indexOf(media[0]) !== 0) text.after(media[0]);
|
|
1976
|
+
}
|
|
1977
|
+
if (body.querySelector(".gallery")) el.classList.add("card-gallery");
|
|
1978
|
+
}
|
|
1979
|
+
function youtubeCommand(fig, func) {
|
|
1980
|
+
const f = fig.querySelector("iframe");
|
|
1981
|
+
if (f && f.contentWindow) f.contentWindow.postMessage(JSON.stringify({ event: "command", func, args: [] }), "*");
|
|
1982
|
+
}
|
|
1983
|
+
function applyStepsComments(root) {
|
|
1984
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
|
|
1985
|
+
const found = [];
|
|
1986
|
+
while (walker.nextNode()) if (/^\s*steps\s*$/i.test(walker.currentNode.data)) found.push(walker.currentNode);
|
|
1987
|
+
found.forEach((c) => {
|
|
1988
|
+
let next = c.nextSibling;
|
|
1989
|
+
while (next && next.nodeType !== 1) next = next.nextSibling;
|
|
1990
|
+
if (next && /^(UL|OL)$/.test(next.tagName)) next.querySelectorAll(":scope > li").forEach((li) => li.classList.add("fragment", "fade-up"));
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
function collectFragments(root) {
|
|
1994
|
+
const items = [...root.querySelectorAll(".fragment")].map((e, i) => ({ e, i, k: e.dataset.fragmentIndex }));
|
|
1995
|
+
if (items.every((x) => x.k === void 0)) return items.map((x) => [x.e]);
|
|
1996
|
+
let next = 0;
|
|
1997
|
+
items.forEach((x) => {
|
|
1998
|
+
x.k = x.k === void 0 ? next : parseFloat(x.k);
|
|
1999
|
+
next = Math.max(next, x.k) + 1;
|
|
2000
|
+
});
|
|
2001
|
+
items.sort((a, b) => a.k - b.k || a.i - b.i);
|
|
2002
|
+
const groups = [];
|
|
2003
|
+
items.forEach((x, j) => {
|
|
2004
|
+
if (j && items[j - 1].k === x.k) groups[groups.length - 1].push(x.e);
|
|
2005
|
+
else groups.push([x.e]);
|
|
2006
|
+
});
|
|
2007
|
+
return groups;
|
|
2008
|
+
}
|
|
2009
|
+
function applyFragments(n, count, snap) {
|
|
2010
|
+
if (!n || !n.frags) return;
|
|
2011
|
+
if (snap) n.el.classList.add("snap");
|
|
2012
|
+
n.frags.forEach((g, i) => g.forEach((e) => {
|
|
2013
|
+
const was = e.classList.contains("visible");
|
|
2014
|
+
e.classList.toggle("visible", i < count);
|
|
2015
|
+
e.classList.toggle("current-fragment", i === count - 1);
|
|
2016
|
+
if (e.classList.contains("yt-play") && was !== i < count && !snap) youtubeCommand(e, i < count ? "playVideo" : "pauseVideo");
|
|
2017
|
+
}));
|
|
2018
|
+
if (snap) {
|
|
2019
|
+
void n.el.offsetWidth;
|
|
2020
|
+
n.el.classList.remove("snap");
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
var deckBase = null;
|
|
2024
|
+
function deckBaseUrl() {
|
|
2025
|
+
try {
|
|
2026
|
+
return deck.base ? new URL(deck.base, deckBase || location.href) : deckBase ? new URL(deckBase) : null;
|
|
2027
|
+
} catch (e) {
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
function resolveUrls(root) {
|
|
2032
|
+
const base = deckBaseUrl();
|
|
2033
|
+
let unresolved = 0;
|
|
2034
|
+
root.querySelectorAll("img[src], source[src], video[src], iframe[src], a[href]").forEach((el) => {
|
|
2035
|
+
const attr = el.hasAttribute("src") ? "src" : "href";
|
|
2036
|
+
const v = el.getAttribute(attr);
|
|
2037
|
+
if (!v || /^(#|[a-z][a-z0-9+.-]*:|\/\/)/i.test(v)) return;
|
|
2038
|
+
if (!base) {
|
|
2039
|
+
if (attr === "src") unresolved++;
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
let site = base;
|
|
2043
|
+
try {
|
|
2044
|
+
if (deck.site) site = new URL(deck.site, base);
|
|
2045
|
+
} catch (e) {
|
|
2046
|
+
}
|
|
2047
|
+
el.setAttribute(attr, new URL(v, v.startsWith("/") ? site : base).href);
|
|
2048
|
+
});
|
|
2049
|
+
return unresolved;
|
|
2050
|
+
}
|
|
2051
|
+
function sizeCard(n) {
|
|
2052
|
+
const el = n.el, b = el.querySelector(".body");
|
|
2053
|
+
el.classList.add("measuring");
|
|
2054
|
+
b.style.zoom = "";
|
|
2055
|
+
let w = NODE_W;
|
|
2056
|
+
n.visual = !!b.querySelector("iframe, .echarts-container, pre > code.language-dot, pre > code.language-d2, pre > code.language-echarts, .diagram, figure.media");
|
|
2057
|
+
if (n.visual) w = XWIDE_W;
|
|
2058
|
+
const full = el.classList.contains("card-full");
|
|
2059
|
+
el.classList.remove("img-portrait", "img-landscape", "img-overlay");
|
|
2060
|
+
if (full) w = XWIDE_W;
|
|
2061
|
+
if (el.classList.contains("card-bleed")) {
|
|
2062
|
+
const aspect = Math.max(0, ...[...b.querySelectorAll("img")].map((i) => i.naturalWidth && i.naturalHeight ? i.naturalWidth / i.naturalHeight : 0)) || 16 / 9;
|
|
2063
|
+
if (full || Math.abs(aspect - 16 / 9) < 0.08) {
|
|
2064
|
+
el.classList.add("img-overlay");
|
|
2065
|
+
w = XWIDE_W;
|
|
2066
|
+
} else if (aspect < 1.3) {
|
|
2067
|
+
const iw = Math.min(Math.round(BLEED_H * aspect), XWIDE_W - 300);
|
|
2068
|
+
el.classList.add("img-portrait");
|
|
2069
|
+
el.style.setProperty("--img-w", iw + "px");
|
|
2070
|
+
w = Math.min(XWIDE_W, Math.max(WIDE_W, iw * 2));
|
|
2071
|
+
} else {
|
|
2072
|
+
el.classList.add("img-landscape");
|
|
2073
|
+
w = Math.round(Math.max(NODE_W, Math.min(XWIDE_W, (BLEED_H - BLEED_BANDS) * aspect)));
|
|
2074
|
+
el.style.setProperty("--img-h", Math.round(w / aspect) + "px");
|
|
2075
|
+
}
|
|
2076
|
+
} else if (b.querySelector('[style*="flex"], [style*="grid"], .r-hstack') || b.querySelectorAll("img").length >= 4) w = WIDE_W;
|
|
2077
|
+
const tables = b.querySelectorAll("table");
|
|
2078
|
+
if (tables.length) {
|
|
2079
|
+
el.style.width = XWIDE_W + "px";
|
|
2080
|
+
const pad = el.offsetWidth - b.clientWidth;
|
|
2081
|
+
tables.forEach((t) => {
|
|
2082
|
+
w = Math.max(w, Math.min(WIDE_W, Math.ceil(t.offsetWidth) + pad + 12));
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
const growers = b.querySelectorAll(".fragment.grow");
|
|
2086
|
+
if (growers.length) {
|
|
2087
|
+
el.style.width = w + "px";
|
|
2088
|
+
const pad = el.offsetWidth - b.clientWidth;
|
|
2089
|
+
growers.forEach((g) => {
|
|
2090
|
+
w = Math.max(w, Math.min(XWIDE_W, Math.ceil(g.offsetWidth * 1.3) + pad));
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
el.style.width = w + "px";
|
|
2094
|
+
if (el.scrollWidth > w + 2) el.style.width = (w = Math.min(XWIDE_W, el.scrollWidth + 24)) + "px";
|
|
2095
|
+
if (b.scrollWidth > b.clientWidth + 2) b.style.zoom = (b.clientWidth / b.scrollWidth).toFixed(3);
|
|
2096
|
+
n._w = w;
|
|
2097
|
+
n._h = el.offsetHeight || NODE_H_EST;
|
|
2098
|
+
el.classList.remove("measuring");
|
|
2099
|
+
}
|
|
2100
|
+
var relayoutTimer = null;
|
|
2101
|
+
function relayoutSoon() {
|
|
2102
|
+
clearTimeout(relayoutTimer);
|
|
2103
|
+
relayoutTimer = setTimeout(() => {
|
|
2104
|
+
nodes.forEach(sizeCard);
|
|
2105
|
+
position();
|
|
2106
|
+
refocus(true);
|
|
2107
|
+
}, 200);
|
|
2108
|
+
}
|
|
2109
|
+
var VIZ_URL = "https://cdn.jsdelivr.net/npm/@viz-js/viz@3.4.0/lib/viz-standalone.js";
|
|
2110
|
+
var ECHARTS_URL = "https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js";
|
|
2111
|
+
var ECHARTS_THEME = {
|
|
2112
|
+
dark: {
|
|
2113
|
+
palette: ["#e0b024", "#60a5fa", "#34d399", "#f472b6", "#a78bfa", "#fb923c", "#a1a1aa"],
|
|
2114
|
+
text: "#e4e4e7",
|
|
2115
|
+
muted: "#a1a1aa",
|
|
2116
|
+
line: "#3f3f46",
|
|
2117
|
+
split: "#27272a",
|
|
2118
|
+
tip: "#18181b"
|
|
2119
|
+
},
|
|
2120
|
+
light: {
|
|
2121
|
+
palette: ["#c4930f", "#2563eb", "#059669", "#db2777", "#7c3aed", "#ea580c", "#71717a"],
|
|
2122
|
+
text: "#27272a",
|
|
2123
|
+
muted: "#71717a",
|
|
2124
|
+
line: "#d4d4d8",
|
|
2125
|
+
split: "#e4e4e7",
|
|
2126
|
+
tip: "#ffffff"
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
function registerChartThemes() {
|
|
2130
|
+
Object.entries(ECHARTS_THEME).forEach(([mode, t]) => {
|
|
2131
|
+
const axis = {
|
|
2132
|
+
axisLine: { lineStyle: { color: t.line } },
|
|
2133
|
+
axisTick: { lineStyle: { color: t.line } },
|
|
2134
|
+
axisLabel: { color: t.muted },
|
|
2135
|
+
splitLine: { lineStyle: { color: t.split } },
|
|
2136
|
+
nameTextStyle: { color: t.muted }
|
|
2137
|
+
};
|
|
2138
|
+
echarts.registerTheme("slidetake-" + mode, {
|
|
2139
|
+
color: t.palette,
|
|
2140
|
+
backgroundColor: "transparent",
|
|
2141
|
+
textStyle: { color: t.text, fontFamily: "'IBM Plex Sans', sans-serif" },
|
|
2142
|
+
title: { textStyle: { color: t.text }, subtextStyle: { color: t.muted } },
|
|
2143
|
+
legend: { textStyle: { color: t.text } },
|
|
2144
|
+
tooltip: { backgroundColor: t.tip, borderColor: t.line, textStyle: { color: t.text } },
|
|
2145
|
+
categoryAxis: axis,
|
|
2146
|
+
valueAxis: axis,
|
|
2147
|
+
logAxis: axis,
|
|
2148
|
+
timeAxis: axis,
|
|
2149
|
+
line: { symbolSize: 6, lineStyle: { width: 2.5 } }
|
|
2150
|
+
});
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
var D2_URL = "https://esm.sh/@terrastruct/d2@0.1.33";
|
|
2154
|
+
var d2 = null;
|
|
2155
|
+
var D2_THEME = {
|
|
2156
|
+
dark: {
|
|
2157
|
+
N1: "#e4e4e7",
|
|
2158
|
+
N2: "#a1a1aa",
|
|
2159
|
+
N3: "#a1a1aa",
|
|
2160
|
+
N4: "#323238",
|
|
2161
|
+
N5: "#27272a",
|
|
2162
|
+
N6: "#18181b",
|
|
2163
|
+
N7: "#09090b",
|
|
2164
|
+
B1: "#e0b024",
|
|
2165
|
+
B2: "#907320",
|
|
2166
|
+
B3: "#68551f",
|
|
2167
|
+
B4: "#483c1d",
|
|
2168
|
+
B5: "#38301c",
|
|
2169
|
+
B6: "#2c271c"
|
|
2170
|
+
},
|
|
2171
|
+
light: {
|
|
2172
|
+
N1: "#27272a",
|
|
2173
|
+
N2: "#71717a",
|
|
2174
|
+
N3: "#71717a",
|
|
2175
|
+
N4: "#e4e4e7",
|
|
2176
|
+
N5: "#e4e4e7",
|
|
2177
|
+
N6: "#f4f4f5",
|
|
2178
|
+
N7: "#ffffff",
|
|
2179
|
+
B1: "#7a5c12",
|
|
2180
|
+
B2: "#e5cf87",
|
|
2181
|
+
B3: "#eedfaf",
|
|
2182
|
+
B4: "#f5eccf",
|
|
2183
|
+
B5: "#f8f2df",
|
|
2184
|
+
B6: "#fbf7eb"
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2187
|
+
var withD2Defaults = (code) => /d2-config\s*:/.test(code) ? code : "vars: {\n d2-config: {\n layout-engine: elk\n }\n}\n" + code;
|
|
2188
|
+
var scripts = {};
|
|
2189
|
+
function loadScript(url) {
|
|
2190
|
+
return scripts[url] || (scripts[url] = new Promise((resolve, reject) => {
|
|
2191
|
+
const s = document.createElement("script");
|
|
2192
|
+
s.src = url;
|
|
2193
|
+
s.onload = resolve;
|
|
2194
|
+
s.onerror = () => {
|
|
2195
|
+
delete scripts[url];
|
|
2196
|
+
reject(new Error("could not load " + url));
|
|
2197
|
+
};
|
|
2198
|
+
document.head.appendChild(s);
|
|
2199
|
+
}));
|
|
2200
|
+
}
|
|
2201
|
+
var buildGen = 0;
|
|
2202
|
+
var viz = null;
|
|
2203
|
+
async function renderRich() {
|
|
2204
|
+
const gen = buildGen;
|
|
2205
|
+
const dots = [...world.querySelectorAll(".node pre > code.language-dot")];
|
|
2206
|
+
world.querySelectorAll(".node pre > code.language-echarts").forEach((code) => {
|
|
2207
|
+
const div = document.createElement("div");
|
|
2208
|
+
div.className = "echarts-container";
|
|
2209
|
+
div.dataset.chart = code.textContent;
|
|
2210
|
+
code.parentElement.replaceWith(div);
|
|
2211
|
+
});
|
|
2212
|
+
const charts = [...world.querySelectorAll(".node .echarts-container[data-chart]")];
|
|
2213
|
+
const d2s = [...world.querySelectorAll(".node pre > code.language-d2")];
|
|
2214
|
+
if (!dots.length && !charts.length && !d2s.length) return;
|
|
2215
|
+
const problems = [];
|
|
2216
|
+
if (dots.length) {
|
|
2217
|
+
try {
|
|
2218
|
+
await loadScript(VIZ_URL);
|
|
2219
|
+
viz = viz || await Viz.instance();
|
|
2220
|
+
if (gen !== buildGen) return;
|
|
2221
|
+
dots.forEach((code) => {
|
|
2222
|
+
const box = document.createElement("div");
|
|
2223
|
+
box.className = "diagram";
|
|
2224
|
+
try {
|
|
2225
|
+
box.appendChild(viz.renderSVGElement(code.textContent));
|
|
2226
|
+
} catch (e) {
|
|
2227
|
+
box.className = "diagram err";
|
|
2228
|
+
box.textContent = "Diagram error: " + e.message;
|
|
2229
|
+
}
|
|
2230
|
+
code.parentElement.replaceWith(box);
|
|
2231
|
+
});
|
|
2232
|
+
} catch (e) {
|
|
2233
|
+
problems.push("diagrams");
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
if (d2s.length) {
|
|
2237
|
+
try {
|
|
2238
|
+
if (!d2) {
|
|
2239
|
+
const mod = await import(
|
|
2240
|
+
/* runtime, not bundled */
|
|
2241
|
+
D2_URL
|
|
2242
|
+
);
|
|
2243
|
+
d2 = new mod.D2();
|
|
2244
|
+
}
|
|
2245
|
+
if (gen !== buildGen) return;
|
|
2246
|
+
const theme = D2_THEME[currentMode()];
|
|
2247
|
+
for (const code of d2s) {
|
|
2248
|
+
const box = document.createElement("div");
|
|
2249
|
+
box.className = "diagram d2";
|
|
2250
|
+
try {
|
|
2251
|
+
const result = await d2.compile(withD2Defaults(code.textContent));
|
|
2252
|
+
box.innerHTML = await d2.render(result.diagram, { ...result.renderOptions || {}, themeOverrides: theme, darkThemeOverrides: theme });
|
|
2253
|
+
} catch (e) {
|
|
2254
|
+
box.className = "diagram err";
|
|
2255
|
+
box.textContent = "Diagram error: " + (e.message || e);
|
|
2256
|
+
}
|
|
2257
|
+
if (gen !== buildGen) return;
|
|
2258
|
+
code.parentElement.replaceWith(box);
|
|
2259
|
+
}
|
|
2260
|
+
} catch (e) {
|
|
2261
|
+
problems.push("D2 diagrams");
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
if (charts.length) {
|
|
2265
|
+
try {
|
|
2266
|
+
await loadScript(ECHARTS_URL);
|
|
2267
|
+
if (gen !== buildGen) return;
|
|
2268
|
+
if (!echarts._slidetakeThemes) {
|
|
2269
|
+
registerChartThemes();
|
|
2270
|
+
echarts._slidetakeThemes = true;
|
|
2271
|
+
}
|
|
2272
|
+
charts.forEach((div) => {
|
|
2273
|
+
let opt;
|
|
2274
|
+
try {
|
|
2275
|
+
opt = JSON.parse(div.dataset.chart);
|
|
2276
|
+
} catch (e) {
|
|
2277
|
+
div.textContent = "Chart data is not valid JSON.";
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
echarts.init(div, "slidetake-" + (currentMode() === "light" ? "light" : "dark"), { renderer: "svg" }).setOption(Object.assign({ backgroundColor: "transparent", animation: !reduceMotion }, opt));
|
|
2281
|
+
});
|
|
2282
|
+
} catch (e) {
|
|
2283
|
+
problems.push("charts");
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
if (gen !== buildGen) return;
|
|
2287
|
+
if (problems.length) statusErr.textContent = "Could not load the " + problems.join(" and ") + " renderer (offline?)";
|
|
2288
|
+
nodes.forEach(sizeCard);
|
|
2289
|
+
position();
|
|
2290
|
+
refocus(true);
|
|
2291
|
+
}
|
|
2292
|
+
function sectionRuns() {
|
|
2293
|
+
const runs = [];
|
|
2294
|
+
order.forEach((id) => {
|
|
2295
|
+
const sec = sectionOf(id), last = runs[runs.length - 1];
|
|
2296
|
+
if (last && last.sec === sec) last.ids.push(id);
|
|
2297
|
+
else runs.push({ sec, ids: [id] });
|
|
2298
|
+
});
|
|
2299
|
+
return runs;
|
|
2300
|
+
}
|
|
2301
|
+
function layoutPath() {
|
|
2302
|
+
const GAP = 90, ROW_GAP = 120;
|
|
2303
|
+
let y = 0, startX = 0, prevH = 0;
|
|
2304
|
+
sectionRuns().forEach((run, ri) => {
|
|
2305
|
+
const h = Math.max(...run.ids.map((id) => nodes.get(id)._h));
|
|
2306
|
+
if (ri) y += prevH / 2 + ROW_GAP + h / 2;
|
|
2307
|
+
let x = startX, lastCx = startX;
|
|
2308
|
+
run.ids.forEach((id, i) => {
|
|
2309
|
+
const n = nodes.get(id);
|
|
2310
|
+
if (i) x += GAP + n._w / 2;
|
|
2311
|
+
n.cx = x;
|
|
2312
|
+
n.cy = y;
|
|
2313
|
+
lastCx = x;
|
|
2314
|
+
x += n._w / 2;
|
|
2315
|
+
});
|
|
2316
|
+
startX = lastCx;
|
|
2317
|
+
prevH = h;
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
function layoutFocus() {
|
|
2321
|
+
nodes.forEach((n) => {
|
|
2322
|
+
n.cx = 0;
|
|
2323
|
+
n.cy = 0;
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
function build() {
|
|
2327
|
+
buildGen++;
|
|
2328
|
+
if (window.echarts) world.querySelectorAll(".echarts-container").forEach((d) => {
|
|
2329
|
+
const c = echarts.getInstanceByDom(d);
|
|
2330
|
+
if (c) c.dispose();
|
|
2331
|
+
});
|
|
2332
|
+
world.querySelectorAll("div.node").forEach((el) => el.remove());
|
|
2333
|
+
const totalLeaves = computeTopology();
|
|
2334
|
+
let unresolved = 0;
|
|
2335
|
+
nodes.forEach((n) => {
|
|
2336
|
+
const el = document.createElement("div");
|
|
2337
|
+
el.className = "node";
|
|
2338
|
+
el.tabIndex = 0;
|
|
2339
|
+
el.dataset.id = n.id;
|
|
2340
|
+
const crumb = n.parent ? breadcrumbPath(n.id).slice(0, -1).map((id) => nodes.get(id).title).join(" / ") : "";
|
|
2341
|
+
el.innerHTML = (crumb ? '<div class="crumb">' + escapeHtml(crumb) + "</div>" : "") + '<div class="body">' + n.html + "</div>" + (n.err ? '<div class="err-badge">!</div>' : "");
|
|
2342
|
+
const body = el.querySelector(".body");
|
|
2343
|
+
applyElementComments(body);
|
|
2344
|
+
applyStepsComments(body);
|
|
2345
|
+
applyMedia(el, body);
|
|
2346
|
+
body.querySelectorAll("thead").forEach((h) => {
|
|
2347
|
+
if (!h.textContent.trim()) h.remove();
|
|
2348
|
+
});
|
|
2349
|
+
unresolved += resolveUrls(body);
|
|
2350
|
+
n.frags = collectFragments(body);
|
|
2351
|
+
body.querySelectorAll("img").forEach((img) => {
|
|
2352
|
+
if (!img.complete) img.addEventListener("load", relayoutSoon, { once: true });
|
|
2353
|
+
});
|
|
2354
|
+
el.querySelectorAll("a[href]").forEach((a) => {
|
|
2355
|
+
const href = a.getAttribute("href");
|
|
2356
|
+
if (href.startsWith("#")) {
|
|
2357
|
+
const target = decodeURIComponent(href.slice(1));
|
|
2358
|
+
if (nodes.has(target)) {
|
|
2359
|
+
a.classList.add("xlink");
|
|
2360
|
+
a.addEventListener("click", (e) => {
|
|
2361
|
+
e.preventDefault();
|
|
2362
|
+
e.stopPropagation();
|
|
2363
|
+
if (!rec.active) navigate(target);
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
} else {
|
|
2367
|
+
a.target = "_blank";
|
|
2368
|
+
a.rel = "noopener";
|
|
2369
|
+
a.addEventListener("click", (e) => e.stopPropagation());
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
el.addEventListener("click", () => {
|
|
2373
|
+
if (!rec.active) navigate(n.id);
|
|
2374
|
+
});
|
|
2375
|
+
el.addEventListener("keydown", (e) => {
|
|
2376
|
+
if (e.key === "Enter" && e.target === el) navigate(n.id);
|
|
2377
|
+
});
|
|
2378
|
+
world.appendChild(el);
|
|
2379
|
+
n.el = el;
|
|
2380
|
+
applyFragments(n, n.frags.length);
|
|
2381
|
+
});
|
|
2382
|
+
if (unresolved && !statusErr.textContent) statusErr.textContent = unresolved + " image(s) use relative paths: add base: to the deck, or open it with ?src=";
|
|
2383
|
+
nodes.forEach(sizeCard);
|
|
2384
|
+
position(totalLeaves);
|
|
2385
|
+
renderRich();
|
|
2386
|
+
}
|
|
2387
|
+
function position(totalLeaves) {
|
|
2388
|
+
if (totalLeaves === void 0) totalLeaves = computeTopology();
|
|
2389
|
+
if (layoutMode === "radial") layoutRadial(totalLeaves);
|
|
2390
|
+
else if (layoutMode === "path") layoutPath();
|
|
2391
|
+
else if (layoutMode === "focus") layoutFocus();
|
|
2392
|
+
else layoutTree();
|
|
2393
|
+
world.classList.toggle("focus", layoutMode === "focus");
|
|
2394
|
+
nodes.forEach((n) => {
|
|
2395
|
+
const s = n.el.style;
|
|
2396
|
+
s.setProperty("--cx", n.cx);
|
|
2397
|
+
s.setProperty("--cy", n.cy);
|
|
2398
|
+
});
|
|
2399
|
+
drawEdges();
|
|
2400
|
+
updateActivePath();
|
|
2401
|
+
updateMinimap();
|
|
2402
|
+
}
|
|
2403
|
+
function drawEdges() {
|
|
2404
|
+
let path = "";
|
|
2405
|
+
if (layoutMode === "focus") {
|
|
2406
|
+
svg.innerHTML = "";
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
if (layoutMode === "path") {
|
|
2410
|
+
for (let i = 1; i < order.length; i++) {
|
|
2411
|
+
const a = nodes.get(order[i - 1]), b = nodes.get(order[i]);
|
|
2412
|
+
path += '<path data-from="' + a.id + '" data-to="' + b.id + '" d="M ' + a.cx + " " + a.cy + " L " + b.cx + " " + b.cy + '"/>';
|
|
2413
|
+
}
|
|
2414
|
+
svg.innerHTML = path;
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
nodes.forEach((n) => {
|
|
2418
|
+
if (!n.parent) return;
|
|
2419
|
+
const p = nodes.get(n.parent);
|
|
2420
|
+
if (layoutMode === "radial") {
|
|
2421
|
+
path += '<path data-from="' + p.id + '" data-to="' + n.id + '" d="M ' + p.cx + " " + p.cy + " L " + n.cx + " " + n.cy + '"/>';
|
|
2422
|
+
} else {
|
|
2423
|
+
const py = p.cy + p._h / 2, cy = n.cy - n._h / 2, my = py + (cy - py) / 2;
|
|
2424
|
+
path += '<path data-from="' + p.id + '" data-to="' + n.id + '" d="M ' + p.cx + " " + py + " L " + p.cx + " " + my + " L " + n.cx + " " + my + " L " + n.cx + " " + cy + '"/>';
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
svg.innerHTML = path;
|
|
2428
|
+
}
|
|
2429
|
+
function breadcrumbPath(id) {
|
|
2430
|
+
const p = [];
|
|
2431
|
+
let cur = id;
|
|
2432
|
+
while (cur) {
|
|
2433
|
+
p.unshift(cur);
|
|
2434
|
+
cur = nodes.get(cur).parent;
|
|
2435
|
+
}
|
|
2436
|
+
return p;
|
|
2437
|
+
}
|
|
2438
|
+
function applyCamera() {
|
|
2439
|
+
const vw = stage.clientWidth, vh = stage.clientHeight;
|
|
2440
|
+
world.style.transform = "translate(" + vw / 2 + "px," + vh / 2 + "px) scale(" + cam.zoom + ") translate(" + -cam.x + "px," + -cam.y + "px)";
|
|
2441
|
+
updateMinimapViewport();
|
|
2442
|
+
}
|
|
2443
|
+
function stopCamera() {
|
|
2444
|
+
if (camTween) {
|
|
2445
|
+
camTween.kill();
|
|
2446
|
+
camTween = null;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
function flyTo(t, instant) {
|
|
2450
|
+
stopCamera();
|
|
2451
|
+
if (instant || reduceMotion || !window.gsap) {
|
|
2452
|
+
Object.assign(cam, t);
|
|
2453
|
+
applyCamera();
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
const vw = stage.clientWidth;
|
|
2457
|
+
const dist = Math.hypot(t.x - cam.x, t.y - cam.y);
|
|
2458
|
+
const endZoom = t.zoom;
|
|
2459
|
+
const tl = gsap.timeline({ onUpdate: applyCamera, onComplete: () => {
|
|
2460
|
+
camTween = null;
|
|
2461
|
+
} });
|
|
2462
|
+
const { zoom, ...rest } = t;
|
|
2463
|
+
const travel = dist * Math.min(cam.zoom, endZoom);
|
|
2464
|
+
const dur = Math.max(0.55, Math.min(1.3, 0.55 + travel / vw * 0.3));
|
|
2465
|
+
tl.to(cam, { ...rest, duration: dur, ease: "power2.inOut" }, 0);
|
|
2466
|
+
if (travel > vw * 1.2) {
|
|
2467
|
+
const dip = Math.max(0.06, Math.min(cam.zoom, endZoom, vw * 0.9 / (dist + NODE_W)));
|
|
2468
|
+
tl.to(cam, { zoom: dip, duration: dur / 2, ease: "sine.out" }, 0).to(cam, { zoom: endZoom, duration: dur / 2, ease: "sine.in" }, dur / 2);
|
|
2469
|
+
} else {
|
|
2470
|
+
tl.to(cam, { zoom: endZoom, duration: dur, ease: "power2.inOut" }, 0);
|
|
2471
|
+
}
|
|
2472
|
+
camTween = tl;
|
|
2473
|
+
}
|
|
2474
|
+
function obstacles() {
|
|
2475
|
+
const sr = stage.getBoundingClientRect(), pad = 14, out = [];
|
|
2476
|
+
if (!brandEl.hidden && brandEl.offsetWidth) {
|
|
2477
|
+
const r = brandEl.getBoundingClientRect();
|
|
2478
|
+
out.push({ x0: r.left - sr.left - pad, y0: r.top - sr.top - pad, x1: r.right - sr.left + pad, y1: r.bottom - sr.top + pad });
|
|
2479
|
+
}
|
|
2480
|
+
const p = pipRect();
|
|
2481
|
+
if (p) out.push({ x0: p.x0 - pad, y0: p.y0 - pad, x1: p.x1 + pad, y1: p.y1 + pad });
|
|
2482
|
+
return out;
|
|
2483
|
+
}
|
|
2484
|
+
function safeRegions() {
|
|
2485
|
+
const vw = stage.clientWidth, vh = stage.clientHeight;
|
|
2486
|
+
let regions = [{ x0: 16, y0: presenting ? 20 : 56, x1: vw - 16, y1: vh - (presenting ? 20 : 74) }];
|
|
2487
|
+
obstacles().forEach((o) => {
|
|
2488
|
+
const next = [];
|
|
2489
|
+
regions.forEach((r) => {
|
|
2490
|
+
if (o.x1 <= r.x0 || o.x0 >= r.x1 || o.y1 <= r.y0 || o.y0 >= r.y1) {
|
|
2491
|
+
next.push(r);
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
[
|
|
2495
|
+
{ ...r, x1: Math.min(r.x1, o.x0) },
|
|
2496
|
+
{ ...r, x0: Math.max(r.x0, o.x1) },
|
|
2497
|
+
{ ...r, y1: Math.min(r.y1, o.y0) },
|
|
2498
|
+
{ ...r, y0: Math.max(r.y0, o.y1) }
|
|
2499
|
+
].forEach((s) => {
|
|
2500
|
+
if (s.x1 - s.x0 > 80 && s.y1 - s.y0 > 80) next.push(s);
|
|
2501
|
+
});
|
|
2502
|
+
});
|
|
2503
|
+
if (next.length) regions = next;
|
|
2504
|
+
});
|
|
2505
|
+
return regions;
|
|
2506
|
+
}
|
|
2507
|
+
function fitInSafe(w, h, fill) {
|
|
2508
|
+
const vw = stage.clientWidth, vh = stage.clientHeight;
|
|
2509
|
+
let best = null;
|
|
2510
|
+
safeRegions().forEach((r) => {
|
|
2511
|
+
const zoom = fill * Math.min((r.x1 - r.x0) / w, (r.y1 - r.y0) / h);
|
|
2512
|
+
if (!best || zoom > best.zoom) best = { zoom, sx: (r.x0 + r.x1) / 2 - vw / 2, sy: (r.y0 + r.y1) / 2 - vh / 2 };
|
|
2513
|
+
});
|
|
2514
|
+
return best;
|
|
2515
|
+
}
|
|
2516
|
+
function aimAt(x, y, f, zoom) {
|
|
2517
|
+
return { x: x - f.sx / zoom, y: y - f.sy / zoom };
|
|
2518
|
+
}
|
|
2519
|
+
function focusOn(id, instant) {
|
|
2520
|
+
const n = nodes.get(id);
|
|
2521
|
+
if (!n) return;
|
|
2522
|
+
document.body.classList.toggle("full-card", n.el.classList.contains("card-full"));
|
|
2523
|
+
if (n.el.classList.contains("card-full")) {
|
|
2524
|
+
const zoom2 = Math.min(stage.clientWidth / n._w, stage.clientHeight / n._h);
|
|
2525
|
+
flyTo({ x: n.cx, y: n.cy, zoom: zoom2 }, instant);
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
const f = fitInSafe(n._w, n._h, slideFill);
|
|
2529
|
+
const sec = sectionOf(id);
|
|
2530
|
+
const peers = order.filter((x) => sectionOf(x) === sec && !nodes.get(x).visual).map((x) => {
|
|
2531
|
+
const m = nodes.get(x);
|
|
2532
|
+
return fitInSafe(m._w, m._h, slideFill).zoom;
|
|
2533
|
+
}).sort((a, b) => a - b);
|
|
2534
|
+
const steady = peers.length ? peers[Math.floor((peers.length - 1) / 2)] : f.zoom;
|
|
2535
|
+
const zoom = Math.max(0.2, Math.min(5, f.zoom, steady));
|
|
2536
|
+
flyTo(Object.assign(aimAt(n.cx, n.cy, f, zoom), { zoom }), instant);
|
|
2537
|
+
}
|
|
2538
|
+
function fitAll(instant) {
|
|
2539
|
+
document.body.classList.remove("full-card");
|
|
2540
|
+
const all = [...nodes.values()];
|
|
2541
|
+
if (!all.length) return;
|
|
2542
|
+
const vw = stage.clientWidth, vh = stage.clientHeight;
|
|
2543
|
+
const minX = Math.min(...all.map((n) => n.cx - n._w / 2)), maxX = Math.max(...all.map((n) => n.cx + n._w / 2));
|
|
2544
|
+
const minY = Math.min(...all.map((n) => n.cy - n._h / 2)), maxY = Math.max(...all.map((n) => n.cy + n._h / 2));
|
|
2545
|
+
const f = fitInSafe(maxX - minX, maxY - minY, 0.94);
|
|
2546
|
+
const zoom = Math.max(0.05, Math.min(1, f.zoom));
|
|
2547
|
+
flyTo(Object.assign(aimAt((minX + maxX) / 2, (minY + maxY) / 2, f, zoom), { zoom }), instant);
|
|
2548
|
+
}
|
|
2549
|
+
function refocus(instant) {
|
|
2550
|
+
if (currentId && nodes.has(currentId)) focusOn(currentId, instant);
|
|
2551
|
+
else fitAll(instant);
|
|
2552
|
+
}
|
|
2553
|
+
function updateActivePath() {
|
|
2554
|
+
const path = currentId ? breadcrumbPath(currentId) : [];
|
|
2555
|
+
nodes.forEach((n) => {
|
|
2556
|
+
const el = n.el;
|
|
2557
|
+
el.classList.toggle("current", n.id === currentId);
|
|
2558
|
+
el.classList.toggle("active-path", path.includes(n.id));
|
|
2559
|
+
});
|
|
2560
|
+
world.querySelectorAll("#connectors path").forEach((p) => {
|
|
2561
|
+
const lit = layoutMode === "path" ? !!currentId && order.indexOf(p.dataset.to) <= order.indexOf(currentId) : path.includes(p.dataset.from) && path.includes(p.dataset.to);
|
|
2562
|
+
p.classList.toggle("active", lit);
|
|
2563
|
+
});
|
|
2564
|
+
renderBreadcrumbs(path);
|
|
2565
|
+
updateProgress();
|
|
2566
|
+
}
|
|
2567
|
+
var progressEl = document.getElementById("progress");
|
|
2568
|
+
progressEl.innerHTML = "<b></b><i></i>";
|
|
2569
|
+
var talk = { start: 0, timer: null };
|
|
2570
|
+
function talkLength() {
|
|
2571
|
+
return parseDuration(new URLSearchParams(location.search).get("duration") ?? deck.duration);
|
|
2572
|
+
}
|
|
2573
|
+
function timerVisible() {
|
|
2574
|
+
return presenting && talkLength() > 0 && (!rec.active || /^always$/i.test(deck.timer || ""));
|
|
2575
|
+
}
|
|
2576
|
+
function updateTimer() {
|
|
2577
|
+
const on = timerVisible() && talk.start > 0;
|
|
2578
|
+
progressEl.classList.toggle("timed", on);
|
|
2579
|
+
if (!on) {
|
|
2580
|
+
progressEl.classList.remove("over");
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
const elapsed = rec.active && rec.t0 ? recNow() : performance.now() - talk.start;
|
|
2584
|
+
const frac = elapsed / talkLength();
|
|
2585
|
+
progressEl.firstChild.style.width = Math.min(100, frac * 100) + "%";
|
|
2586
|
+
progressEl.classList.toggle("over", frac >= 1);
|
|
2587
|
+
}
|
|
2588
|
+
function startTalkClock() {
|
|
2589
|
+
talk.start = performance.now();
|
|
2590
|
+
clearInterval(talk.timer);
|
|
2591
|
+
talk.timer = setInterval(updateTimer, 1e3);
|
|
2592
|
+
updateTimer();
|
|
2593
|
+
}
|
|
2594
|
+
function stopTalkClock() {
|
|
2595
|
+
clearInterval(talk.timer);
|
|
2596
|
+
talk.timer = null;
|
|
2597
|
+
talk.start = 0;
|
|
2598
|
+
updateTimer();
|
|
2599
|
+
}
|
|
2600
|
+
function updateProgress() {
|
|
2601
|
+
const on = presenting && order.length > 1 && !/^(off|no|false)$/i.test(deck.progress || "");
|
|
2602
|
+
progressEl.classList.toggle("show", on);
|
|
2603
|
+
if (!on) return;
|
|
2604
|
+
updateTimer();
|
|
2605
|
+
const at = order.indexOf(currentId);
|
|
2606
|
+
let total = 0, done = 0;
|
|
2607
|
+
order.forEach((id, i) => {
|
|
2608
|
+
const n = slideSteps(nodes.get(id)).length;
|
|
2609
|
+
total += n;
|
|
2610
|
+
if (i < at) done += n;
|
|
2611
|
+
else if (i === at) done += Math.min(stepPos, n - 1) + 1;
|
|
2612
|
+
});
|
|
2613
|
+
progressEl.lastChild.style.width = (total ? done / total * 100 : 0) + "%";
|
|
2614
|
+
}
|
|
2615
|
+
function renderBreadcrumbs(path) {
|
|
2616
|
+
breadcrumbs.innerHTML = path.map((id, i) => {
|
|
2617
|
+
const sep = i > 0 ? '<span class="sep">\u203A</span>' : "";
|
|
2618
|
+
return sep + '<button class="crumb-btn' + (id === currentId ? " here" : "") + '" data-id="' + escapeHtml(id) + '">' + escapeHtml(nodes.get(id).title) + "</button>";
|
|
2619
|
+
}).join("");
|
|
2620
|
+
breadcrumbs.querySelectorAll(".crumb-btn").forEach((b) => b.addEventListener("click", () => {
|
|
2621
|
+
if (!rec.active) navigate(b.dataset.id);
|
|
2622
|
+
}));
|
|
2623
|
+
}
|
|
2624
|
+
function applyStepState(snap) {
|
|
2625
|
+
const n = nodes.get(currentId);
|
|
2626
|
+
if (!n) return;
|
|
2627
|
+
applyFragments(n, currentStep().frag, snap);
|
|
2628
|
+
applyPipState();
|
|
2629
|
+
if (pipEl.hidden || !pipState || !pipState.full) playEntrances(n);
|
|
2630
|
+
scheduleAutoslide(n);
|
|
2631
|
+
}
|
|
2632
|
+
var TRANSFORM_PROPS = ["x", "y", "xPercent", "yPercent", "scale", "scaleX", "scaleY", "rotation", "rotate", "skewX", "skewY"];
|
|
2633
|
+
function autoEntrance(n) {
|
|
2634
|
+
if (!order.length || n.id !== order[0] && n.id !== order[order.length - 1]) return null;
|
|
2635
|
+
if (n.el.querySelector("[data-gsap], .title-scramble")) return null;
|
|
2636
|
+
return [...n.el.querySelector(".body").children].filter((el) => !el.classList.contains("fragment"));
|
|
2637
|
+
}
|
|
2638
|
+
function playEntrances(n) {
|
|
2639
|
+
if (n._played || !window.gsap || reduceMotion) return;
|
|
2640
|
+
n._played = true;
|
|
2641
|
+
const auto = autoEntrance(n);
|
|
2642
|
+
if (auto && auto.length) {
|
|
2643
|
+
n._auto = auto;
|
|
2644
|
+
const [head, ...rest] = auto;
|
|
2645
|
+
if (/^H[1-3]$/.test(head.tagName) && !head.children.length) {
|
|
2646
|
+
head.classList.add("auto-scramble");
|
|
2647
|
+
scramble(head);
|
|
2648
|
+
} else rest.unshift(head);
|
|
2649
|
+
gsap.from(rest, { opacity: 0, y: 24, duration: 0.7, ease: "power2.out", delay: 0.5, stagger: 0.45 });
|
|
2650
|
+
}
|
|
2651
|
+
n.el.querySelectorAll("[data-gsap]").forEach((el) => {
|
|
2652
|
+
let cfg;
|
|
2653
|
+
try {
|
|
2654
|
+
cfg = JSON.parse(el.dataset.gsap);
|
|
2655
|
+
} catch (e) {
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
const timing = { duration: cfg.duration ?? 1, delay: cfg.delay ?? 0, ease: cfg.ease || "power2.out" };
|
|
2659
|
+
if (cfg.to) gsap.fromTo(el, cfg.from || {}, Object.assign({}, cfg.to, timing));
|
|
2660
|
+
else if (cfg.from) gsap.from(el, Object.assign({}, cfg.from, timing));
|
|
2661
|
+
});
|
|
2662
|
+
n.el.querySelectorAll(".title-scramble").forEach(scramble);
|
|
2663
|
+
}
|
|
2664
|
+
function resetEntrances(n) {
|
|
2665
|
+
if (!n || !n._played) return;
|
|
2666
|
+
n._played = false;
|
|
2667
|
+
if (!window.gsap) return;
|
|
2668
|
+
if (n._auto) {
|
|
2669
|
+
n._auto.forEach((el) => {
|
|
2670
|
+
gsap.killTweensOf(el);
|
|
2671
|
+
gsap.set(el, { clearProps: "opacity,transform" });
|
|
2672
|
+
});
|
|
2673
|
+
n._auto = null;
|
|
2674
|
+
}
|
|
2675
|
+
n.el.querySelectorAll("[data-gsap]").forEach((el) => {
|
|
2676
|
+
gsap.killTweensOf(el);
|
|
2677
|
+
let cfg = {};
|
|
2678
|
+
try {
|
|
2679
|
+
cfg = JSON.parse(el.dataset.gsap);
|
|
2680
|
+
} catch (e) {
|
|
2681
|
+
}
|
|
2682
|
+
const props = new Set(Object.keys(Object.assign({}, cfg.from, cfg.to)).map((k) => TRANSFORM_PROPS.includes(k) ? "transform" : k));
|
|
2683
|
+
if (props.size) gsap.set(el, { clearProps: [...props].join(",") });
|
|
2684
|
+
});
|
|
2685
|
+
n.el.querySelectorAll(".title-scramble, .auto-scramble").forEach((el) => {
|
|
2686
|
+
if (el._scramble) el._scramble.kill();
|
|
2687
|
+
if (el.dataset.text) el.textContent = el.dataset.text;
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
function scramble(el) {
|
|
2691
|
+
const text = el.dataset.text || (el.dataset.text = el.textContent);
|
|
2692
|
+
const chars = Array.from(text), pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*+=?";
|
|
2693
|
+
const st = { p: 0 };
|
|
2694
|
+
el._scramble = gsap.to(st, {
|
|
2695
|
+
p: 1,
|
|
2696
|
+
duration: 1.4,
|
|
2697
|
+
ease: "none",
|
|
2698
|
+
onUpdate() {
|
|
2699
|
+
const done = Math.floor(st.p * chars.length);
|
|
2700
|
+
el.textContent = chars.map((c, i) => i < done || /\s/.test(c) ? c : pool[Math.random() * pool.length | 0]).join("");
|
|
2701
|
+
},
|
|
2702
|
+
onComplete() {
|
|
2703
|
+
el.textContent = text;
|
|
2704
|
+
}
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2707
|
+
var autoTimer = null;
|
|
2708
|
+
function scheduleAutoslide(n) {
|
|
2709
|
+
clearTimeout(autoTimer);
|
|
2710
|
+
if (!presenting || !n || !n.autoslide || rec.active && (!rec.t0 || rec.paused)) return;
|
|
2711
|
+
autoTimer = setTimeout(() => {
|
|
2712
|
+
if (currentId === n.id) step(1);
|
|
2713
|
+
}, n.autoslide);
|
|
2714
|
+
}
|
|
2715
|
+
function setHash(id) {
|
|
2716
|
+
const slide = id && id !== order[0] ? id : "";
|
|
2717
|
+
try {
|
|
2718
|
+
if (view && view.kind === "share") history.replaceState(null, "", location.pathname + location.search + deckHash(view.data, slide));
|
|
2719
|
+
else history.replaceState(null, "", id ? "#" + encodeURIComponent(id) : location.pathname + location.search);
|
|
2720
|
+
} catch (e) {
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
function navigate(id, instant, atLastStep) {
|
|
2724
|
+
if (!nodes.has(id)) return;
|
|
2725
|
+
if (id !== currentId) {
|
|
2726
|
+
camManual = null;
|
|
2727
|
+
camCycle = -1;
|
|
2728
|
+
stepPos = atLastStep ? slideSteps(nodes.get(id)).length - 1 : 0;
|
|
2729
|
+
const prev = nodes.get(currentId);
|
|
2730
|
+
if (prev && layoutMode === "focus" && !instant) {
|
|
2731
|
+
prev.el.classList.add("leaving");
|
|
2732
|
+
setTimeout(() => prev.el.classList.remove("leaving"), 600);
|
|
2733
|
+
}
|
|
2734
|
+
leaveSlide();
|
|
2735
|
+
}
|
|
2736
|
+
const arriving = id !== currentId;
|
|
2737
|
+
currentId = id;
|
|
2738
|
+
clearTimeout(mapTimer);
|
|
2739
|
+
mapTimer = null;
|
|
2740
|
+
if (arriving && layoutMode === "focus" && !instant && !reduceMotion) {
|
|
2741
|
+
const el = nodes.get(id).el;
|
|
2742
|
+
el.classList.add("entering");
|
|
2743
|
+
void el.offsetWidth;
|
|
2744
|
+
el.classList.remove("entering");
|
|
2745
|
+
}
|
|
2746
|
+
applyStepState(arriving);
|
|
2747
|
+
if (arriving) logTake("slide", id);
|
|
2748
|
+
const n = nodes.get(id);
|
|
2749
|
+
if (arriving && n.mapFirst && !atLastStep && !instant && layoutMode !== "focus") {
|
|
2750
|
+
fitAll();
|
|
2751
|
+
mapTimer = setTimeout(() => {
|
|
2752
|
+
mapTimer = null;
|
|
2753
|
+
if (currentId === id) focusOn(id);
|
|
2754
|
+
}, 1900);
|
|
2755
|
+
} else focusOn(id, instant);
|
|
2756
|
+
updateActivePath();
|
|
2757
|
+
updateMinimap();
|
|
2758
|
+
setHash(id);
|
|
2759
|
+
}
|
|
2760
|
+
var mapTimer = null;
|
|
2761
|
+
function leaveSlide() {
|
|
2762
|
+
const prev = nodes.get(currentId);
|
|
2763
|
+
if (!prev) return;
|
|
2764
|
+
prev.el.querySelectorAll("figure.yt").forEach((f) => youtubeCommand(f, "pauseVideo"));
|
|
2765
|
+
applyFragments(prev, prev.frags.length, true);
|
|
2766
|
+
resetEntrances(prev);
|
|
2767
|
+
}
|
|
2768
|
+
var overviewFrom = null;
|
|
2769
|
+
function overview() {
|
|
2770
|
+
if (!currentId && overviewFrom && nodes.has(overviewFrom)) {
|
|
2771
|
+
backFromOverview();
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
if (currentId) overviewFrom = currentId;
|
|
2775
|
+
if (layoutMode === "focus") {
|
|
2776
|
+
setMode("path");
|
|
2777
|
+
}
|
|
2778
|
+
leaveSlide();
|
|
2779
|
+
clearTimeout(autoTimer);
|
|
2780
|
+
currentId = null;
|
|
2781
|
+
updateActivePath();
|
|
2782
|
+
updateMinimap();
|
|
2783
|
+
fitAll();
|
|
2784
|
+
setHash(null);
|
|
2785
|
+
}
|
|
2786
|
+
function backFromOverview() {
|
|
2787
|
+
if (mapTimer) {
|
|
2788
|
+
clearTimeout(mapTimer);
|
|
2789
|
+
mapTimer = null;
|
|
2790
|
+
focusOn(currentId);
|
|
2791
|
+
return true;
|
|
2792
|
+
}
|
|
2793
|
+
if (!currentId && overviewFrom && nodes.has(overviewFrom)) {
|
|
2794
|
+
const id = overviewFrom;
|
|
2795
|
+
overviewFrom = null;
|
|
2796
|
+
navigate(id);
|
|
2797
|
+
return true;
|
|
2798
|
+
}
|
|
2799
|
+
return false;
|
|
2800
|
+
}
|
|
2801
|
+
function step(dir) {
|
|
2802
|
+
if (!currentId) {
|
|
2803
|
+
if (order.length) navigate(order[dir > 0 ? 0 : order.length - 1]);
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
if (mapTimer && dir > 0) {
|
|
2807
|
+
clearTimeout(mapTimer);
|
|
2808
|
+
mapTimer = null;
|
|
2809
|
+
focusOn(currentId);
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
const steps = slideSteps(nodes.get(currentId));
|
|
2813
|
+
const ns = Math.min(stepPos, steps.length - 1) + dir;
|
|
2814
|
+
if (ns >= 0 && ns < steps.length) {
|
|
2815
|
+
stepPos = ns;
|
|
2816
|
+
camManual = null;
|
|
2817
|
+
camCycle = -1;
|
|
2818
|
+
applyStepState();
|
|
2819
|
+
if (!cameraStream && !pipEl.hidden && pipState.used) startWebcam();
|
|
2820
|
+
else refocus();
|
|
2821
|
+
updateActivePath();
|
|
2822
|
+
return;
|
|
2823
|
+
}
|
|
2824
|
+
const ni = order.indexOf(currentId) + dir;
|
|
2825
|
+
if (ni >= 0 && ni < order.length) navigate(order[ni], false, dir < 0);
|
|
2826
|
+
}
|
|
2827
|
+
function toParent() {
|
|
2828
|
+
const n = nodes.get(currentId);
|
|
2829
|
+
if (n && n.parent) navigate(n.parent);
|
|
2830
|
+
}
|
|
2831
|
+
function toChild() {
|
|
2832
|
+
const n = nodes.get(currentId);
|
|
2833
|
+
if (n && n.children.length) navigate(n.children[0]);
|
|
2834
|
+
else if (!currentId && order.length) navigate(order[0]);
|
|
2835
|
+
}
|
|
2836
|
+
var mm = null;
|
|
2837
|
+
function updateMinimap() {
|
|
2838
|
+
const all = [...nodes.values()];
|
|
2839
|
+
if (!all.length) {
|
|
2840
|
+
mmSvg.innerHTML = "";
|
|
2841
|
+
mm = null;
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
mmLabel.textContent = "map";
|
|
2845
|
+
const px = (n) => n.cx, py = (n) => n.cy;
|
|
2846
|
+
const minX = Math.min(...all.map(px)) - NODE_W / 2, maxX = Math.max(...all.map(px)) + NODE_W / 2;
|
|
2847
|
+
const minY = Math.min(...all.map(py)) - NODE_H_EST / 2, maxY = Math.max(...all.map(py)) + NODE_H_EST / 2;
|
|
2848
|
+
const pad = 16, W = 180, H = 130;
|
|
2849
|
+
const s = Math.min((W - 2 * pad) / Math.max(1, maxX - minX), (H - 2 * pad - 6) / Math.max(1, maxY - minY));
|
|
2850
|
+
const ox = W / 2 - (minX + maxX) / 2 * s, oy = H / 2 + 5 - (minY + maxY) / 2 * s;
|
|
2851
|
+
const path = currentId ? breadcrumbPath(currentId) : [];
|
|
2852
|
+
let out = "";
|
|
2853
|
+
all.forEach((n) => {
|
|
2854
|
+
if (!n.parent) return;
|
|
2855
|
+
const p = nodes.get(n.parent);
|
|
2856
|
+
out += '<line x1="' + (px(p) * s + ox) + '" y1="' + (py(p) * s + oy) + '" x2="' + (px(n) * s + ox) + '" y2="' + (py(n) * s + oy) + '" stroke="var(--panel-line)" stroke-width="1"/>';
|
|
2857
|
+
});
|
|
2858
|
+
all.forEach((n) => {
|
|
2859
|
+
const color = n.id === currentId ? "var(--accent)" : path.includes(n.id) ? "var(--accent-teal)" : "var(--node-border)";
|
|
2860
|
+
out += '<circle data-id="' + escapeHtml(n.id) + '" cx="' + (px(n) * s + ox) + '" cy="' + (py(n) * s + oy) + '" r="' + (n.id === currentId ? 4 : 3) + '" fill="' + color + '"><title>' + escapeHtml(n.title) + "</title></circle>";
|
|
2861
|
+
});
|
|
2862
|
+
out += '<rect id="mm-viewport" fill="none" stroke="var(--accent)" stroke-width="1" opacity="0.7"/>';
|
|
2863
|
+
mmSvg.innerHTML = out;
|
|
2864
|
+
mm = { s, ox, oy };
|
|
2865
|
+
updateMinimapViewport();
|
|
2866
|
+
}
|
|
2867
|
+
function updateMinimapViewport() {
|
|
2868
|
+
const rect = document.getElementById("mm-viewport");
|
|
2869
|
+
if (!rect || !mm) return;
|
|
2870
|
+
const ww = stage.clientWidth / cam.zoom, wh = stage.clientHeight / cam.zoom;
|
|
2871
|
+
rect.setAttribute("x", (cam.x - ww / 2) * mm.s + mm.ox);
|
|
2872
|
+
rect.setAttribute("y", (cam.y - wh / 2) * mm.s + mm.oy);
|
|
2873
|
+
rect.setAttribute("width", Math.max(2, ww * mm.s));
|
|
2874
|
+
rect.setAttribute("height", Math.max(2, wh * mm.s));
|
|
2875
|
+
}
|
|
2876
|
+
mmSvg.addEventListener("click", (e) => {
|
|
2877
|
+
const c = e.target.closest("circle");
|
|
2878
|
+
if (c && !rec.active) navigate(c.dataset.id);
|
|
2879
|
+
});
|
|
2880
|
+
var debounceTimer = null;
|
|
2881
|
+
function rebuild(instant) {
|
|
2882
|
+
parseDeck2(editor.value);
|
|
2883
|
+
if (currentId && !nodes.has(currentId)) currentId = null;
|
|
2884
|
+
build();
|
|
2885
|
+
if (currentId) navigate(currentId, instant);
|
|
2886
|
+
else if (order.length) navigate(order[0], instant);
|
|
2887
|
+
else {
|
|
2888
|
+
currentId = null;
|
|
2889
|
+
fitAll(true);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
editor.addEventListener("input", () => {
|
|
2893
|
+
if (view.kind !== "copy" && !forkToCopy()) return;
|
|
2894
|
+
copy.text = editor.value;
|
|
2895
|
+
updateDocState();
|
|
2896
|
+
clearTimeout(debounceTimer);
|
|
2897
|
+
debounceTimer = setTimeout(() => {
|
|
2898
|
+
saveCopy();
|
|
2899
|
+
rebuild(true);
|
|
2900
|
+
}, 300);
|
|
2901
|
+
});
|
|
2902
|
+
function setMode(mode, instant) {
|
|
2903
|
+
layoutMode = mode;
|
|
2904
|
+
save("slidetake:layout", mode);
|
|
2905
|
+
document.querySelectorAll("#layout-toggle .seg-btn").forEach((x) => x.classList.toggle("active", x.dataset.mode === mode));
|
|
2906
|
+
if (!nodes.size) return;
|
|
2907
|
+
if (!instant && !reduceMotion) {
|
|
2908
|
+
world.classList.add("morph");
|
|
2909
|
+
setTimeout(() => world.classList.remove("morph"), 700);
|
|
2910
|
+
}
|
|
2911
|
+
position();
|
|
2912
|
+
applyCamera();
|
|
2913
|
+
if (currentId) focusOn(currentId, instant);
|
|
2914
|
+
else fitAll(instant);
|
|
2915
|
+
}
|
|
2916
|
+
document.querySelectorAll("#layout-toggle .seg-btn").forEach((b) => {
|
|
2917
|
+
b.addEventListener("click", () => {
|
|
2918
|
+
if (b.dataset.mode !== layoutMode) setMode(b.dataset.mode);
|
|
2919
|
+
});
|
|
2920
|
+
});
|
|
2921
|
+
(function() {
|
|
2922
|
+
const ptrs = /* @__PURE__ */ new Map();
|
|
2923
|
+
let moved = 0, dragged = false, pinch = null;
|
|
2924
|
+
const pinchDist = () => {
|
|
2925
|
+
const [a, b] = [...ptrs.values()];
|
|
2926
|
+
return Math.hypot(a.x - b.x, a.y - b.y) || 1;
|
|
2927
|
+
};
|
|
2928
|
+
stage.addEventListener("pointerdown", (e) => {
|
|
2929
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
2930
|
+
if (rec.active || e.target.closest("a, pre, code, input, textarea")) return;
|
|
2931
|
+
ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
2932
|
+
moved = 0;
|
|
2933
|
+
dragged = false;
|
|
2934
|
+
if (ptrs.size === 2) pinch = { d: pinchDist(), zoom: cam.zoom };
|
|
2935
|
+
});
|
|
2936
|
+
window.addEventListener("pointermove", (e) => {
|
|
2937
|
+
const prev = ptrs.get(e.pointerId);
|
|
2938
|
+
if (!prev) return;
|
|
2939
|
+
const dx = e.clientX - prev.x, dy = e.clientY - prev.y;
|
|
2940
|
+
ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
2941
|
+
moved += Math.abs(dx) + Math.abs(dy);
|
|
2942
|
+
if (!dragged && moved > 5) {
|
|
2943
|
+
dragged = true;
|
|
2944
|
+
stopCamera();
|
|
2945
|
+
stage.classList.add("dragging");
|
|
2946
|
+
}
|
|
2947
|
+
if (!dragged) return;
|
|
2948
|
+
if (ptrs.size === 2 && pinch) {
|
|
2949
|
+
cam.zoom = clampZoom(pinch.zoom * pinchDist() / pinch.d);
|
|
2950
|
+
} else {
|
|
2951
|
+
cam.x -= dx / cam.zoom;
|
|
2952
|
+
cam.y -= dy / cam.zoom;
|
|
2953
|
+
}
|
|
2954
|
+
applyCamera();
|
|
2955
|
+
});
|
|
2956
|
+
const end = (e) => {
|
|
2957
|
+
ptrs.delete(e.pointerId);
|
|
2958
|
+
if (ptrs.size < 2) pinch = null;
|
|
2959
|
+
if (!ptrs.size) stage.classList.remove("dragging");
|
|
2960
|
+
};
|
|
2961
|
+
window.addEventListener("pointerup", end);
|
|
2962
|
+
window.addEventListener("pointercancel", end);
|
|
2963
|
+
stage.addEventListener("click", (e) => {
|
|
2964
|
+
if (dragged) {
|
|
2965
|
+
e.stopPropagation();
|
|
2966
|
+
e.preventDefault();
|
|
2967
|
+
dragged = false;
|
|
2968
|
+
}
|
|
2969
|
+
}, true);
|
|
2970
|
+
})();
|
|
2971
|
+
function clampZoom(z) {
|
|
2972
|
+
return Math.max(0.04, Math.min(5, z));
|
|
2973
|
+
}
|
|
2974
|
+
function setSlideFill(f) {
|
|
2975
|
+
slideFill = Math.round(Math.max(SLIDE_FILL_MIN, Math.min(SLIDE_FILL_MAX, f)) * 100) / 100;
|
|
2976
|
+
save("slidetake:slideSize", slideFill);
|
|
2977
|
+
if (currentId) focusOn(currentId);
|
|
2978
|
+
}
|
|
2979
|
+
function sizeStep(dir) {
|
|
2980
|
+
if (currentId) setSlideFill(slideFill + dir * 0.1);
|
|
2981
|
+
else zoomBy(dir > 0 ? 1.2 : 1 / 1.2);
|
|
2982
|
+
}
|
|
2983
|
+
function zoomBy(f, clientX, clientY) {
|
|
2984
|
+
stopCamera();
|
|
2985
|
+
const nz = clampZoom(cam.zoom * f);
|
|
2986
|
+
if (clientX !== void 0) {
|
|
2987
|
+
const r = stage.getBoundingClientRect();
|
|
2988
|
+
const px = clientX - r.left - r.width / 2, py = clientY - r.top - r.height / 2;
|
|
2989
|
+
cam.x += px / cam.zoom - px / nz;
|
|
2990
|
+
cam.y += py / cam.zoom - py / nz;
|
|
2991
|
+
}
|
|
2992
|
+
cam.zoom = nz;
|
|
2993
|
+
applyCamera();
|
|
2994
|
+
}
|
|
2995
|
+
stage.addEventListener("wheel", (e) => {
|
|
2996
|
+
e.preventDefault();
|
|
2997
|
+
if (rec.active) return;
|
|
2998
|
+
zoomBy(Math.exp(-e.deltaY * (e.ctrlKey ? 0.01 : 15e-4)), e.clientX, e.clientY);
|
|
2999
|
+
}, { passive: false });
|
|
3000
|
+
document.getElementById("nav-prev").onclick = () => step(-1);
|
|
3001
|
+
document.getElementById("nav-next").onclick = () => step(1);
|
|
3002
|
+
document.getElementById("btn-open").onclick = () => document.getElementById("file-input").click();
|
|
3003
|
+
document.getElementById("file-input").addEventListener("change", (e) => {
|
|
3004
|
+
const f = e.target.files[0];
|
|
3005
|
+
if (!f) return;
|
|
3006
|
+
const reader = new FileReader();
|
|
3007
|
+
reader.onload = () => {
|
|
3008
|
+
if (!confirmReplaceCopy("a copy of " + f.name)) return;
|
|
3009
|
+
copy = makeCopy(String(reader.result), { kind: "file", name: f.name }, { exported: true });
|
|
3010
|
+
saveCopy();
|
|
3011
|
+
deckBase = null;
|
|
3012
|
+
currentId = null;
|
|
3013
|
+
showCopy();
|
|
3014
|
+
};
|
|
3015
|
+
reader.readAsText(f);
|
|
3016
|
+
e.target.value = "";
|
|
3017
|
+
});
|
|
3018
|
+
document.getElementById("btn-save").onclick = () => {
|
|
3019
|
+
const blob = new Blob([editor.value], { type: "text/markdown" });
|
|
3020
|
+
const a = document.createElement("a");
|
|
3021
|
+
a.href = URL.createObjectURL(blob);
|
|
3022
|
+
a.download = (roots[0] ? slugify(nodes.get(roots[0]).title) : "deck") + ".md";
|
|
3023
|
+
a.click();
|
|
3024
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1e3);
|
|
3025
|
+
if (view.kind === "copy") {
|
|
3026
|
+
copy.exported = copy.text;
|
|
3027
|
+
saveCopy();
|
|
3028
|
+
updateDocState();
|
|
3029
|
+
}
|
|
3030
|
+
};
|
|
3031
|
+
document.getElementById("btn-reset").onclick = () => {
|
|
3032
|
+
if (view.kind !== "copy" || matchesOrigin(copy)) return;
|
|
3033
|
+
if (!confirm("Discard your edits and go back to " + originLabel(copy.origin) + " as it was?")) return;
|
|
3034
|
+
copy.text = copy.originText;
|
|
3035
|
+
saveCopy();
|
|
3036
|
+
editor.value = copy.text;
|
|
3037
|
+
currentId = null;
|
|
3038
|
+
rebuild(true);
|
|
3039
|
+
updateDocState();
|
|
3040
|
+
};
|
|
3041
|
+
function toggleEditor() {
|
|
3042
|
+
if (EMBED) return;
|
|
3043
|
+
editorPane.classList.toggle("collapsed");
|
|
3044
|
+
document.getElementById("btn-edit-toggle").classList.toggle("active", !editorPane.classList.contains("collapsed"));
|
|
3045
|
+
}
|
|
3046
|
+
document.getElementById("btn-edit-toggle").onclick = toggleEditor;
|
|
3047
|
+
var mainEl = document.querySelector("main");
|
|
3048
|
+
var editorResizer = document.getElementById("editor-resizer");
|
|
3049
|
+
var savedEditorW = parseFloat(load("slidetake:editorWidth"));
|
|
3050
|
+
if (savedEditorW) editorPane.style.setProperty("--editor-w", savedEditorW + "px");
|
|
3051
|
+
editorResizer.addEventListener("pointerdown", (e) => {
|
|
3052
|
+
e.preventDefault();
|
|
3053
|
+
editorResizer.setPointerCapture(e.pointerId);
|
|
3054
|
+
mainEl.classList.add("resizing");
|
|
3055
|
+
const right = mainEl.getBoundingClientRect().right;
|
|
3056
|
+
const move = (ev) => {
|
|
3057
|
+
const w = Math.round(Math.max(280, Math.min(window.innerWidth * 0.75, right - ev.clientX)));
|
|
3058
|
+
editorPane.style.setProperty("--editor-w", w + "px");
|
|
3059
|
+
};
|
|
3060
|
+
const up = () => {
|
|
3061
|
+
mainEl.classList.remove("resizing");
|
|
3062
|
+
editorResizer.removeEventListener("pointermove", move);
|
|
3063
|
+
save("slidetake:editorWidth", String(editorPane.getBoundingClientRect().width));
|
|
3064
|
+
};
|
|
3065
|
+
editorResizer.addEventListener("pointermove", move);
|
|
3066
|
+
editorResizer.addEventListener("pointerup", up, { once: true });
|
|
3067
|
+
});
|
|
3068
|
+
editorResizer.addEventListener("dblclick", () => {
|
|
3069
|
+
editorPane.style.removeProperty("--editor-w");
|
|
3070
|
+
try {
|
|
3071
|
+
localStorage.removeItem("slidetake:editorWidth");
|
|
3072
|
+
} catch (e) {
|
|
3073
|
+
}
|
|
3074
|
+
});
|
|
3075
|
+
document.getElementById("btn-mode").onclick = toggleMode;
|
|
3076
|
+
function setPresent(on) {
|
|
3077
|
+
presenting = on;
|
|
3078
|
+
document.body.classList.toggle("presenting", on);
|
|
3079
|
+
markActive();
|
|
3080
|
+
const de = document.documentElement;
|
|
3081
|
+
if (on && de.requestFullscreen && !document.fullscreenElement) de.requestFullscreen().catch(() => {
|
|
3082
|
+
});
|
|
3083
|
+
if (!on && document.fullscreenElement && document.exitFullscreen) document.exitFullscreen().catch(() => {
|
|
3084
|
+
});
|
|
3085
|
+
if (on && !currentId && order.length) navigate(order[0]);
|
|
3086
|
+
const usesCamera = deck.camera || [...nodes.values()].some((n) => n.camera);
|
|
3087
|
+
if (on && usesCamera && !cameraStream && !cameraOff) startWebcam();
|
|
3088
|
+
if (on) scheduleAutoslide(nodes.get(currentId));
|
|
3089
|
+
else clearTimeout(autoTimer);
|
|
3090
|
+
if (on) startTalkClock();
|
|
3091
|
+
else stopTalkClock();
|
|
3092
|
+
updateProgress();
|
|
3093
|
+
}
|
|
3094
|
+
document.getElementById("btn-present").onclick = () => setPresent(!presenting);
|
|
3095
|
+
var OBS_URL = "https://cdn.jsdelivr.net/npm/obs-websocket-js@5.0.5/dist/obs-ws.min.js";
|
|
3096
|
+
var NEXT_KEYS = ["ArrowRight", "PageDown", " ", "ArrowDown", "Enter"];
|
|
3097
|
+
var BACK_KEYS = ["ArrowLeft", "PageUp", "ArrowUp", "r", "R"];
|
|
3098
|
+
var PAUSE_KEYS = ["b", "B", "."];
|
|
3099
|
+
var recDialog = document.getElementById("rec-dialog");
|
|
3100
|
+
var reviewDialog = document.getElementById("review");
|
|
3101
|
+
var countdownEl = document.getElementById("rec-countdown");
|
|
3102
|
+
var pausedEl = document.getElementById("rec-paused");
|
|
3103
|
+
var obsHost = document.getElementById("obs-host");
|
|
3104
|
+
var obsPort = document.getElementById("obs-port");
|
|
3105
|
+
var obsPass = document.getElementById("obs-pass");
|
|
3106
|
+
var obsRemember = document.getElementById("obs-remember");
|
|
3107
|
+
var obsStatus = document.getElementById("obs-status");
|
|
3108
|
+
var recStartBtn = document.getElementById("rec-start");
|
|
3109
|
+
var obs = null;
|
|
3110
|
+
var obsConnected = false;
|
|
3111
|
+
var recStartResolve = null;
|
|
3112
|
+
var obsFps = null;
|
|
3113
|
+
var rec = { active: false, withObs: false, counting: false, paused: false, finishing: false, t0: 0, pauseAt: 0, pausedMs: 0, events: [], outputPath: null };
|
|
3114
|
+
var wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
3115
|
+
var nextFrame = () => Promise.race([new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))), wait(100)]);
|
|
3116
|
+
function recNow() {
|
|
3117
|
+
return (rec.paused ? rec.pauseAt : performance.now()) - rec.t0 - rec.pausedMs;
|
|
3118
|
+
}
|
|
3119
|
+
function openModal(m) {
|
|
3120
|
+
m.classList.add("open");
|
|
3121
|
+
}
|
|
3122
|
+
function closeModals() {
|
|
3123
|
+
document.querySelectorAll(".modal.open").forEach((m) => m.classList.remove("open"));
|
|
3124
|
+
}
|
|
3125
|
+
document.querySelectorAll(".modal").forEach((m) => {
|
|
3126
|
+
m.addEventListener("click", (e) => {
|
|
3127
|
+
if (e.target === m || e.target.closest("[data-close]")) m.classList.remove("open");
|
|
3128
|
+
});
|
|
3129
|
+
});
|
|
3130
|
+
document.querySelectorAll("[data-copy]").forEach((b) => b.addEventListener("click", () => {
|
|
3131
|
+
const ta = document.getElementById(b.dataset.copy);
|
|
3132
|
+
ta.select();
|
|
3133
|
+
(navigator.clipboard ? navigator.clipboard.writeText(ta.value) : Promise.reject()).catch(() => document.execCommand("copy"));
|
|
3134
|
+
b.textContent = "Copied";
|
|
3135
|
+
setTimeout(() => {
|
|
3136
|
+
b.textContent = "Copy";
|
|
3137
|
+
}, 1500);
|
|
3138
|
+
}));
|
|
3139
|
+
function loadObsSettings() {
|
|
3140
|
+
const fromUrl = new URLSearchParams(location.search).get("obs");
|
|
3141
|
+
if (fromUrl) {
|
|
3142
|
+
const [host, port, ...rest] = fromUrl.split(":");
|
|
3143
|
+
obsHost.value = host || "localhost";
|
|
3144
|
+
obsPort.value = port || "4455";
|
|
3145
|
+
obsPass.value = rest.join(":");
|
|
3146
|
+
return true;
|
|
3147
|
+
}
|
|
3148
|
+
try {
|
|
3149
|
+
const saved = JSON.parse(load("slidetake:obs") || "null");
|
|
3150
|
+
if (saved) {
|
|
3151
|
+
obsHost.value = saved.host || "localhost";
|
|
3152
|
+
obsPort.value = saved.port || "4455";
|
|
3153
|
+
obsPass.value = saved.password || "";
|
|
3154
|
+
obsRemember.checked = true;
|
|
3155
|
+
}
|
|
3156
|
+
} catch (e) {
|
|
3157
|
+
}
|
|
3158
|
+
return false;
|
|
3159
|
+
}
|
|
3160
|
+
function saveObsSettings() {
|
|
3161
|
+
if (obsRemember.checked) save("slidetake:obs", JSON.stringify({ host: obsHost.value.trim(), port: obsPort.value.trim(), password: obsPass.value }));
|
|
3162
|
+
else {
|
|
3163
|
+
try {
|
|
3164
|
+
localStorage.removeItem("slidetake:obs");
|
|
3165
|
+
} catch (e) {
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
function setObsStatus(text, kind) {
|
|
3170
|
+
obsStatus.textContent = text;
|
|
3171
|
+
obsStatus.className = kind || "";
|
|
3172
|
+
}
|
|
3173
|
+
var isLoopback = (host) => /^(localhost|127(\.\d+){3}|\[?::1\]?)$/i.test(host);
|
|
3174
|
+
function obsBlockedHere(host) {
|
|
3175
|
+
return location.protocol === "https:" && !isLoopback(host);
|
|
3176
|
+
}
|
|
3177
|
+
var OBS_HTTPS_HELP = "This page is served over https, and browsers block it from reaching OBS on another computer (OBS only offers plain ws://). Run OBS on this computer and use localhost, or open Slidetake from a local copy: download dist/index.html from github.com/slidetake/slidetake and serve it with python3 -m http.server.";
|
|
3178
|
+
async function connectObs() {
|
|
3179
|
+
const host = obsHost.value.trim() || "localhost";
|
|
3180
|
+
const url = "ws://" + host + ":" + (obsPort.value.trim() || "4455");
|
|
3181
|
+
if (obsBlockedHere(host)) {
|
|
3182
|
+
obsConnected = false;
|
|
3183
|
+
recStartBtn.disabled = true;
|
|
3184
|
+
setObsStatus(OBS_HTTPS_HELP, "err");
|
|
3185
|
+
return;
|
|
3186
|
+
}
|
|
3187
|
+
setObsStatus("Connecting to " + url + "\u2026");
|
|
3188
|
+
try {
|
|
3189
|
+
await loadScript(OBS_URL);
|
|
3190
|
+
const Ctor = window.OBSWebSocket && (window.OBSWebSocket.default || window.OBSWebSocket);
|
|
3191
|
+
if (obs) {
|
|
3192
|
+
try {
|
|
3193
|
+
await obs.disconnect();
|
|
3194
|
+
} catch (e) {
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
obs = new Ctor();
|
|
3198
|
+
obs.on("ConnectionClosed", () => {
|
|
3199
|
+
obsConnected = false;
|
|
3200
|
+
setObsStatus("Disconnected from OBS", "err");
|
|
3201
|
+
recStartBtn.disabled = true;
|
|
3202
|
+
});
|
|
3203
|
+
obs.on("RecordStateChanged", (e) => {
|
|
3204
|
+
if (e.outputState === "OBS_WEBSOCKET_OUTPUT_STARTED" && recStartResolve) {
|
|
3205
|
+
recStartResolve();
|
|
3206
|
+
recStartResolve = null;
|
|
3207
|
+
}
|
|
3208
|
+
if (e.outputState === "OBS_WEBSOCKET_OUTPUT_STOPPED" && rec.active && rec.withObs && !rec.finishing) finishTake("Stopped in OBS");
|
|
3209
|
+
});
|
|
3210
|
+
const info = await obs.connect(url, obsPass.value || void 0);
|
|
3211
|
+
obsConnected = true;
|
|
3212
|
+
try {
|
|
3213
|
+
const v = await obs.call("GetVideoSettings");
|
|
3214
|
+
if (v && v.fpsNumerator && v.fpsDenominator) obsFps = v.fpsNumerator / v.fpsDenominator;
|
|
3215
|
+
} catch (e) {
|
|
3216
|
+
}
|
|
3217
|
+
setObsStatus("Connected" + (info && info.obsWebSocketVersion ? " \xB7 OBS WebSocket " + info.obsWebSocketVersion : ""), "ok");
|
|
3218
|
+
saveObsSettings();
|
|
3219
|
+
} catch (e) {
|
|
3220
|
+
obsConnected = false;
|
|
3221
|
+
setObsStatus("Could not connect (" + (e && e.message || e) + "). Is OBS running with its WebSocket server on, and is the password right?", "err");
|
|
3222
|
+
}
|
|
3223
|
+
recStartBtn.disabled = !obsConnected;
|
|
3224
|
+
}
|
|
3225
|
+
document.getElementById("obs-connect").onclick = connectObs;
|
|
3226
|
+
obsRemember.addEventListener("change", saveObsSettings);
|
|
3227
|
+
function showScreenAdvice() {
|
|
3228
|
+
const el = document.getElementById("rec-screen");
|
|
3229
|
+
const w = screen.width, h = screen.height;
|
|
3230
|
+
if (Math.abs(w / h - 16 / 9) < 0.02) {
|
|
3231
|
+
el.innerHTML = '<span class="ok">This screen is 16:9 (' + w + "\xD7" + h + "), right for YouTube.</span>";
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
const shapes = [["16:10", 1.6], ["3:2", 1.5], ["4:3", 4 / 3], ["21:9", 21 / 9], ["16:9", 16 / 9]];
|
|
3235
|
+
const [name, r] = shapes.reduce((a, b) => Math.abs(b[1] - w / h) < Math.abs(a[1] - w / h) ? b : a);
|
|
3236
|
+
const shape = Math.abs(r - w / h) < 5e-3 ? name : "about " + name;
|
|
3237
|
+
el.innerHTML = '<span class="warn">This screen is ' + shape + " (" + w + "\xD7" + h + "), not 16:9, so the video will have bars or be cropped. Move this window to a 16:9 screen, physical or virtual (say 1920\xD71080), then press F there.</span>";
|
|
3238
|
+
}
|
|
3239
|
+
function openRecordDialog() {
|
|
3240
|
+
if (!RECORDING_UI) return;
|
|
3241
|
+
const total = order.reduce((a, id) => a + slideSteps(nodes.get(id)).length, 0);
|
|
3242
|
+
const usesCamera = deck.camera || [...nodes.values()].some((n) => n.camera);
|
|
3243
|
+
document.getElementById("rec-deck-info").innerHTML = escapeHtml(deck.title || (roots[0] ? nodes.get(roots[0]).title : "This deck")) + " \xB7 " + order.length + " slides \xB7 " + total + " presses" + (usesCamera && cameraOff ? '<br><span class="warn">The camera is off. Press C first if this take should include your webcam.</span>' : "");
|
|
3244
|
+
recStartBtn.disabled = !obsConnected;
|
|
3245
|
+
renderSessionList();
|
|
3246
|
+
showScreenAdvice();
|
|
3247
|
+
openModal(recDialog);
|
|
3248
|
+
}
|
|
3249
|
+
document.getElementById("btn-record").onclick = openRecordDialog;
|
|
3250
|
+
recStartBtn.onclick = () => startTake(true);
|
|
3251
|
+
document.getElementById("rec-rehearse").onclick = () => startTake(false);
|
|
3252
|
+
async function startTake(withObs) {
|
|
3253
|
+
if (rec.active || !order.length) return;
|
|
3254
|
+
closeModals();
|
|
3255
|
+
Object.assign(rec, { active: true, withObs, counting: true, paused: false, finishing: false, t0: 0, pausedMs: 0, events: [], outputPath: null });
|
|
3256
|
+
document.body.classList.add("recording");
|
|
3257
|
+
hidePipMsg();
|
|
3258
|
+
const lay = document.getElementById("rec-layout").value;
|
|
3259
|
+
if (lay !== "current" && lay !== layoutMode) setMode(lay, true);
|
|
3260
|
+
if (!presenting) setPresent(true);
|
|
3261
|
+
if (currentId === order[0]) {
|
|
3262
|
+
stepPos = 0;
|
|
3263
|
+
camManual = null;
|
|
3264
|
+
camCycle = -1;
|
|
3265
|
+
}
|
|
3266
|
+
navigate(order[0], true);
|
|
3267
|
+
for (let i = 3; i > 0; i--) {
|
|
3268
|
+
countdownEl.querySelector(".num").textContent = i;
|
|
3269
|
+
countdownEl.classList.add("show");
|
|
3270
|
+
await wait(1e3);
|
|
3271
|
+
if (!rec.active) return;
|
|
3272
|
+
}
|
|
3273
|
+
countdownEl.classList.remove("show");
|
|
3274
|
+
await nextFrame();
|
|
3275
|
+
if (withObs) {
|
|
3276
|
+
const started = new Promise((r) => {
|
|
3277
|
+
recStartResolve = r;
|
|
3278
|
+
setTimeout(() => {
|
|
3279
|
+
if (recStartResolve) {
|
|
3280
|
+
recStartResolve();
|
|
3281
|
+
recStartResolve = null;
|
|
3282
|
+
}
|
|
3283
|
+
}, 2500);
|
|
3284
|
+
});
|
|
3285
|
+
try {
|
|
3286
|
+
await obs.call("StartRecord");
|
|
3287
|
+
} catch (e) {
|
|
3288
|
+
abortTake("OBS could not start recording: " + (e && e.message || e));
|
|
3289
|
+
return;
|
|
3290
|
+
}
|
|
3291
|
+
await started;
|
|
3292
|
+
if (!rec.active) return;
|
|
3293
|
+
}
|
|
3294
|
+
rec.counting = false;
|
|
3295
|
+
rec.t0 = performance.now();
|
|
3296
|
+
const first = nodes.get(currentId);
|
|
3297
|
+
resetEntrances(first);
|
|
3298
|
+
applyStepState(true);
|
|
3299
|
+
logTake("slide", currentId);
|
|
3300
|
+
}
|
|
3301
|
+
function abortTake(message) {
|
|
3302
|
+
rec.active = false;
|
|
3303
|
+
rec.counting = false;
|
|
3304
|
+
countdownEl.classList.remove("show");
|
|
3305
|
+
document.body.classList.remove("recording");
|
|
3306
|
+
if (presenting) setPresent(false);
|
|
3307
|
+
showPipMsg(message);
|
|
3308
|
+
}
|
|
3309
|
+
function logTake(kind, id) {
|
|
3310
|
+
if (!rec.active || !rec.t0 || rec.finishing) return;
|
|
3311
|
+
const n = nodes.get(id);
|
|
3312
|
+
const ev = { id, title: n ? n.title : id, retake: kind === "retake", t: Math.round(recNow()), obsT: null };
|
|
3313
|
+
rec.events.push(ev);
|
|
3314
|
+
if (rec.withObs && obsConnected) {
|
|
3315
|
+
obs.call("GetRecordStatus").then((r) => {
|
|
3316
|
+
if (r && typeof r.outputDuration === "number") ev.obsT = r.outputDuration;
|
|
3317
|
+
}).catch(() => {
|
|
3318
|
+
});
|
|
3319
|
+
if (n) obs.call("CreateRecordChapter", { chapterName: (ev.retake ? "RETAKE \xB7 " : "") + n.title }).catch(() => {
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
function takeKey(e) {
|
|
3324
|
+
const k = e.key;
|
|
3325
|
+
const handled = NEXT_KEYS.includes(k) || BACK_KEYS.includes(k) || PAUSE_KEYS.includes(k) || k === "Escape";
|
|
3326
|
+
if (handled) e.preventDefault();
|
|
3327
|
+
if (k === "Escape") {
|
|
3328
|
+
if (rec.counting) abortTake("Take cancelled");
|
|
3329
|
+
else finishTake("Stopped early");
|
|
3330
|
+
return;
|
|
3331
|
+
}
|
|
3332
|
+
if (rec.counting || rec.finishing) return;
|
|
3333
|
+
if (PAUSE_KEYS.includes(k)) {
|
|
3334
|
+
togglePause();
|
|
3335
|
+
return;
|
|
3336
|
+
}
|
|
3337
|
+
if (rec.paused) return;
|
|
3338
|
+
if (NEXT_KEYS.includes(k)) takeForward();
|
|
3339
|
+
else if (BACK_KEYS.includes(k)) retake();
|
|
3340
|
+
}
|
|
3341
|
+
function takeForward() {
|
|
3342
|
+
const steps = slideSteps(nodes.get(currentId));
|
|
3343
|
+
const lastStep = Math.min(stepPos, steps.length - 1) >= steps.length - 1;
|
|
3344
|
+
if (lastStep && order.indexOf(currentId) === order.length - 1) finishTake();
|
|
3345
|
+
else step(1);
|
|
3346
|
+
}
|
|
3347
|
+
function retake() {
|
|
3348
|
+
const n = nodes.get(currentId);
|
|
3349
|
+
if (!n) return;
|
|
3350
|
+
logTake("retake", currentId);
|
|
3351
|
+
stepPos = 0;
|
|
3352
|
+
camManual = null;
|
|
3353
|
+
camCycle = -1;
|
|
3354
|
+
resetEntrances(n);
|
|
3355
|
+
applyStepState(true);
|
|
3356
|
+
if (!cameraStream && !pipEl.hidden && pipState.used) startWebcam();
|
|
3357
|
+
else refocus();
|
|
3358
|
+
updateActivePath();
|
|
3359
|
+
}
|
|
3360
|
+
async function togglePause() {
|
|
3361
|
+
if (!rec.t0) return;
|
|
3362
|
+
if (!rec.paused) {
|
|
3363
|
+
rec.paused = true;
|
|
3364
|
+
rec.pauseAt = performance.now();
|
|
3365
|
+
clearTimeout(autoTimer);
|
|
3366
|
+
if (rec.withObs) await obs.call("PauseRecord").catch(() => {
|
|
3367
|
+
});
|
|
3368
|
+
pausedEl.classList.add("show");
|
|
3369
|
+
} else {
|
|
3370
|
+
pausedEl.classList.remove("show");
|
|
3371
|
+
await nextFrame();
|
|
3372
|
+
if (rec.withObs) await obs.call("ResumeRecord").catch(() => {
|
|
3373
|
+
});
|
|
3374
|
+
rec.pausedMs += performance.now() - rec.pauseAt;
|
|
3375
|
+
rec.paused = false;
|
|
3376
|
+
scheduleAutoslide(nodes.get(currentId));
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
async function finishTake(reason) {
|
|
3380
|
+
if (!rec.active || rec.finishing) return;
|
|
3381
|
+
if (rec.counting) {
|
|
3382
|
+
abortTake("Take cancelled");
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
rec.finishing = true;
|
|
3386
|
+
clearTimeout(autoTimer);
|
|
3387
|
+
if (rec.paused) {
|
|
3388
|
+
rec.pausedMs += performance.now() - rec.pauseAt;
|
|
3389
|
+
rec.paused = false;
|
|
3390
|
+
pausedEl.classList.remove("show");
|
|
3391
|
+
}
|
|
3392
|
+
let total = Math.round(recNow()), totalObs = null;
|
|
3393
|
+
if (rec.withObs) {
|
|
3394
|
+
await wait(1200);
|
|
3395
|
+
total = Math.round(recNow());
|
|
3396
|
+
try {
|
|
3397
|
+
const st = await obs.call("GetRecordStatus");
|
|
3398
|
+
if (st && typeof st.outputDuration === "number") totalObs = st.outputDuration;
|
|
3399
|
+
} catch (e) {
|
|
3400
|
+
}
|
|
3401
|
+
try {
|
|
3402
|
+
const r = await obs.call("StopRecord");
|
|
3403
|
+
rec.outputPath = r && r.outputPath;
|
|
3404
|
+
} catch (e) {
|
|
3405
|
+
reason = (reason ? reason + ". " : "") + "OBS did not confirm the stop (" + (e && e.message || e) + ")";
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
rec.active = false;
|
|
3409
|
+
rec.finishing = false;
|
|
3410
|
+
document.body.classList.remove("recording");
|
|
3411
|
+
if (presenting) setPresent(false);
|
|
3412
|
+
const session = {
|
|
3413
|
+
key: sessionKey(),
|
|
3414
|
+
deckTitle: deck.title || nodes.get(order[0]).title,
|
|
3415
|
+
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3416
|
+
withObs: rec.withObs,
|
|
3417
|
+
outputPath: rec.outputPath,
|
|
3418
|
+
reason: reason || "",
|
|
3419
|
+
total,
|
|
3420
|
+
totalObs,
|
|
3421
|
+
fps: obsFps,
|
|
3422
|
+
events: rec.events.map((e) => ({ id: e.id, title: e.title, retake: e.retake, t: e.t, obsT: e.obsT })),
|
|
3423
|
+
picks: {}
|
|
3424
|
+
};
|
|
3425
|
+
saveSession(session);
|
|
3426
|
+
openReview(session);
|
|
3427
|
+
}
|
|
3428
|
+
function sessionKey() {
|
|
3429
|
+
return slugify(deck.title || (order[0] ? nodes.get(order[0]).title : "deck"));
|
|
3430
|
+
}
|
|
3431
|
+
function loadSessions() {
|
|
3432
|
+
try {
|
|
3433
|
+
return JSON.parse(load("slidetake:sessions") || "[]");
|
|
3434
|
+
} catch (e) {
|
|
3435
|
+
return [];
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
function saveSession(sess) {
|
|
3439
|
+
const all = loadSessions().filter((x) => x.date !== sess.date);
|
|
3440
|
+
all.unshift(sess);
|
|
3441
|
+
save("slidetake:sessions", JSON.stringify(all.slice(0, 12)));
|
|
3442
|
+
}
|
|
3443
|
+
function renderSessionList() {
|
|
3444
|
+
const box = document.getElementById("rec-sessions");
|
|
3445
|
+
const mine = loadSessions().filter((x) => x.key === sessionKey());
|
|
3446
|
+
box.innerHTML = mine.length ? "<h3>Earlier takes of this deck</h3>" + mine.map((x, i) => '<div class="row"><button class="btn small" data-session="' + i + '">Review</button><span>' + escapeHtml(new Date(x.date).toLocaleString()) + " \xB7 " + fmtTime(x.totalObs ?? x.total) + (x.withObs ? "" : " \xB7 rehearsal") + (x.outputPath ? " \xB7 " + escapeHtml(baseName(x.outputPath)) : "") + "</span></div>").join("") : "";
|
|
3447
|
+
box.querySelectorAll("[data-session]").forEach((b) => b.onclick = () => {
|
|
3448
|
+
closeModals();
|
|
3449
|
+
openReview(mine[+b.dataset.session]);
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
function sectionOf(id) {
|
|
3453
|
+
const path = nodes.has(id) ? breadcrumbPath(id) : [id];
|
|
3454
|
+
return path[Math.min(1, path.length - 1)];
|
|
3455
|
+
}
|
|
3456
|
+
var reviewFileName = "";
|
|
3457
|
+
function sectionInfo(id, fallbackTitle) {
|
|
3458
|
+
const sec = sectionOf(id);
|
|
3459
|
+
return { sec, title: nodes.has(sec) ? nodes.get(sec).title : fallbackTitle };
|
|
3460
|
+
}
|
|
3461
|
+
var finalChapters2 = (sess) => finalChapters(sess, sectionInfo);
|
|
3462
|
+
var ffmpegScript2 = (sess, mode) => ffmpegScript(sess, mode, {
|
|
3463
|
+
input: sess.outputPath || reviewFileName || "recording.mov",
|
|
3464
|
+
outputName: sessionKey() + "-final.mp4",
|
|
3465
|
+
sectionOf: sectionInfo
|
|
3466
|
+
});
|
|
3467
|
+
function deckTags() {
|
|
3468
|
+
const all = Object.keys(deck).filter((k) => k === "tags" || /_tags$/.test(k)).flatMap((k) => [].concat(deck[k])).filter((t) => typeof t === "string");
|
|
3469
|
+
return [...new Set(all.map((t) => t.trim()).filter(Boolean))];
|
|
3470
|
+
}
|
|
3471
|
+
function relatedLinks() {
|
|
3472
|
+
return [].concat(deck.related || []).map((x) => {
|
|
3473
|
+
const md = String(x).match(/^\[([^\]]+)\]\(([^)]+)\)$/), pipe2 = String(x).split("|");
|
|
3474
|
+
if (md) return md[1] + ": " + md[2];
|
|
3475
|
+
if (pipe2.length === 2) return pipe2[0].trim() + ": " + pipe2[1].trim();
|
|
3476
|
+
return String(x);
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
3479
|
+
function deckLink() {
|
|
3480
|
+
if (deck.permalink || deck.url) return deck.permalink || deck.url;
|
|
3481
|
+
const site = deck.site || load("slidetake:site");
|
|
3482
|
+
if (!site || !deckBase) return "";
|
|
3483
|
+
try {
|
|
3484
|
+
const path = new URL(deckBase).pathname.replace(/\/index\.md$/i, "/").replace(/\.md$/i, "/");
|
|
3485
|
+
return new URL(path, site).href;
|
|
3486
|
+
} catch (e) {
|
|
3487
|
+
return "";
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
function describe(sess) {
|
|
3491
|
+
const ch = finalChapters2(sess), link = document.getElementById("rv-link").value.trim(), related = relatedLinks(), tags = deckTags();
|
|
3492
|
+
const parts = [];
|
|
3493
|
+
if (deck.summary) parts.push(deck.summary);
|
|
3494
|
+
if (link) parts.push("\u{1F4D1} Slides: " + link);
|
|
3495
|
+
if (ch.lines.length >= 3) parts.push("Chapters\n" + ch.lines.join("\n"));
|
|
3496
|
+
if (related.length) parts.push("Related\n" + related.map((r) => "\u2022 " + r).join("\n"));
|
|
3497
|
+
if (tags.length) parts.push(tags.slice(0, 3).map((t) => "#" + t.replace(/[^\p{L}\p{N}]+/gu, "")).join(" "));
|
|
3498
|
+
document.getElementById("rv-yt-desc").value = parts.join("\n\n");
|
|
3499
|
+
document.getElementById("rv-chapters-note").textContent = (ch.dropped ? ch.dropped + " section" + (ch.dropped > 1 ? "s were" : " was") + " under 10 seconds and folded into the chapter before, as YouTube requires. " : "") + (ch.lines.length < 3 ? "YouTube needs at least three chapters, so none are listed. " : "") + "Final length " + fmtTime(ch.length) + ".";
|
|
3500
|
+
}
|
|
3501
|
+
var reviewing = null;
|
|
3502
|
+
var playlist = null;
|
|
3503
|
+
var rvVideo = document.getElementById("rv-video");
|
|
3504
|
+
var rvNow = document.getElementById("rv-now");
|
|
3505
|
+
function openReview(sess) {
|
|
3506
|
+
reviewing = sess;
|
|
3507
|
+
playlist = null;
|
|
3508
|
+
const slides = takesOf(sess), retakes = sess.events.filter((e) => e.retake).length;
|
|
3509
|
+
document.getElementById("rv-title").textContent = (sess.withObs ? "Review the take \xB7 " : "Rehearsal \xB7 ") + sess.deckTitle;
|
|
3510
|
+
document.getElementById("rv-info").textContent = [
|
|
3511
|
+
sess.reason,
|
|
3512
|
+
new Date(sess.date).toLocaleString(),
|
|
3513
|
+
(sess.withObs ? "recorded " : "ran ") + fmtTime(sess.totalObs ?? sess.total),
|
|
3514
|
+
slides.size + " slides",
|
|
3515
|
+
retakes ? retakes + " retake" + (retakes > 1 ? "s" : "") : "no retakes",
|
|
3516
|
+
sess.outputPath ? "saved to " + sess.outputPath : sess.withObs ? "" : "nothing was recorded"
|
|
3517
|
+
].filter(Boolean).join(" \xB7 ");
|
|
3518
|
+
document.getElementById("rv-file").textContent = sess.outputPath ? " (" + baseName(sess.outputPath) + ")" : "";
|
|
3519
|
+
document.getElementById("rv-yt-title").value = sess.deckTitle;
|
|
3520
|
+
const fps = sessionFps(sess);
|
|
3521
|
+
fpsSel.value = [...fpsSel.options].reduce((a, o) => Math.abs(o.value - fps) < Math.abs(a.value - fps) ? o : a).value;
|
|
3522
|
+
document.getElementById("rv-yt-tags").value = deckTags().join(", ");
|
|
3523
|
+
document.getElementById("rv-link").value = deckLink();
|
|
3524
|
+
if (rvVideo.src && reviewFileName !== baseName(sess.outputPath) && sess.outputPath) {
|
|
3525
|
+
rvVideo.removeAttribute("src");
|
|
3526
|
+
rvVideo.load();
|
|
3527
|
+
reviewFileName = "";
|
|
3528
|
+
}
|
|
3529
|
+
document.getElementById("rv-novideo").hidden = !!rvVideo.src;
|
|
3530
|
+
renderReview();
|
|
3531
|
+
openModal(reviewDialog);
|
|
3532
|
+
autoLoadRecording(sess);
|
|
3533
|
+
}
|
|
3534
|
+
function renderReview() {
|
|
3535
|
+
const sess = reviewing, list = document.getElementById("rv-list");
|
|
3536
|
+
let lastSec = null;
|
|
3537
|
+
list.innerHTML = [...takesOf(sess).values()].map((slide) => {
|
|
3538
|
+
const pick = sess.picks[slide.id] ?? slide.takes.length, sec = sectionOf(slide.id);
|
|
3539
|
+
const isSec = sec !== lastSec;
|
|
3540
|
+
lastSec = sec;
|
|
3541
|
+
const chips = slide.takes.map((t) => '<button class="rv-chip' + (pick === t.no ? " on" : "") + '" data-id="' + escapeHtml(slide.id) + '" data-take="' + t.no + '">' + (slide.takes.length > 1 ? "Take " + t.no + " \xB7 " : "") + fmtTime(t.end - t.start) + "</button>").join("") + '<button class="rv-chip skip' + (pick === 0 ? " on" : "") + '" data-id="' + escapeHtml(slide.id) + '" data-take="0">Leave out</button>';
|
|
3542
|
+
return '<div class="rv-row' + (isSec ? " sec" : "") + '"><div class="t">' + escapeHtml(slide.title) + "<small>" + fmtTime(slide.takes[0].start) + '</small></div><div class="rv-chips">' + chips + "</div></div>";
|
|
3543
|
+
}).join("");
|
|
3544
|
+
list.querySelectorAll(".rv-chip").forEach((b) => b.onclick = () => {
|
|
3545
|
+
sess.picks[b.dataset.id] = +b.dataset.take;
|
|
3546
|
+
saveSession(sess);
|
|
3547
|
+
renderReview();
|
|
3548
|
+
const slide = takesOf(sess).get(b.dataset.id), t = slide && slide.takes[+b.dataset.take - 1];
|
|
3549
|
+
if (t) playRange([{ start: t.start, end: t.end, title: slide.title + (slide.takes.length > 1 ? " \xB7 take " + t.no : "") }]);
|
|
3550
|
+
});
|
|
3551
|
+
document.getElementById("rv-ffmpeg").value = ffmpegScript2(sess, document.getElementById("rv-mode").value);
|
|
3552
|
+
describe(sess);
|
|
3553
|
+
}
|
|
3554
|
+
document.getElementById("rv-mode").onchange = () => renderReview();
|
|
3555
|
+
var fpsSel = document.getElementById("rv-fps");
|
|
3556
|
+
fpsSel.onchange = () => {
|
|
3557
|
+
if (!reviewing) return;
|
|
3558
|
+
reviewing.fps = parseFloat(fpsSel.value);
|
|
3559
|
+
saveSession(reviewing);
|
|
3560
|
+
renderReview();
|
|
3561
|
+
};
|
|
3562
|
+
document.getElementById("rv-link").addEventListener("input", (e) => {
|
|
3563
|
+
try {
|
|
3564
|
+
save("slidetake:site", new URL(e.target.value.trim()).origin);
|
|
3565
|
+
} catch (err) {
|
|
3566
|
+
}
|
|
3567
|
+
if (reviewing) describe(reviewing);
|
|
3568
|
+
});
|
|
3569
|
+
var pendingPlay = null;
|
|
3570
|
+
function playRange(ranges) {
|
|
3571
|
+
if (!rvVideo.src) {
|
|
3572
|
+
pendingPlay = ranges;
|
|
3573
|
+
rvNow.textContent = rvOpening ? "Opening the recording\u2026 it plays when ready." : "Open the recording to preview.";
|
|
3574
|
+
return;
|
|
3575
|
+
}
|
|
3576
|
+
pendingPlay = null;
|
|
3577
|
+
playlist = { ranges, i: 0 };
|
|
3578
|
+
rvNow.textContent = "\u25B6 " + ranges[0].title;
|
|
3579
|
+
const go = () => {
|
|
3580
|
+
rvVideo.currentTime = ranges[0].start / 1e3;
|
|
3581
|
+
rvVideo.play().catch((e) => {
|
|
3582
|
+
if (e && e.name !== "AbortError") rvNow.textContent = "Could not play: " + e.message;
|
|
3583
|
+
});
|
|
3584
|
+
};
|
|
3585
|
+
if (rvVideo.readyState >= 1) go();
|
|
3586
|
+
else rvVideo.addEventListener("loadedmetadata", go, { once: true });
|
|
3587
|
+
}
|
|
3588
|
+
rvVideo.addEventListener("timeupdate", () => {
|
|
3589
|
+
if (!playlist) return;
|
|
3590
|
+
const r = playlist.ranges[playlist.i];
|
|
3591
|
+
if (rvVideo.currentTime * 1e3 < r.end) return;
|
|
3592
|
+
playlist.i++;
|
|
3593
|
+
if (playlist.i >= playlist.ranges.length) {
|
|
3594
|
+
rvVideo.pause();
|
|
3595
|
+
playlist = null;
|
|
3596
|
+
rvNow.textContent = "";
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3599
|
+
const next = playlist.ranges[playlist.i];
|
|
3600
|
+
rvVideo.currentTime = next.start / 1e3;
|
|
3601
|
+
rvNow.textContent = "\u25B6 " + next.title;
|
|
3602
|
+
});
|
|
3603
|
+
document.getElementById("rv-play-final").onclick = () => {
|
|
3604
|
+
if (reviewing) playRange(pickedRanges(reviewing).map((r) => ({ start: r.start, end: r.end, title: r.title })));
|
|
3605
|
+
};
|
|
3606
|
+
function idb(name) {
|
|
3607
|
+
return new Promise((res, rej) => {
|
|
3608
|
+
const r = indexedDB.open(name || "slidetake", 1);
|
|
3609
|
+
r.onupgradeneeded = () => r.result.createObjectStore("kv");
|
|
3610
|
+
r.onsuccess = () => res(r.result);
|
|
3611
|
+
r.onerror = () => rej(r.error);
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
async function kvGet(k) {
|
|
3615
|
+
const get = async (name) => {
|
|
3616
|
+
const db = await idb(name);
|
|
3617
|
+
return await new Promise((r) => {
|
|
3618
|
+
const q = db.transaction("kv").objectStore("kv").get(k);
|
|
3619
|
+
q.onsuccess = () => r(q.result);
|
|
3620
|
+
q.onerror = () => r(null);
|
|
3621
|
+
});
|
|
3622
|
+
};
|
|
3623
|
+
try {
|
|
3624
|
+
return await get() ?? await get("markcast") ?? await get("traverse") ?? null;
|
|
3625
|
+
} catch (e) {
|
|
3626
|
+
return null;
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
async function kvSet(k, v) {
|
|
3630
|
+
try {
|
|
3631
|
+
const db = await idb();
|
|
3632
|
+
db.transaction("kv", "readwrite").objectStore("kv").put(v, k);
|
|
3633
|
+
} catch (e) {
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
var rvHandle = null;
|
|
3637
|
+
var rvRetries = 0;
|
|
3638
|
+
var rvOpening = false;
|
|
3639
|
+
rvVideo.addEventListener("error", async () => {
|
|
3640
|
+
if (!rvVideo.getAttribute("src")) return;
|
|
3641
|
+
if (rvHandle && rvRetries < 5) {
|
|
3642
|
+
rvRetries++;
|
|
3643
|
+
rvNow.textContent = "Reloading " + reviewFileName + " (OBS was still finishing it)\u2026";
|
|
3644
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
3645
|
+
try {
|
|
3646
|
+
useRecording(await stableFile(rvHandle), rvHandle, true);
|
|
3647
|
+
return;
|
|
3648
|
+
} catch (e) {
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
rvNow.textContent = rvHandle ? "Chrome cannot play " + reviewFileName + ". In OBS set Recording Format to Hybrid MP4 (or MP4) with H.264 video; the ffmpeg command still works with this file." : "Could not play " + (reviewFileName || "this file") + ". If OBS was still finishing it when you opened it, open it again; if it still fails, set OBS to Hybrid MP4 (or MP4) with H.264 video.";
|
|
3652
|
+
});
|
|
3653
|
+
async function stableFile(handle) {
|
|
3654
|
+
rvOpening = true;
|
|
3655
|
+
try {
|
|
3656
|
+
return await settle(handle);
|
|
3657
|
+
} finally {
|
|
3658
|
+
rvOpening = false;
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
async function settle(handle) {
|
|
3662
|
+
let f = await handle.getFile();
|
|
3663
|
+
for (let i = 0; i < 10; i++) {
|
|
3664
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
3665
|
+
const g = await handle.getFile();
|
|
3666
|
+
if (g.size === f.size && g.lastModified === f.lastModified) return g;
|
|
3667
|
+
f = g;
|
|
3668
|
+
}
|
|
3669
|
+
return f;
|
|
3670
|
+
}
|
|
3671
|
+
function useRecording(file, handle, retry) {
|
|
3672
|
+
if (rvVideo.src) URL.revokeObjectURL(rvVideo.src);
|
|
3673
|
+
rvHandle = handle || null;
|
|
3674
|
+
if (!retry) rvRetries = 0;
|
|
3675
|
+
rvVideo.src = URL.createObjectURL(file);
|
|
3676
|
+
reviewFileName = file.name;
|
|
3677
|
+
document.getElementById("rv-novideo").hidden = true;
|
|
3678
|
+
rvNow.textContent = "Loaded " + file.name + ". Click a take to preview it.";
|
|
3679
|
+
if (pendingPlay) playRange(pendingPlay);
|
|
3680
|
+
else if (retry && playlist) playRange(playlist.ranges.slice(playlist.i));
|
|
3681
|
+
if (reviewing) document.getElementById("rv-ffmpeg").value = ffmpegScript2(reviewing, document.getElementById("rv-mode").value);
|
|
3682
|
+
}
|
|
3683
|
+
var fileInput = document.getElementById("rv-file-input");
|
|
3684
|
+
fileInput.addEventListener("change", () => {
|
|
3685
|
+
if (fileInput.files[0]) useRecording(fileInput.files[0]);
|
|
3686
|
+
fileInput.value = "";
|
|
3687
|
+
});
|
|
3688
|
+
document.getElementById("rv-open").onclick = async () => {
|
|
3689
|
+
if (!window.showOpenFilePicker) return fileInput.click();
|
|
3690
|
+
try {
|
|
3691
|
+
const [handle] = await window.showOpenFilePicker({ id: "obs-recordings", types: [{ description: "Recordings", accept: { "video/*": [".mov", ".mp4", ".m4v", ".mkv", ".webm"] } }] });
|
|
3692
|
+
rvNow.textContent = "Opening " + handle.name + "\u2026";
|
|
3693
|
+
useRecording(await stableFile(handle), handle);
|
|
3694
|
+
} catch (e) {
|
|
3695
|
+
if (!e || e.name !== "AbortError") rvNow.textContent = "Could not open that file.";
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
var folderBtn = document.getElementById("rv-folder");
|
|
3699
|
+
folderBtn.hidden = !window.showDirectoryPicker;
|
|
3700
|
+
folderBtn.onclick = async () => {
|
|
3701
|
+
const name = reviewing && baseName(reviewing.outputPath);
|
|
3702
|
+
try {
|
|
3703
|
+
const dir = await window.showDirectoryPicker({ id: "obs-recordings", mode: "read" });
|
|
3704
|
+
kvSet("obs-folder", dir);
|
|
3705
|
+
if (!name) {
|
|
3706
|
+
rvNow.textContent = "Folder remembered. This session has no file name from OBS; open the file instead.";
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
const handle = await dir.getFileHandle(name);
|
|
3710
|
+
useRecording(await stableFile(handle), handle);
|
|
3711
|
+
} catch (e) {
|
|
3712
|
+
if (e && e.name === "AbortError") return;
|
|
3713
|
+
rvNow.textContent = (name ? name + " is not in that folder" : "Could not read that folder") + ". Use \u201COpen the recording file\u2026\u201D instead.";
|
|
3714
|
+
}
|
|
3715
|
+
};
|
|
3716
|
+
async function autoLoadRecording(sess) {
|
|
3717
|
+
const name = baseName(sess.outputPath);
|
|
3718
|
+
if (!name || !window.showDirectoryPicker) return;
|
|
3719
|
+
if (reviewFileName === name && rvVideo.src) return;
|
|
3720
|
+
try {
|
|
3721
|
+
const dir = await kvGet("obs-folder");
|
|
3722
|
+
if (!dir || await dir.queryPermission({ mode: "read" }) !== "granted") return;
|
|
3723
|
+
const handle = await dir.getFileHandle(name);
|
|
3724
|
+
rvNow.textContent = "Opening " + name + "\u2026";
|
|
3725
|
+
useRecording(await stableFile(handle), handle);
|
|
3726
|
+
} catch (e) {
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
document.getElementById("rv-download").onclick = () => {
|
|
3730
|
+
if (!reviewing) return;
|
|
3731
|
+
const sess = reviewing, ch = finalChapters2(sess);
|
|
3732
|
+
const text = "# " + document.getElementById("rv-yt-title").value + "\n\nRecorded " + new Date(sess.date).toLocaleString() + (sess.outputPath ? " \xB7 " + sess.outputPath : "") + " \xB7 final length " + fmtTime(ch.length) + "\n\n## Render\n\n```sh\n" + document.getElementById("rv-ffmpeg").value + "\n```\n\n## YouTube title\n\n" + document.getElementById("rv-yt-title").value + "\n\n## YouTube description\n\n" + document.getElementById("rv-yt-desc").value + "\n\n## Tags\n\n" + document.getElementById("rv-yt-tags").value + "\n\n## Picked takes\n\n" + pickedRanges(sess).map((r) => "- " + fmtTime(r.start) + "\u2013" + fmtTime(r.end) + " " + r.title).join("\n") + "\n";
|
|
3733
|
+
const a = document.createElement("a");
|
|
3734
|
+
a.href = URL.createObjectURL(new Blob([text], { type: "text/markdown" }));
|
|
3735
|
+
a.download = sessionKey() + "-publish.md";
|
|
3736
|
+
a.click();
|
|
3737
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1e3);
|
|
3738
|
+
};
|
|
3739
|
+
if (loadObsSettings() && new URLSearchParams(location.search).get("obs")) connectObs();
|
|
3740
|
+
var camBtn = document.getElementById("btn-camera");
|
|
3741
|
+
var pipMsg = document.getElementById("pip-msg");
|
|
3742
|
+
var pipMsgTimer = null;
|
|
3743
|
+
function showPipMsg(text, sticky) {
|
|
3744
|
+
if (rec.active) return;
|
|
3745
|
+
pipMsg.textContent = text;
|
|
3746
|
+
pipMsg.classList.add("show");
|
|
3747
|
+
clearTimeout(pipMsgTimer);
|
|
3748
|
+
if (!sticky) pipMsgTimer = setTimeout(() => pipMsg.classList.remove("show"), 9e3);
|
|
3749
|
+
}
|
|
3750
|
+
function hidePipMsg() {
|
|
3751
|
+
clearTimeout(pipMsgTimer);
|
|
3752
|
+
pipMsg.classList.remove("show");
|
|
3753
|
+
}
|
|
3754
|
+
function cameraHelp() {
|
|
3755
|
+
let embedded = false;
|
|
3756
|
+
try {
|
|
3757
|
+
embedded = window.top !== window.self;
|
|
3758
|
+
} catch (e) {
|
|
3759
|
+
embedded = true;
|
|
3760
|
+
}
|
|
3761
|
+
if (embedded) return " This page is running inside a preview frame that may not allow cameras. Open Slidetake directly in Chrome (from localhost or as a file).";
|
|
3762
|
+
if (!window.isSecureContext) return " Browsers only allow cameras on secure pages. Open it from http://localhost or as a local file in Chrome.";
|
|
3763
|
+
return " Allow camera access for this page in the browser\u2019s site settings (the icon at the left of the address bar), then try again.";
|
|
3764
|
+
}
|
|
3765
|
+
function stopWebcam() {
|
|
3766
|
+
if (cameraStream) cameraStream.getTracks().forEach((t) => t.stop());
|
|
3767
|
+
cameraStream = null;
|
|
3768
|
+
const v = pipEl.querySelector("video");
|
|
3769
|
+
if (v) v.remove();
|
|
3770
|
+
}
|
|
3771
|
+
async function startWebcam() {
|
|
3772
|
+
if (cameraStream || cameraOff) return;
|
|
3773
|
+
{
|
|
3774
|
+
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
|
3775
|
+
showPipMsg("Camera not available on this page." + cameraHelp());
|
|
3776
|
+
return;
|
|
3777
|
+
}
|
|
3778
|
+
if (camBtn.disabled) return;
|
|
3779
|
+
camBtn.disabled = true;
|
|
3780
|
+
showPipMsg("Waiting for camera permission \u2014 check the browser prompt near the address bar.", true);
|
|
3781
|
+
try {
|
|
3782
|
+
cameraStream = await navigator.mediaDevices.getUserMedia({ video: { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { ideal: 30 } }, audio: false });
|
|
3783
|
+
hidePipMsg();
|
|
3784
|
+
} catch (e) {
|
|
3785
|
+
const name = e && e.name;
|
|
3786
|
+
showPipMsg(
|
|
3787
|
+
name === "NotAllowedError" || name === "SecurityError" ? "Camera access was blocked." + cameraHelp() : name === "NotFoundError" || name === "OverconstrainedError" ? "No camera was found. Check that a webcam is connected." : name === "NotReadableError" ? "The camera is busy \u2014 close other apps using it (Zoom, OBS, FaceTime) and try again." : "Could not start the camera" + (name ? " (" + name + ")" : "") + "." + cameraHelp()
|
|
3788
|
+
);
|
|
3789
|
+
return;
|
|
3790
|
+
} finally {
|
|
3791
|
+
camBtn.disabled = false;
|
|
3792
|
+
updateCamBtn();
|
|
3793
|
+
}
|
|
3794
|
+
cameraStream.getVideoTracks().forEach((t) => t.addEventListener("ended", () => {
|
|
3795
|
+
stopWebcam();
|
|
3796
|
+
applyDeckSettings();
|
|
3797
|
+
refocus();
|
|
3798
|
+
}));
|
|
3799
|
+
const v = document.createElement("video");
|
|
3800
|
+
v.autoplay = true;
|
|
3801
|
+
v.muted = true;
|
|
3802
|
+
v.playsInline = true;
|
|
3803
|
+
v.srcObject = cameraStream;
|
|
3804
|
+
pipEl.appendChild(v);
|
|
3805
|
+
}
|
|
3806
|
+
applyDeckSettings();
|
|
3807
|
+
refocus();
|
|
3808
|
+
}
|
|
3809
|
+
var CAMERA_ICON = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="6" width="14" height="12" rx="2"/><path d="M16 10.5 22 7v10l-6-3.5z"/></svg>';
|
|
3810
|
+
function updateCamBtn() {
|
|
3811
|
+
if (!camBtn.querySelector("svg")) camBtn.innerHTML = CAMERA_ICON + '<span class="lbl"> Camera</span>';
|
|
3812
|
+
camBtn.classList.toggle("on", !cameraOff);
|
|
3813
|
+
camBtn.setAttribute("aria-pressed", String(!cameraOff));
|
|
3814
|
+
camBtn.title = cameraOff ? "Camera is off for every slide (C)" : "Camera is on and follows the deck (C)";
|
|
3815
|
+
}
|
|
3816
|
+
function setCameraEnabled(on) {
|
|
3817
|
+
if (on && !RECORDING_UI) return;
|
|
3818
|
+
cameraOff = !on;
|
|
3819
|
+
if (cameraOff) stopWebcam();
|
|
3820
|
+
camManual = null;
|
|
3821
|
+
camCycle = -1;
|
|
3822
|
+
stepPos = Math.min(stepPos, Math.max(0, slideSteps(nodes.get(currentId)).length - 1));
|
|
3823
|
+
updateCamBtn();
|
|
3824
|
+
applyDeckSettings();
|
|
3825
|
+
applyStepState();
|
|
3826
|
+
updateActivePath();
|
|
3827
|
+
refocus();
|
|
3828
|
+
if (!presenting) showPipMsg(on ? "Camera on \u2014 slides follow their camera settings." : "Camera off \u2014 camera settings are ignored and slides use the whole screen.");
|
|
3829
|
+
if (on) startWebcam();
|
|
3830
|
+
}
|
|
3831
|
+
camBtn.onclick = () => setCameraEnabled(cameraOff);
|
|
3832
|
+
updateCamBtn();
|
|
3833
|
+
var idleTimer = null;
|
|
3834
|
+
function markActive() {
|
|
3835
|
+
document.body.classList.remove("idle");
|
|
3836
|
+
clearTimeout(idleTimer);
|
|
3837
|
+
if (presenting) idleTimer = setTimeout(() => document.body.classList.add("idle"), 2e3);
|
|
3838
|
+
}
|
|
3839
|
+
window.addEventListener("pointermove", markActive);
|
|
3840
|
+
document.addEventListener("fullscreenchange", () => {
|
|
3841
|
+
if (document.fullscreenElement) return;
|
|
3842
|
+
if (rec.active) finishTake("Stopped: the browser left fullscreen");
|
|
3843
|
+
else if (presenting) setPresent(false);
|
|
3844
|
+
});
|
|
3845
|
+
var help = document.getElementById("help");
|
|
3846
|
+
document.getElementById("btn-help").onclick = () => window.open(EMBED ? "https://slidetake.com/help" : "/help", "_blank", "noopener");
|
|
3847
|
+
document.getElementById("btn-keys").onclick = () => help.classList.add("open");
|
|
3848
|
+
document.getElementById("help-close").onclick = () => help.classList.remove("open");
|
|
3849
|
+
help.addEventListener("click", (e) => {
|
|
3850
|
+
if (e.target === help) help.classList.remove("open");
|
|
3851
|
+
});
|
|
3852
|
+
window.addEventListener("keydown", (e) => {
|
|
3853
|
+
if (e.key === "F5") {
|
|
3854
|
+
e.preventDefault();
|
|
3855
|
+
if (!rec.active) openRecordDialog();
|
|
3856
|
+
return;
|
|
3857
|
+
}
|
|
3858
|
+
if (rec.active) {
|
|
3859
|
+
takeKey(e);
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
if (document.querySelector(".modal.open")) {
|
|
3863
|
+
if (e.key === "Escape") closeModals();
|
|
3864
|
+
return;
|
|
3865
|
+
}
|
|
3866
|
+
const tag = document.activeElement && document.activeElement.tagName;
|
|
3867
|
+
if (tag === "TEXTAREA" || tag === "INPUT" || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
3868
|
+
if (help.classList.contains("open")) {
|
|
3869
|
+
if (e.key === "Escape") help.classList.remove("open");
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
const k = e.key;
|
|
3873
|
+
if (k === "ArrowRight" || k === " " || k === "PageDown") {
|
|
3874
|
+
e.preventDefault();
|
|
3875
|
+
step(1);
|
|
3876
|
+
} else if (k === "ArrowLeft" || k === "PageUp") {
|
|
3877
|
+
e.preventDefault();
|
|
3878
|
+
step(-1);
|
|
3879
|
+
} else if (k === "ArrowDown") {
|
|
3880
|
+
e.preventDefault();
|
|
3881
|
+
toChild();
|
|
3882
|
+
} else if (k === "ArrowUp") {
|
|
3883
|
+
e.preventDefault();
|
|
3884
|
+
toParent();
|
|
3885
|
+
} else if (k === "Home") {
|
|
3886
|
+
if (order.length) navigate(order[0]);
|
|
3887
|
+
} else if (k === "End") {
|
|
3888
|
+
if (order.length) navigate(order[order.length - 1]);
|
|
3889
|
+
} else if (k === "o" || k === "O") {
|
|
3890
|
+
overview();
|
|
3891
|
+
} else if (k === "e" || k === "E") {
|
|
3892
|
+
toggleEditor();
|
|
3893
|
+
} else if (k === "f" || k === "F" || k === "p" || k === "P") {
|
|
3894
|
+
setPresent(!presenting);
|
|
3895
|
+
} else if (k === "r" || k === "R") {
|
|
3896
|
+
openRecordDialog();
|
|
3897
|
+
} else if (k === "1") {
|
|
3898
|
+
setMode("tree");
|
|
3899
|
+
} else if (k === "2") {
|
|
3900
|
+
setMode("radial");
|
|
3901
|
+
} else if (k === "3") {
|
|
3902
|
+
setMode("path");
|
|
3903
|
+
} else if (k === "4") {
|
|
3904
|
+
setMode("focus");
|
|
3905
|
+
} else if (k === "c" || k === "C") {
|
|
3906
|
+
setCameraEnabled(cameraOff);
|
|
3907
|
+
} else if (k === "v" || k === "V") {
|
|
3908
|
+
cycleCamera();
|
|
3909
|
+
} else if (k === "l" || k === "L") {
|
|
3910
|
+
toggleMode();
|
|
3911
|
+
} else if (k === "+" || k === "=") {
|
|
3912
|
+
sizeStep(1);
|
|
3913
|
+
} else if (k === "-" || k === "_") {
|
|
3914
|
+
sizeStep(-1);
|
|
3915
|
+
} else if (k === "?" || k === "k" || k === "K") {
|
|
3916
|
+
help.classList.add("open");
|
|
3917
|
+
} else if (k === "Escape") {
|
|
3918
|
+
if (!backFromOverview() && presenting) setPresent(false);
|
|
3919
|
+
}
|
|
3920
|
+
});
|
|
3921
|
+
window.addEventListener("hashchange", () => {
|
|
3922
|
+
const { data, slide } = parseHash(location.hash);
|
|
3923
|
+
if (data && !(view && view.kind === "share" && data === view.data)) {
|
|
3924
|
+
location.reload();
|
|
3925
|
+
return;
|
|
3926
|
+
}
|
|
3927
|
+
if (slide && slide !== currentId && nodes.has(slide)) navigate(slide);
|
|
3928
|
+
});
|
|
3929
|
+
var lastSize = "";
|
|
3930
|
+
new ResizeObserver(() => {
|
|
3931
|
+
const size = stage.clientWidth + "x" + stage.clientHeight;
|
|
3932
|
+
if (size === lastSize) return;
|
|
3933
|
+
lastSize = size;
|
|
3934
|
+
applyCamera();
|
|
3935
|
+
refocus(true);
|
|
3936
|
+
}).observe(stage);
|
|
3937
|
+
var toastEl = document.createElement("div");
|
|
3938
|
+
toastEl.id = "toast";
|
|
3939
|
+
toastEl.setAttribute("role", "status");
|
|
3940
|
+
document.body.appendChild(toastEl);
|
|
3941
|
+
var toastTimer = null;
|
|
3942
|
+
function showToast(text, ms) {
|
|
3943
|
+
toastEl.textContent = text;
|
|
3944
|
+
toastEl.classList.add("show");
|
|
3945
|
+
clearTimeout(toastTimer);
|
|
3946
|
+
toastTimer = setTimeout(() => toastEl.classList.remove("show"), ms || 2500);
|
|
3947
|
+
}
|
|
3948
|
+
function deckAddress(source, { keepObs = true, keepEdit = true, slide = "" } = {}) {
|
|
3949
|
+
const link = new URL(shortLink(source), location.origin);
|
|
3950
|
+
new URLSearchParams(location.search).forEach((v, k) => {
|
|
3951
|
+
if (k === "src" || k === "obs" && !keepObs || k === "edit" && !keepEdit) return;
|
|
3952
|
+
link.searchParams.set(k, v);
|
|
3953
|
+
});
|
|
3954
|
+
if (slide) link.hash = slide;
|
|
3955
|
+
return link.href.replace(link.pathname, link.pathname.replace(/%40/g, "@"));
|
|
3956
|
+
}
|
|
3957
|
+
var openDialog = document.getElementById("open-dialog");
|
|
3958
|
+
var openUrl = document.getElementById("open-url");
|
|
3959
|
+
var openError = document.getElementById("open-error");
|
|
3960
|
+
document.getElementById("btn-load").onclick = () => {
|
|
3961
|
+
openError.hidden = true;
|
|
3962
|
+
openModal(openDialog);
|
|
3963
|
+
openUrl.focus();
|
|
3964
|
+
openUrl.select();
|
|
3965
|
+
};
|
|
3966
|
+
document.getElementById("open-form").onsubmit = (e) => {
|
|
3967
|
+
e.preventDefault();
|
|
3968
|
+
const source = normalizeSource(openUrl.value);
|
|
3969
|
+
if (!source) {
|
|
3970
|
+
openError.textContent = "That doesn't look like a link.";
|
|
3971
|
+
openError.hidden = false;
|
|
3972
|
+
return;
|
|
3973
|
+
}
|
|
3974
|
+
location.href = deckAddress(source);
|
|
3975
|
+
};
|
|
3976
|
+
async function shareLink(slide) {
|
|
3977
|
+
const keep = { keepObs: false, keepEdit: false, slide };
|
|
3978
|
+
if (view.kind === "source") return { link: deckAddress(view.source, keep), inside: false };
|
|
3979
|
+
const linkable = view.kind === "copy" && matchesOrigin(copy) && ["url", "gist", "builtin"].includes(copy.origin.kind);
|
|
3980
|
+
if (linkable) return { link: deckAddress(copy.origin, keep), inside: false };
|
|
3981
|
+
const data = view.kind === "share" ? view.data : await encodeDeck(editor.value);
|
|
3982
|
+
const q = new URLSearchParams(location.search);
|
|
3983
|
+
["src", "obs", "edit"].forEach((k) => q.delete(k));
|
|
3984
|
+
return { link: location.origin + "/share" + (q.toString() ? "?" + q : "") + deckHash(data, slide), inside: true };
|
|
3985
|
+
}
|
|
3986
|
+
document.getElementById("btn-share").onclick = async () => {
|
|
3987
|
+
const { link, inside } = await shareLink(currentId && currentId !== order[0] ? currentId : "");
|
|
3988
|
+
const note = !inside ? "Link copied." : "Link copied, with the whole deck inside it (" + (link.length / 1024).toFixed(1) + " KB)" + (link.length > 8e3 ? ". Some chat apps cut long links short: a GitHub file or gist makes a shorter one." : ".");
|
|
3989
|
+
try {
|
|
3990
|
+
await navigator.clipboard.writeText(link);
|
|
3991
|
+
showToast(note, 5e3);
|
|
3992
|
+
} catch (err) {
|
|
3993
|
+
prompt("Copy this link:", link);
|
|
3994
|
+
}
|
|
3995
|
+
if (view.kind === "copy") {
|
|
3996
|
+
copy.exported = copy.text;
|
|
3997
|
+
saveCopy();
|
|
3998
|
+
updateDocState();
|
|
3999
|
+
}
|
|
4000
|
+
};
|
|
4001
|
+
var savedMode = load("slidetake:layout");
|
|
4002
|
+
layoutMode = ["tree", "radial", "path", "focus"].includes(savedMode) ? savedMode : "tree";
|
|
4003
|
+
document.querySelectorAll("#layout-toggle .seg-btn").forEach((x) => x.classList.toggle("active", x.dataset.mode === layoutMode));
|
|
4004
|
+
var params = new URLSearchParams(location.search);
|
|
4005
|
+
if (["tree", "radial", "path", "focus"].includes(params.get("layout"))) {
|
|
4006
|
+
layoutMode = params.get("layout");
|
|
4007
|
+
document.querySelectorAll("#layout-toggle .seg-btn").forEach((x) => x.classList.toggle("active", x.dataset.mode === layoutMode));
|
|
4008
|
+
}
|
|
4009
|
+
if (EMBED) {
|
|
4010
|
+
const trail = (Array.isArray(EMBED.trail) ? EMBED.trail : EMBED.back ? [EMBED.back] : []).filter((t) => t && t.label);
|
|
4011
|
+
const brandBox = document.querySelector("header .brand");
|
|
4012
|
+
if (trail.length) {
|
|
4013
|
+
brandBox.innerHTML = '<nav class="trail" aria-label="Site">' + trail.map((t, i) => (i ? '<span class="sep" aria-hidden="true">|</span>' : "") + (t.url ? '<a href="' + escapeHtml(t.url) + '">' + escapeHtml(t.label) + "</a>" : "<span>" + escapeHtml(t.label) + "</span>")).join("") + "</nav>";
|
|
4014
|
+
}
|
|
4015
|
+
const credit = document.createElement("a");
|
|
4016
|
+
credit.id = "credit";
|
|
4017
|
+
credit.href = "https://slidetake.com";
|
|
4018
|
+
credit.target = "_blank";
|
|
4019
|
+
credit.rel = "noopener";
|
|
4020
|
+
credit.title = "Made with Slidetake";
|
|
4021
|
+
credit.setAttribute("aria-label", "Made with Slidetake");
|
|
4022
|
+
credit.innerHTML = LOGO + '<span class="word">Slide<span>take</span></span>';
|
|
4023
|
+
const actions = document.querySelector("header .hdr-actions");
|
|
4024
|
+
actions.insertBefore(credit, actions.firstChild);
|
|
4025
|
+
if (!RECORDING_UI) {
|
|
4026
|
+
actions.insertAdjacentHTML(
|
|
4027
|
+
"beforeend",
|
|
4028
|
+
'<button class="btn" id="hdr-keys" title="Keyboard shortcuts (K)">\u2328 Keys</button><button class="btn" id="hdr-full" title="Fullscreen (F)">\u26F6 Fullscreen</button>'
|
|
4029
|
+
);
|
|
4030
|
+
document.getElementById("hdr-keys").onclick = () => document.getElementById("help").classList.add("open");
|
|
4031
|
+
document.getElementById("hdr-full").onclick = () => setPresent(!presenting);
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
var route = routeOf(location.pathname, location.search, location.hash);
|
|
4035
|
+
var startId = route.page === "pick" ? "" : route.slide;
|
|
4036
|
+
var view = null;
|
|
4037
|
+
var copy = parseCopy(load("slidetake:copy")) || earlierDraft();
|
|
4038
|
+
function earlierDraft() {
|
|
4039
|
+
const old = load("slidetake:draft");
|
|
4040
|
+
if (!old || old === sample_default) return null;
|
|
4041
|
+
const c = makeCopy(old, { kind: "file", name: "your earlier draft" }, { exported: true });
|
|
4042
|
+
save("slidetake:copy", JSON.stringify(c));
|
|
4043
|
+
try {
|
|
4044
|
+
localStorage.removeItem("slidetake:draft");
|
|
4045
|
+
} catch (e) {
|
|
4046
|
+
}
|
|
4047
|
+
return c;
|
|
4048
|
+
}
|
|
4049
|
+
function saveCopy() {
|
|
4050
|
+
save("slidetake:copy", JSON.stringify(copy));
|
|
4051
|
+
}
|
|
4052
|
+
function updateDocState() {
|
|
4053
|
+
if (EMBED) return;
|
|
4054
|
+
let html;
|
|
4055
|
+
if (view.kind === "copy") {
|
|
4056
|
+
html = '<span class="mine">Your copy of ' + escapeHtml(originLabel(copy.origin)) + "</span>" + (isEdited(copy) ? ' <span class="edited">\xB7 edited</span>' : "");
|
|
4057
|
+
} else {
|
|
4058
|
+
const name = view.kind === "share" ? "a shared deck" : originLabel(view.source);
|
|
4059
|
+
html = '<span class="mine">' + escapeHtml(name.charAt(0).toUpperCase() + name.slice(1)) + '</span> <span class="ro">\xB7 read-only, typing makes your copy</span>';
|
|
4060
|
+
}
|
|
4061
|
+
document.getElementById("doc-state").innerHTML = html;
|
|
4062
|
+
editorPane.classList.toggle("unsaved", view.kind === "copy" && isEdited(copy));
|
|
4063
|
+
document.getElementById("btn-reset").hidden = !(view.kind === "copy" && !matchesOrigin(copy));
|
|
4064
|
+
const cont = document.getElementById("continue");
|
|
4065
|
+
cont.hidden = view.kind === "copy" || !copy;
|
|
4066
|
+
if (copy) {
|
|
4067
|
+
cont.textContent = "Your copy \u2192";
|
|
4068
|
+
cont.title = "Continue your copy of " + originLabel(copy.origin);
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
function confirmReplaceCopy(what) {
|
|
4072
|
+
if (!copy || !isEdited(copy)) return true;
|
|
4073
|
+
return confirm("Your copy of " + originLabel(copy.origin) + " has edits you haven't saved or shared. Replace it with " + what + "?");
|
|
4074
|
+
}
|
|
4075
|
+
function editAddress() {
|
|
4076
|
+
const q = new URLSearchParams(location.search);
|
|
4077
|
+
q.delete("src");
|
|
4078
|
+
q.delete("template");
|
|
4079
|
+
return "/edit" + (q.toString() ? "?" + q : "");
|
|
4080
|
+
}
|
|
4081
|
+
function forkToCopy() {
|
|
4082
|
+
const origin = view.kind === "share" ? { kind: "shared" } : view.source;
|
|
4083
|
+
if (!confirmReplaceCopy("a copy of " + originLabel(origin))) {
|
|
4084
|
+
editor.value = view.text;
|
|
4085
|
+
return false;
|
|
4086
|
+
}
|
|
4087
|
+
copy = makeCopy(view.text, origin);
|
|
4088
|
+
view = { kind: "copy" };
|
|
4089
|
+
history.pushState(null, "", editAddress() + (currentId && currentId !== order[0] ? "#" + encodeURIComponent(currentId) : ""));
|
|
4090
|
+
showToast("Editing your own copy of " + originLabel(origin) + ". The original is unchanged.", 4e3);
|
|
4091
|
+
return true;
|
|
4092
|
+
}
|
|
4093
|
+
function showCopy() {
|
|
4094
|
+
view = { kind: "copy" };
|
|
4095
|
+
history.pushState(null, "", editAddress());
|
|
4096
|
+
if (editorPane.classList.contains("collapsed")) toggleEditor();
|
|
4097
|
+
editor.value = copy.text;
|
|
4098
|
+
rebuild(true);
|
|
4099
|
+
updateDocState();
|
|
4100
|
+
}
|
|
4101
|
+
window.addEventListener("popstate", () => location.reload());
|
|
4102
|
+
async function fetchSource(source) {
|
|
4103
|
+
if (source.kind === "builtin") return BUILTIN[source.id] ?? BUILTIN.home;
|
|
4104
|
+
if (source.kind === "gist") {
|
|
4105
|
+
const res2 = await fetch("https://api.github.com/gists/" + encodeURIComponent(source.id));
|
|
4106
|
+
if (!res2.ok) throw new Error(res2.status === 404 ? "no such gist" : res2.status + " " + res2.statusText);
|
|
4107
|
+
const files = Object.values((await res2.json()).files || {});
|
|
4108
|
+
const file = files.find((f) => f.filename === source.file) || files.find((f) => /\.(md|markdown)$/i.test(f.filename)) || files[0];
|
|
4109
|
+
if (!file) throw new Error("the gist has no files");
|
|
4110
|
+
deckBase = file.raw_url;
|
|
4111
|
+
return file.truncated ? await (await fetch(file.raw_url)).text() : file.content;
|
|
4112
|
+
}
|
|
4113
|
+
const res = await fetch(source.url);
|
|
4114
|
+
if (!res.ok) throw new Error(res.status === 404 ? "not found" : res.status + " " + res.statusText);
|
|
4115
|
+
deckBase = new URL(source.url, location.href).href;
|
|
4116
|
+
return await res.text();
|
|
4117
|
+
}
|
|
4118
|
+
function showHome() {
|
|
4119
|
+
view = { kind: "source", source: { kind: "builtin", id: "home" }, text: BUILTIN.home };
|
|
4120
|
+
return view.text;
|
|
4121
|
+
}
|
|
4122
|
+
async function loadInitialDeck() {
|
|
4123
|
+
if (EMBED) {
|
|
4124
|
+
deckBase = EMBED.base || location.href;
|
|
4125
|
+
view = { kind: "source", source: { kind: "url", url: deckBase }, text: settingsBlock(EMBED.settings || {}) + String(EMBED.markdown || "") };
|
|
4126
|
+
return view.text;
|
|
4127
|
+
}
|
|
4128
|
+
if (route.page === "edit") {
|
|
4129
|
+
if (copy) {
|
|
4130
|
+
view = { kind: "copy" };
|
|
4131
|
+
return copy.text;
|
|
4132
|
+
}
|
|
4133
|
+
history.replaceState(null, "", "/new" + location.search);
|
|
4134
|
+
route.page = "pick";
|
|
4135
|
+
}
|
|
4136
|
+
if (route.page === "pick") {
|
|
4137
|
+
openModal(document.getElementById("new-dialog"));
|
|
4138
|
+
view = { kind: "source", source: { kind: "builtin", id: "template:blank" }, text: BUILTIN["template:blank"] };
|
|
4139
|
+
return view.text;
|
|
4140
|
+
}
|
|
4141
|
+
if (route.page === "share") {
|
|
4142
|
+
try {
|
|
4143
|
+
const text = await decodeDeck(route.data);
|
|
4144
|
+
view = { kind: "share", data: route.data, text };
|
|
4145
|
+
return text;
|
|
4146
|
+
} catch (e) {
|
|
4147
|
+
showToast("This link's deck is damaged or cut short, so it could not be opened.", 6e3);
|
|
4148
|
+
return showHome();
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
try {
|
|
4152
|
+
const text = await fetchSource(route.source);
|
|
4153
|
+
view = { kind: "source", source: route.source, text };
|
|
4154
|
+
return text;
|
|
4155
|
+
} catch (e) {
|
|
4156
|
+
statusErr.textContent = "Could not load the deck (" + e.message + ")";
|
|
4157
|
+
showToast("Could not load " + originLabel(route.source) + ": " + e.message, 6e3);
|
|
4158
|
+
return showHome();
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
if (params.get("edit") === "1" || route.page === "edit" && copy && params.get("edit") !== "0") toggleEditor();
|
|
4162
|
+
loadInitialDeck().then((text) => {
|
|
4163
|
+
editor.value = text;
|
|
4164
|
+
updateDocState();
|
|
4165
|
+
parseDeck2(editor.value);
|
|
4166
|
+
build();
|
|
4167
|
+
return document.fonts ? document.fonts.ready : null;
|
|
4168
|
+
}).then(() => {
|
|
4169
|
+
nodes.forEach(sizeCard);
|
|
4170
|
+
position();
|
|
4171
|
+
navigate(nodes.has(startId) ? startId : order[0], true);
|
|
4172
|
+
});
|
|
4173
|
+
})();
|
|
4174
|
+
</script>
|
|
4175
|
+
</body>
|
|
4176
|
+
</html>
|