summaryrefslogtreecommitdiffstats
path: root/templates/page.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'templates/page.tmpl')
-rw-r--r--templates/page.tmpl211
1 files changed, 151 insertions, 60 deletions
diff --git a/templates/page.tmpl b/templates/page.tmpl
index 235d3aa9..1f40aa66 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -76,6 +76,21 @@
}, 0);
}
+ function handleSubtitleClick(event) {
+ var video = event.target.getAttribute('data-video');
+ var start = event.target.getAttribute('data-start');
+ let m = video.match(/(mainVideo|qnaVideo)-(.*)/);
+ if (m) {
+ video = m[2] + '-' + m[1];
+ }
+ 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");
@@ -88,16 +103,6 @@
video.currentTime = parseSeconds(this.innerText)
};
}
- handleSubtitleClick = function(event) {
- video = event.target.attributes['data-video'].value;
- start = event.target.attributes['data-start'].value
- videoElem = document.getElementById(video);
- if (videoElem) {
- videoElem.currentTime = parseSeconds(start);
- videoElem.scrollIntoView();
- }
- }
-
let subtitles = document.getElementsByClassName('subtitle');
for (let i = 0; i < subtitles.length; i++) {
subtitles[i].onclick = handleSubtitleClick;
@@ -293,70 +298,156 @@ Last edited <TMPL_VAR MTIME>
<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()) + "\n"); }
+ // Copyright (C) 2021, 2022 Sacha Chua
+
+ if (document.querySelector('.times')) {
+ var dateOptions = {dateStyle: 'short', timeStyle: 'short'};
+ var localStart = (new Date(document.querySelector('.times').getAttribute('start'))).toLocaleString([], dateOptions);
+ var localEnd = (new Date(document.querySelector('.times').getAttribute('end'))).toLocaleString([], dateOptions);
+ var dateElem = document.createElement('div');
+ dateElem.appendChild(document.createTextNode('Your local time: ~ ' + localStart + ' to ~ ' + localEnd));
+ document.querySelector('.times').prepend(dateElem);
+ if (document.querySelector('.times').querySelector('.others')) {
+ document.querySelector('.times').querySelector('.others').style.display = 'none';
+ }
+ }
+ if (document.querySelector('.time-overlay')) {
+ document.querySelectorAll('.time-overlay').forEach(function (o) {
+ if (o.getAttribute('title')) return;
+ var dateOptions = {dateStyle: 'short', timeStyle: 'short'};
+ var localStart, localEnd;
+ if (o.getAttribute('start') && o.getAttribute('end')) {
+ localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions);
+ localEnd = (new Date(o.getAttribute('end'))).toLocaleString([], dateOptions);
+ o.setAttribute('title', 'Your local time: ~ ' + localStart + ' to ~ ' + localEnd);
+ } else if (o.getAttribute('start')) {
+ localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions);
+ o.setAttribute('title', 'Your local time: ~ ' + localStart);
+ }
+ });
+ }
+
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>';
-}
+ 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); }
+ }
+ }
+ var chat = document.querySelector('.chat-iframe');
+ if (chat) {
+ if (chat.getAttribute('data-track')) {
+ chat.innerHTML = '<iframe src="https://chat.emacsconf.org?join=emacsconf,emacsconf-' +
+ chat.getAttribute('data-track').replace(/[^A-Za-z]/g, '') + '" height="600" width="100%"></iframe>';
+ } else {
+ chat.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
- // Based on http://thenewcode.com/977/Create-Interactive-HTML5-Video-with-WebVTT-Chapters
- function displayChapters(trackElement){
- if ((trackElement) && (textTrack = trackElement.track)){
- if (textTrack.kind === "chapters"){
- textTrack.mode = 'hidden';
- var video = trackElement.closest('video');
- var chapterList = trackElement.closest('.video-card').querySelector('ol');
- for (var i = 0; i < textTrack.cues.length; ++i) {
- cue = textTrack.cues[i],
- chapterName = cue.text,
- start = cue.startTime,
- chapter = document.createElement("li");
- chapter.setAttribute('data-start', start);
- date = new Date(0);
- date.setSeconds(cue.startTime);
- var chapterDescription = document.createTextNode(date.toISOString().substr(14, 5) + ' ' + cue.text);
- chapter.appendChild(chapterDescription);
- //locationList.insertBefore(newLocale);
- chapter.addEventListener("click",
- function() {
- video.currentTime = this.getAttribute('data-start');
- },false);
- chapterList.append(chapter);
+ // 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]+)(?:\.[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[2] + ' ' + 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));
}
- textTrack.addEventListener("cuechange",
- function() {
- var currentLocation = this.activeCues[0].startTime;
- if (chapter = chapterList.querySelector('li[data-start="' + currentLocation + '"]')) {
- var locations = [].slice.call(chapterList.querySelectorAll("li"));
- for (var i = 0; i < locations.length; ++i) {
- locations[i].classList.remove("current");
- }
- chapter.classList.add("current");
- }
- },false);
}
+ })
+ 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('track[kind=chapters]').forEach(function(e) { e.addEventListener('load', function() { displayChapters(e); });});
+
+ document.querySelectorAll('pre.chapters').forEach(displayChapters);
+
+ var video = document.querySelector('video.reload');
+if (video) {
+ var myVar = setInterval(reloadAsNeeded, 1000);
+ var oldTime = '';
+ function reloadAsNeeded() {
+ if ((video.paused != true && (video.currentTime - oldTime) == 0 && video.currentTime != 0)) {
+ var source = video.querySelector('source');
+ var oldVideo = source.src;
+ source.src = '';
+ source.src = oldVideo;
+ video.load();
+ video.play();
+ }
+ oldTime = video.currentTime;
+ };
+}
// @license-end
+ // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0
+ // Copyright (c) 2023 Sacha Chua - CC0 Public Domain
+ function highlightTalks() {
+ // highlight any talk mentioned in the highlight URL parameter
+ var params = new URLSearchParams(window.location.search);
+ if (!params.get('highlight')) return;
+ var talks = params.get('highlight').split(',').filter(function(o) { return o.match(/^[-a-z0-9]+$/); });
+ var regexp = new RegExp('/talks/(' + talks.join('|') + ')/?$');
+ document.querySelectorAll('a[href]').forEach(function(link) {
+ console.debug(link.getAttribute('href'), link.getAttribute('href').match(regexp));
+ if (link.getAttribute('href').match(regexp)) {
+ console.debug(link);
+ link.classList.add('highlight');
+ }
+ });
+ }
+
+ addEventListener('DOMContentLoaded', highlightTalks);
+ // @license-end
</script>
</body>
</html>