Oprava bugu - caste prekreslovani

closes #7 a closes #6
pull/9/head
David Zálešák 4 years ago
parent d2c5282d65
commit a3d917f67c

@ -62,15 +62,21 @@ class Controller {
); );
const seek = document.getElementById("seek"); const seek = document.getElementById("seek");
seek.addEventListener("input", function() { seek.addEventListener(
"input",
function () {
this.view.videoPlayer.skipAhead(seek.value); this.view.videoPlayer.skipAhead(seek.value);
}.bind(this)); }.bind(this)
);
document.addEventListener("keyup", function (e) { document.addEventListener(
"keyup",
function (e) {
if (e.keyCode == 32) { if (e.keyCode == 32) {
this.view.videoPlayer.togglePlay(); this.view.videoPlayer.togglePlay();
} }
}.bind(this)); }.bind(this)
);
} }
async loadVideo(v) { async loadVideo(v) {
@ -101,16 +107,28 @@ class Controller {
for (let i = 0; i < this.model.comments.length; i++) { for (let i = 0; i < this.model.comments.length; i++) {
if ( if (
currentTime > this.model.comments[i].start && currentTime >= this.model.comments[i].start &&
currentTime < this.model.comments[i].end currentTime <= this.model.comments[i].end
) { ) {
this.view.activateComment(i); this.activeComment = i;
this.view.activateCommentText(this.model.comments[i].fulltext); break;
return; }
} else { if (i == this.model.comments.length - 1) {
this.activeComment = null;
}
}
if (this.activeComment !== this.lastActiveComment) {
this.view.activateComment(null); this.view.activateComment(null);
this.view.activateCommentText(null); this.view.activateCommentText(null);
if (this.activeComment !== null) {
this.view.activateComment(this.activeComment);
this.view.activateCommentText(
this.model.comments[this.activeComment].fulltext
);
} }
} }
this.lastActiveComment = this.activeComment;
} }
} }