summaryrefslogtreecommitdiffstats
path: root/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'script.js')
-rw-r--r--script.js39
1 files changed, 22 insertions, 17 deletions
diff --git a/script.js b/script.js
index c127d3a9..9777c060 100644
--- a/script.js
+++ b/script.js
@@ -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');