Display all comments

This commit is contained in:
2019-01-14 21:01:44 +01:00
parent 59e6eb3c30
commit b48b6db028
4 changed files with 79 additions and 1 deletions

View File

@ -90,4 +90,13 @@ h1 {
.post .post-end-countdown {
text-align: center;
}
/**
* Comments rules
*/
#all-comments-table .comment-img {
width: 100%;
max-width: 350px;
}

View File

@ -0,0 +1,46 @@
/**
* Comments category
*
* @author Pierre HUBERT
*/
/**
* Apply full comments list
*/
function ApplyCommentsList() {
let target = document.querySelector("#all-comments-table tbody");
data.comments.forEach(comment => {
let commentEl = createElem2({
appendTo: target,
type: "tr",
innerHTML:
"<td>"+comment.ID+"</td>" +
"<td>"+comment.postID+"</td>" +
"<td>"+timeToStr(comment.time_sent)+"</td>" +
"<td>"+comment.content+"</td>"
});
if(comment.img_path != null){
let imageContainer = createElem2({
appendTo: commentEl,
type: "td"
});
let imageElem = createElem2({
appendTo: imageContainer,
type: "img",
class: "comment-img"
});
applyURLToImage(imageElem, comment.img_url);
}
});
}

View File

@ -76,6 +76,7 @@ xhr.onload = function(){
ApplyUserInfo();
ApplyFriendsList();
ApplyPosts();
ApplyCommentsList();
}
xhr.send(null);