1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
<!DOCTYPE html>
<TMPL_IF HTML_LANG_CODE><html lang="<TMPL_VAR HTML_LANG_CODE>" dir="<TMPL_VAR HTML_LANG_DIR>" xmlns="http://www.w3.org/1999/xhtml"><TMPL_ELSE><html xmlns="http://www.w3.org/1999/xhtml"></TMPL_IF>
<head>
<TMPL_IF DYNAMIC>
<TMPL_IF FORCEBASEURL><base href="<TMPL_VAR FORCEBASEURL>" /><TMPL_ELSE>
<TMPL_IF BASEURL><base href="<TMPL_VAR BASEURL>" /></TMPL_IF>
</TMPL_IF>
</TMPL_IF>
<TMPL_IF HTML5><meta charset="utf-8" /><TMPL_ELSE><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></TMPL_IF>
<title><TMPL_LOOP PARENTLINKS><TMPL_VAR PAGE> - </TMPL_LOOP> <TMPL_VAR TITLE></title>
<TMPL_IF RESPONSIVE_LAYOUT><meta name="viewport" content="width=device-width, initial-scale=1" /></TMPL_IF>
<TMPL_IF FAVICON>
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/x-icon" />
</TMPL_IF>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
<TMPL_IF LOCAL_CSS>
<link rel="stylesheet" href="<TMPL_VAR BASEURL><TMPL_VAR LOCAL_CSS>" type="text/css" />
<TMPL_ELSE>
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
</TMPL_IF>
<TMPL_UNLESS DYNAMIC>
<TMPL_IF EDITURL>
<link rel="alternate" type="application/x-wiki" title="Edit this page" href="<TMPL_VAR EDITURL>" />
</TMPL_IF>
<TMPL_IF FEEDLINKS><TMPL_VAR FEEDLINKS></TMPL_IF>
<TMPL_IF RELVCS><TMPL_VAR RELVCS></TMPL_IF>
<TMPL_IF META><TMPL_VAR META></TMPL_IF>
<TMPL_LOOP TRAILLOOP>
<TMPL_IF PREVPAGE>
<link rel="prev" href="<TMPL_VAR PREVURL>" title="<TMPL_VAR PREVTITLE>" />
</TMPL_IF>
<link rel="up" href="<TMPL_VAR TRAILURL>" title="<TMPL_VAR TRAILTITLE>" />
<TMPL_IF NEXTPAGE>
<link rel="next" href="<TMPL_VAR NEXTURL>" title="<TMPL_VAR NEXTTITLE>" />
</TMPL_IF>
</TMPL_LOOP>
</TMPL_UNLESS>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
/*
SeekToTime - simple script to add video time jump functionality to timestamp links
Copyright (C) 2020 Grant Shangreaux
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
This script enables wiki editors to create anchor tags with the class "time-link"
that will be parsed for seeking to specific time stamps in the main video on a page.
The tag should look like this:
<a href="#mainVideo" class="time-link">mm:ss</a>
This could be extended to accept hours in the time stamp as well, but currently does not.
*/
let mainVideo;
let qnaVideo; // some pages have a questions and answers video
let timestamps;
// expects a string like "mm:ss.mmm"
function parseSeconds(timeString) {
return timeString.split(":").reduce(function(prev, o) {
return prev * 60 + parseFloat(o);
}, 0);
}
function handleSubtitleClick(event) {
var video = event.target.attributes['data-video'].value;
var start = event.target.attributes['data-start'].value
var videoElem = document.getElementById(video);
if (videoElem) {
videoElem.currentTime = parseSeconds(start);
videoElem.scrollIntoView();
}
event.preventDefault();
}
window.onload = function initScript() {
mainVideo = document.getElementById("mainVideo");
qnaVideo = document.getElementById("qnaVideo");
timestamps = document.getElementsByClassName("time-link");
var len = timestamps.length;
for (let i = 0; i < len; i++) {
timestamps[i].onclick = function () {
videoType = this.href.split("/").pop();
video = (videoType == "#mainVideo") ? mainVideo : qnaVideo;
video.currentTime = parseSeconds(this.innerText)
};
}
let subtitles = document.getElementsByClassName('subtitle');
for (let i = 0; i < subtitles.length; i++) {
subtitles[i].onclick = handleSubtitleClick;
}
}
// @license-end
</script>
</head>
<body <TMPL_IF SIDEBAR>class="has-sidebar"</TMPL_IF>>
<TMPL_IF HTML5><article class="page"><TMPL_ELSE><div class="page"></TMPL_IF>
<TMPL_IF HTML5><section class="pageheader-wrapper"><TMPL_ELSE><div class="pageheader-wrapper"></TMPL_IF>
<TMPL_IF HTML5><section class="pageheader"><TMPL_ELSE><div class="pageheader"></TMPL_IF>
<TMPL_IF HTML5><header class="header"><TMPL_ELSE><div class="header"></TMPL_IF>
<span>
<span class="parentlinks">
<TMPL_LOOP PARENTLINKS>
<a href="<TMPL_VAR URL>"><TMPL_VAR PAGE></a>/
</TMPL_LOOP>
</span>
<span class="title">
<TMPL_VAR TITLE>
<TMPL_IF ISTRANSLATION>
(<TMPL_VAR PERCENTTRANSLATED>%)
</TMPL_IF>
</span>
</span>
<TMPL_UNLESS DYNAMIC>
<TMPL_IF SEARCHFORM>
<TMPL_VAR SEARCHFORM>
</TMPL_IF>
</TMPL_UNLESS>
<TMPL_IF HTML5></header><TMPL_ELSE></div></TMPL_IF>
<TMPL_IF HAVE_ACTIONS>
<TMPL_IF HTML5><nav class="actions"><TMPL_ELSE><div class="actions"></TMPL_IF>
<ul>
<TMPL_IF EDITURL>
<li><a href="<TMPL_VAR EDITURL>" rel="nofollow">Edit</a></li>
<TMPL_ELSE>
<li><a href="/edit/">Edit <span class="muted">(how to)</span></a></li>
</TMPL_IF>
<TMPL_IF RECENTCHANGESURL>
<li><a href="<TMPL_VAR RECENTCHANGESURL>">Recent Changes</a></li>
</TMPL_IF>
<TMPL_IF HISTORYURL>
<li><a rel="nofollow" href="<TMPL_VAR HISTORYURL>">History</a></li>
</TMPL_IF>
<TMPL_IF GETSOURCEURL>
<li><a rel="nofollow" href="<TMPL_VAR GETSOURCEURL>">Source</a></li>
</TMPL_IF>
<TMPL_IF PREFSURL>
<li><a rel="nofollow" href="<TMPL_VAR PREFSURL>">Preferences</a></li>
</TMPL_IF>
<TMPL_IF ACTIONS>
<TMPL_LOOP ACTIONS>
<li><TMPL_VAR ACTION></li>
</TMPL_LOOP>
</TMPL_IF>
<TMPL_IF COMMENTSLINK>
<li><TMPL_VAR COMMENTSLINK></li>
<TMPL_ELSE>
<TMPL_IF DISCUSSIONLINK>
<li><TMPL_VAR DISCUSSIONLINK></li>
</TMPL_IF>
</TMPL_IF>
</ul>
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<TMPL_IF OTHERLANGUAGES>
<TMPL_IF HTML5><nav id="otherlanguages"><TMPL_ELSE><div id="otherlanguages"></TMPL_IF>
<ul>
<TMPL_LOOP OTHERLANGUAGES>
<li>
<a href="<TMPL_VAR URL>"><TMPL_VAR LANGUAGE></a>
<TMPL_IF MASTER>
(master)
<TMPL_ELSE>
(<TMPL_VAR PERCENT>%)
</TMPL_IF>
</li>
</TMPL_LOOP>
</ul>
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<TMPL_UNLESS DYNAMIC>
<TMPL_VAR TRAILS>
</TMPL_UNLESS>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
<div id="pagebody">
<TMPL_UNLESS DYNAMIC>
<TMPL_IF SIDEBAR>
<TMPL_IF HTML5><aside class="sidebar"><TMPL_ELSE><div class="sidebar"></TMPL_IF>
<TMPL_VAR SIDEBAR>
<TMPL_IF HTML5></aside><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
</TMPL_UNLESS>
<TMPL_IF HTML5><section<TMPL_ELSE><div</TMPL_IF> id="content" role="main">
<TMPL_VAR CONTENT>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
<TMPL_IF ENCLOSURE>
<TMPL_IF HTML5><section id="enclosure"><TMPL_ELSE><div id="enclosure"></TMPL_IF>
<a href="<TMPL_VAR ENCLOSURE>">Download</a>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<TMPL_UNLESS DYNAMIC>
<TMPL_IF COMMENTS>
<TMPL_IF HTML5><section<TMPL_ELSE><div</TMPL_IF> id="comments" role="complementary">
<TMPL_VAR COMMENTS>
<TMPL_IF ADDCOMMENTURL>
<div class="addcomment">
<a rel="nofollow" href="<TMPL_VAR ADDCOMMENTURL>">Add a comment</a>
</div>
<TMPL_ELSE>
<div class="addcomment">Comments on this page are closed.</div>
</TMPL_IF>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
</TMPL_UNLESS>
</div>
<TMPL_IF HTML5><footer<TMPL_ELSE><div</TMPL_IF> id="footer" class="pagefooter" role="contentinfo">
<TMPL_UNLESS DYNAMIC>
<TMPL_IF HTML5><nav id="pageinfo"><TMPL_ELSE><div id="pageinfo"></TMPL_IF>
<TMPL_VAR TRAILS>
<TMPL_IF TAGS>
<TMPL_IF HTML5><nav class="tags"><TMPL_ELSE><div class="tags"></TMPL_IF>
Tags:
<TMPL_LOOP TAGS>
<TMPL_VAR LINK>
</TMPL_LOOP>
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<TMPL_IF BACKLINKS>
<TMPL_IF HTML5><nav id="backlinks"><TMPL_ELSE><div id="backlinks"></TMPL_IF>
Backlinks:
<TMPL_LOOP BACKLINKS>
<a href="<TMPL_VAR URL>"><TMPL_VAR PAGE></a>
</TMPL_LOOP>
<TMPL_IF MORE_BACKLINKS>
<span class="popup">...
<span class="balloon">
<TMPL_LOOP MORE_BACKLINKS>
<a href="<TMPL_VAR URL>"><TMPL_VAR PAGE></a>
</TMPL_LOOP>
</span>
</span>
</TMPL_IF>
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
</TMPL_IF>
<TMPL_IF COPYRIGHT>
<div class="pagecopyright">
<a name="pagecopyright"></a>
<TMPL_VAR COPYRIGHT>
</div>
</TMPL_IF>
<TMPL_IF LICENSE>
<div class="pagelicense">
<a name="pagelicense"></a>
<TMPL_VAR LICENSE>
</div>
</TMPL_IF>
<div class="pagedate">
Last edited <TMPL_VAR MTIME>
<!-- Created <TMPL_VAR CTIME> -->
</div>
<TMPL_IF HTML5></nav><TMPL_ELSE></div></TMPL_IF>
<TMPL_IF EXTRAFOOTER><TMPL_VAR EXTRAFOOTER></TMPL_IF>
</TMPL_UNLESS>
<!-- from <TMPL_VAR WIKINAME> -->
<TMPL_IF HTML5></footer><TMPL_ELSE></div></TMPL_IF>
<TMPL_IF HTML5></article><TMPL_ELSE></div></TMPL_IF>
<script>
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0
// Copyright (C) 2021 Sacha Chua
if (document.querySelector('.times')) { document.querySelector('.times').prepend('Your local time: ~ ' + (new Date(document.querySelector('.times').getAttribute('start')).toLocaleString()) + ' to ~ ' + (new Date(document.querySelector('.times').getAttribute('end')).toLocaleString()) + "<br />"); }
if (document.querySelector('a[name=transcript]')) {
var transcriptLink = document.createElement('a');
transcriptLink.setAttribute('href', '#transcript');
transcriptLink.textContent = 'View transcript';
var video = document.querySelector('.mainVideo video');
if (video) {
var resources = document.querySelector('.mainVideo video').closest('.vid').querySelector('.resources');
var transcriptDiv = document.createElement('div');
transcriptDiv.appendChild(transcriptLink)
if (resources) { resources.prepend(transcriptDiv); }
}
}
if (document.querySelector('.chat-iframe')) {
document.querySelector('.chat-iframe').innerHTML = '<iframe src="https://chat.emacsconf.org" height="600" width="100%"></iframe>';
}
// @license-end
</script>
<script>
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0
// Copyright (c) 2021 Sacha Chua - CC0 Public Domain
function displayChapters(elem) {
var i;
var chapter;
var list = document.createElement('ol');
list.setAttribute('class', 'chapters');
var link;
var target = elem.getAttribute('data-target');
var video = document.getElementById(target);
var track;
if (video) {
track = video.addTextTrack('chapters');
track.mode = 'hidden';
}
var chapters = elem.textContent.split(/[ \t]*\n+[ \t]*/).forEach(function(line) {
var m = (line.match(/^(([0-9]+:)?[0-9]+:[0-9]+)[ \t]+(.*)/));
if (m) {
var start = m[1];
var text = m[3];
chapter = document.createElement('li');
link = document.createElement('a');
link.setAttribute('href', '#');
link.setAttribute('data-video', target);
link.setAttribute('data-start', start);
link.setAttribute('data-start-s', parseSeconds(start));
link.appendChild(document.createTextNode(m[1] + ' ' + text));
link.onclick = handleSubtitleClick;
chapter.appendChild(link);
list.appendChild(chapter);
if (track) {
var time = parseSeconds(start);
if (track.cues.length > 0) {
track.cues[track.cues.length - 1].endTime = time - 1;
}
track.addCue(new VTTCue(time, time, text));
}
}
})
if (track && track.cues.length > 0) {
video.addEventListener('durationchange', function() {
track.cues[track.cues.length - 1].endTime = video.duration;
});
track.addEventListener('cuechange', function() {
if (!this.activeCues[0]) return;
if (list.querySelector('.current')) {
list.querySelector('.current').className = '';
}
var chapter;
if (chapter = list.querySelector('a[data-start-s="' + this.activeCues[0].startTime + '"]')) {
chapter.parentNode.className = 'current';
}
});
}
elem.parentNode.replaceChild(list, elem);
}
document.querySelectorAll('pre.chapters').forEach(displayChapters);
// @license-end
</script>
</body>
</html>
|