From d2224e35bd050a1fcc548a34a73979734e361371 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 00:31:21 -0500 Subject: Start working on directive for subtitles --- templates/subtitle.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/subtitle.md (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md new file mode 100644 index 00000000..dcd6971e --- /dev/null +++ b/templates/subtitle.md @@ -0,0 +1 @@ + -- cgit v1.2.3 From 6de4c373099fc24100fe8bcfd63d2677f4018035 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 00:53:29 -0500 Subject: Try subtitle --- templates/page.tmpl | 9 ++++----- templates/subtitle.md | 1 - templates/subtitle.tmpl | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 templates/subtitle.md create mode 100644 templates/subtitle.tmpl (limited to 'templates') diff --git a/templates/page.tmpl b/templates/page.tmpl index 576f3d66..44b6a957 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -69,12 +69,11 @@ let qnaVideo; // some pages have a questions and answers video let timestamps; - // expects a string like "mm:ss" + // expects a string like "mm:ss.mmm" function parseSeconds(timeString) { - const times = timeString.split(":"); - const minutes = parseFloat(times[0]); - const seconds = parseFloat(times[1]); - return (minutes * 60) + seconds; + return timeString.split(":").reduce(function(prev, o) { + return prev * 60 + parseFloat(o); + }); } window.onload = function initScript() { diff --git a/templates/subtitle.md b/templates/subtitle.md deleted file mode 100644 index dcd6971e..00000000 --- a/templates/subtitle.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/subtitle.tmpl b/templates/subtitle.tmpl new file mode 100644 index 00000000..dcd6971e --- /dev/null +++ b/templates/subtitle.tmpl @@ -0,0 +1 @@ + -- cgit v1.2.3 From 5b4eb06f36e0aef05a82024ffae083f83d9b4b13 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 00:54:11 -0500 Subject: Rename it back --- templates/subtitle.md | 1 + templates/subtitle.tmpl | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 templates/subtitle.md delete mode 100644 templates/subtitle.tmpl (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md new file mode 100644 index 00000000..dcd6971e --- /dev/null +++ b/templates/subtitle.md @@ -0,0 +1 @@ + diff --git a/templates/subtitle.tmpl b/templates/subtitle.tmpl deleted file mode 100644 index dcd6971e..00000000 --- a/templates/subtitle.tmpl +++ /dev/null @@ -1 +0,0 @@ - -- cgit v1.2.3 From 1fc217a60159aca216c7ba6c95b752eb883ed6cb Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 00:55:27 -0500 Subject: Remove newline --- templates/subtitle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md index dcd6971e..b9e0ba9d 100644 --- a/templates/subtitle.md +++ b/templates/subtitle.md @@ -1 +1 @@ - + \ No newline at end of file -- cgit v1.2.3 From 468b90e681bbca2c7e2095c0b6df48bbb4cf7041 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 01:13:11 -0500 Subject: Fiddle with page JS --- templates/page.tmpl | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/templates/page.tmpl b/templates/page.tmpl index 44b6a957..a764202d 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -73,21 +73,35 @@ function parseSeconds(timeString) { return timeString.split(":").reduce(function(prev, o) { return prev * 60 + parseFloat(o); - }); + }, 0); } window.onload = function initScript() { - mainVideo = document.getElementById("mainVideo"); - qnaVideo = document.getElementById("qnaVideo"); - timestamps = document.getElementsByClassName("time-link"); - let len = timestamps.length; - for (let i = 0; i < len; i++) { - timestamps[i].onclick = function () { - const videoType = this.href.split("/").pop(); - const video = (videoType == "#mainVideo") ? mainVideo : qnaVideo; - video.currentTime = parseSeconds(this.innerText) - }; + mainVideo = document.getElementById("mainVideo"); + qnaVideo = document.getElementById("qnaVideo"); + timestamps = document.getElementsByClassName("time-link"); + let len = timestamps.length; + for (let i = 0; i < len; i++) { + timestamps[i].onclick = function () { + const videoType = this.href.split("/").pop(); + const video = (videoType == "#mainVideo") ? mainVideo : qnaVideo; + video.currentTime = parseSeconds(this.innerText) + }; + } + let handleSubtitleClick = function(event) { + let video = event.target.attributes['data-video'].value; + let start = event.target.attributes['data-start'].value + let videoElem = document.getElementById(video); + if (videoElem) { + videoElem.currentTime = parseSeconds(start); } + } + + let subtitles = document.getElementsByClassName('subtitle'); + for (let i = 0; i < subtitles.length; i++) { + subtitles[i].onclick = handleSubtitleClick; + } + } // @license-end -- cgit v1.2.3 From 48096e4d2341c1a439e80515f3f6334cb27f59c4 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 01:15:22 -0500 Subject: Add scroll --- templates/page.tmpl | 1 + 1 file changed, 1 insertion(+) (limited to 'templates') diff --git a/templates/page.tmpl b/templates/page.tmpl index a764202d..0ccf7af6 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -94,6 +94,7 @@ let videoElem = document.getElementById(video); if (videoElem) { videoElem.currentTime = parseSeconds(start); + videoElem.scrollIntoView(); } } -- cgit v1.2.3 From 612cda9b315d38d9e7de4581465e775ca636a080 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 22:47:26 -0500 Subject: Tweak transcripts --- templates/subtitle.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md index b9e0ba9d..167e1126 100644 --- a/templates/subtitle.md +++ b/templates/subtitle.md @@ -1 +1,3 @@ - \ No newline at end of file + + +[] \ No newline at end of file -- cgit v1.2.3 From ba7005fa44a64ed4f968f945cac789a77ec93bc5 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 28 Jan 2021 12:23:12 -0500 Subject: Test explicit link --- templates/subtitle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md index 167e1126..eb2e21aa 100644 --- a/templates/subtitle.md +++ b/templates/subtitle.md @@ -1,3 +1,3 @@ -[] \ No newline at end of file +[] " data-video=""> \ No newline at end of file -- cgit v1.2.3 From f6ce612f2eacaa24d28b4ea7898f7660e0071cc1 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 28 Jan 2021 12:24:05 -0500 Subject: Fix link --- templates/subtitle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md index eb2e21aa..293147bb 100644 --- a/templates/subtitle.md +++ b/templates/subtitle.md @@ -1,3 +1,3 @@ -[] " data-video=""> \ No newline at end of file +[] " data-video=""> \ No newline at end of file -- cgit v1.2.3 From d61ee3c7ac6243127caa4b6e1dbfe389c455e527 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 28 Jan 2021 12:24:50 -0500 Subject: Fix subtitle --- templates/subtitle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/subtitle.md b/templates/subtitle.md index 293147bb..67906b4b 100644 --- a/templates/subtitle.md +++ b/templates/subtitle.md @@ -1,3 +1,3 @@ -[] " data-video=""> \ No newline at end of file +[] " data-video=""> \ No newline at end of file -- cgit v1.2.3