From d2c5282d65e2335985b1a39dceaf14fb4743f79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Z=C3=A1le=C5=A1=C3=A1k?= Date: Thu, 28 Jan 2021 18:18:44 +0100 Subject: [PATCH] added on click listeners on comments --- js/controller.js | 4 +++- js/video.js | 4 +--- js/view.js | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/js/controller.js b/js/controller.js index e08c5cc..d8b52b8 100644 --- a/js/controller.js +++ b/js/controller.js @@ -62,7 +62,9 @@ class Controller { ); const seek = document.getElementById("seek"); - seek.addEventListener("input", this.view.videoPlayer.skipAhead); + seek.addEventListener("input", function() { + this.view.videoPlayer.skipAhead(seek.value); + }.bind(this)); document.addEventListener("keyup", function (e) { if (e.keyCode == 32) { diff --git a/js/video.js b/js/video.js index f373ab8..a38307d 100644 --- a/js/video.js +++ b/js/video.js @@ -26,12 +26,10 @@ class VideoPlayer { } } // Posouvání ve videu - skipAhead() { + skipAhead(skipTo) { const progressBar = document.getElementById("progress-bar"); const video = document.getElementById("video"); - let skipTo = this.value; - video.currentTime = skipTo; progressBar.value = skipTo; } diff --git a/js/view.js b/js/view.js index 56e9d90..1e461db 100644 --- a/js/view.js +++ b/js/view.js @@ -56,6 +56,13 @@ class View { comment.appendChild(commentText); aside.appendChild(comment); + + comment.addEventListener( + "click", + function () { + this.videoPlayer.skipAhead(comments[i].start); + }.bind(this) + ); } } @@ -80,6 +87,13 @@ class View { videoComment.appendChild(img); videoProgress.appendChild(videoComment); + + videoComment.addEventListener( + "click", + function () { + this.videoPlayer.skipAhead(comments[i].start); + }.bind(this) + ); } }