From e10d336fa2823431e4e25237700cbaf1bd1f5899 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sun, 22 Dec 2024 21:24:52 -0500 Subject: affect the sticky one --- templates/page.tmpl | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/templates/page.tmpl b/templates/page.tmpl index c196dedf..203f88ba 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -42,7 +42,7 @@ /* 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 @@ -76,16 +76,19 @@ 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 (stickyVideo && window.getComputedStyle(stickyVideo).display == 'block') { + stickyVideo.currentTime = parseSeconds(start); + } else if (indexCardVideo) { + indexCardVideo.currentTime = parseSeconds(start); + indexCardVideo.scrollIntoView(); + } + if (event.preventDefault) { + event.preventDefault(); + } + } window.onload = function initScript() { let subtitles = document.getElementsByClassName('subtitle'); -- cgit v1.2.3