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(
this.view.videoPlayer.skipAhead(seek.value); "input",
}.bind(this)); function () {
this.view.videoPlayer.skipAhead(seek.value);
}.bind(this)
);
document.addEventListener("keyup", function (e) { document.addEventListener(
if (e.keyCode == 32) { "keyup",
this.view.videoPlayer.togglePlay(); function (e) {
} if (e.keyCode == 32) {
}.bind(this)); this.view.videoPlayer.togglePlay();
}
}.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.view.activateComment(null); this.activeComment = null;
this.view.activateCommentText(null); }
}
if (this.activeComment !== this.lastActiveComment) {
this.view.activateComment(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;
} }
} }