@@ -1,8 +1,12 @@
|
||||
class Comment {
|
||||
constructor(start, end, text, fulltext) {
|
||||
constructor(start, end, tittle, text) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.text = text;
|
||||
this.fulltext = fulltext;
|
||||
this.tittle = tittle;
|
||||
this.text = [];
|
||||
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
this.text.push(text[i].innerHTML);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Controller {
|
||||
init(videoToLoad) {
|
||||
this.loadXml(videoToLoad).then(
|
||||
function (v) {
|
||||
this.view.drawCommentsText(v);
|
||||
this.view.drawCommentTittles(v);
|
||||
this.addEventListeners();
|
||||
this.view.drawCommentsToVideo(v);
|
||||
}.bind(this)
|
||||
@@ -145,9 +145,17 @@ class Controller {
|
||||
|
||||
if (this.activeComment !== null) {
|
||||
this.view.activateComment(this.activeComment);
|
||||
this.view.activateCommentText(
|
||||
this.model.comments[this.activeComment].fulltext
|
||||
);
|
||||
console.log(this.model.comments[this.activeComment].text.length);
|
||||
|
||||
for (
|
||||
let i = 0;
|
||||
i < this.model.comments[this.activeComment].text.length;
|
||||
i++
|
||||
) {
|
||||
this.view.activateCommentText(
|
||||
this.model.comments[this.activeComment].text[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.lastActiveComment = this.activeComment;
|
||||
|
||||
@@ -11,10 +11,10 @@ class Model {
|
||||
for (let i = 0; i < comment.length; i++) {
|
||||
let start = comment[i].getElementsByTagName("start")[0].innerHTML;
|
||||
let end = comment[i].getElementsByTagName("end")[0].innerHTML;
|
||||
let text = comment[i].getElementsByTagName("text")[0].innerHTML;
|
||||
let fulltext = comment[i].getElementsByTagName("fulltext")[0].innerHTML;
|
||||
let tittle = comment[i].getElementsByTagName("tittle")[0].innerHTML;
|
||||
let text = comment[i].getElementsByTagName("text");
|
||||
|
||||
this.comments.push(new Comment(start, end, text, fulltext));
|
||||
this.comments.push(new Comment(start, end, tittle, text));
|
||||
}
|
||||
|
||||
return this.comments;
|
||||
|
||||
19
js/view.js
19
js/view.js
@@ -21,7 +21,7 @@ class View {
|
||||
); */
|
||||
}
|
||||
|
||||
drawCommentsText(comments) {
|
||||
drawCommentTittles(comments) {
|
||||
let aside = document.getElementsByTagName("aside")[0];
|
||||
|
||||
for (let i = 0; i < comments.length; i++) {
|
||||
@@ -49,11 +49,11 @@ class View {
|
||||
|
||||
comment.appendChild(time);
|
||||
|
||||
let commentText = document.createElement("div");
|
||||
commentText.setAttribute("class", "commentText");
|
||||
commentText.innerHTML = comments[i].text;
|
||||
let commentTittle = document.createElement("div");
|
||||
commentTittle.setAttribute("class", "commentText");
|
||||
commentTittle.innerHTML = comments[i].tittle;
|
||||
|
||||
comment.appendChild(commentText);
|
||||
comment.appendChild(commentTittle);
|
||||
|
||||
aside.appendChild(comment);
|
||||
|
||||
@@ -120,7 +120,14 @@ class View {
|
||||
activateCommentText(text) {
|
||||
let textArea = document.getElementsByTagName("article")[0];
|
||||
|
||||
textArea.innerHTML = text;
|
||||
if (text == null) {
|
||||
textArea.innerHTML = text;
|
||||
return;
|
||||
}
|
||||
|
||||
let div = document.createElement("div");
|
||||
div.innerHTML = text;
|
||||
textArea.append(div);
|
||||
}
|
||||
|
||||
commentHover(c, active = true) {
|
||||
|
||||
Reference in New Issue
Block a user