diff options
| author | Sacha Chua <sacha@sachachua.com> | 2026-10-15 13:23:48 -0400 |
|---|---|---|
| committer | Sacha Chua <sacha@sachachua.com> | 2026-10-15 13:23:48 -0400 |
| commit | b6b6d024c96663d02c6e0a7061ab76ee47c3bc8c (patch) | |
| tree | 5febef7f11bc5da669f948a5896ee75cfb2aba4d /script.js | |
| parent | 97b9c64e9584e893f571f3507347e8430c05f649 (diff) | |
| download | emacsconf-wiki-b6b6d024c96663d02c6e0a7061ab76ee47c3bc8c.tar.xz emacsconf-wiki-b6b6d024c96663d02c6e0a7061ab76ee47c3bc8c.zip | |
use script.js
Diffstat (limited to 'script.js')
| -rw-r--r-- | script.js | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -1,8 +1,8 @@ -// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later + // @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 + Copyright (C) 2020-2024 Grant Shangreaux and Sacha Chua This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -36,16 +36,21 @@ function handleSubtitleClick(event) { var video = event.target.getAttribute('data-video'); - var start = event.target.getAttribute('data-start'); - var videoElem = document.getElementById(video); - if (videoElem) { - videoElem.currentTime = parseSeconds(start); - videoElem.scrollIntoView(); - } - if (event.preventDefault) { - event.preventDefault(); - } - } + var start = event.target.getAttribute('data-start'); + const stickyVideo = document.querySelector('.transcript #' + video); + const indexCardVideo = document.querySelector('.vid #' + video); + if (indexCardVideo) { + indexCardVideo.currentTime = parseSeconds(start); + } + if (stickyVideo && window.getComputedStyle(stickyVideo).display == 'block') { + stickyVideo.currentTime = parseSeconds(start); + } else { + indexCardVideo.scrollIntoView(); + } + if (event.preventDefault) { + event.preventDefault(); + } + } window.onload = function initScript() { let subtitles = document.getElementsByClassName('subtitle'); @@ -53,11 +58,11 @@ subtitles[i].onclick = handleSubtitleClick; } } -// @license-end + // @license-end // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0 -// Copyright (C) 2021, 2022 Sacha Chua + // Copyright (C) 2021, 2022, 2026 Sacha Chua -function addLocalTimeToSVGs() { + function addLocalTimeToSVGs() { var dateOptions = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', @@ -122,7 +127,7 @@ addLocalTimeToSVGs(); } } -// @license-end + // @license-end // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0 // Copyright (c) 2021 Sacha Chua - CC0 Public Domain function displayChapters(elem) { @@ -207,7 +212,7 @@ addLocalTimeToSVGs(); if (transcriptDiv.querySelector('.vid')) transcriptDiv.querySelector('.vid').remove(); // already has it - // TODO: Make a copy of the video and place it at the start of the btranscript div, positioned to the left, and sticky, but only on large screens. + // TODO: Make a copy of the video and place it at the start of the transcript div, positioned to the left, and sticky, but only on large screens. const videoCopy = video.cloneNode(true); transcriptDiv.prepend(videoCopy); videoCopy.classList.add('sticky-video'); |
