From 88a2c4b653ba7f73ba18375ec4596efbd62c6ff4 Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Tue, 29 Dec 2020 12:22:21 -0600 Subject: Fix: event handler scoping --- templates/page.tmpl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/page.tmpl b/templates/page.tmpl index 6d223308..cafc6835 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -49,17 +49,20 @@ return (minutes * 60) + seconds; } + function seekToTime(seconds) { + console.log("handler", seconds) + mainVideo.currentTime = seconds; + } + window.onload = function initScript() { - console.log("initializing seek to time script"); mainVideo = document.getElementById("mainVideo"); timestamps = document.getElementsByClassName("time-link"); len = timestamps.length; for (i = 0; i < len; i++) { seconds = parseSeconds(timestamps[i].innerText); + console.log("seconds: ", seconds); - timestamps[i].onclick = function () { - mainVideo.currentTime = seconds; - } + timestamps[i].onclick = seekToTime(seconds); } } -- cgit v1.2.3