Display user likes

This commit is contained in:
Pierre HUBERT 2019-01-14 21:12:06 +01:00
parent 64ead89601
commit 4a24d5249c
3 changed files with 50 additions and 1 deletions

View File

@ -122,8 +122,27 @@
</table>
</div>
<!-- All user likes -->
<div id="likes" class="category container">
Loading likes
<h1>All your likes</h1>
<table id="all-likes-table">
<thead>
<tr>
<th>Number</th>
<th>Date</th>
<th>Element type</th>
<th>Element ID</th>
</tr>
</thead>
<tbody>
<!-- Likes will go here-->
</tbody>
</table>
</div>
<div id="survey-responses" class="category container">
@ -152,6 +171,7 @@
<script src="assets/js/categories/friends.js"></script>
<script src="assets/js/categories/posts.js"></script>
<script src="assets/js/categories/comments.js"></script>
<script src="assets/js/categories/likes.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,28 @@
/**
* Likes category
*
* @author Pierre HUBERT
*/
/**
* Apply all user likes
*/
function ApplyUserLikes() {
let target = document.querySelector("#all-likes-table tbody");
data.likes.forEach(like => {
createElem2({
appendTo: target,
type: "tr",
innerHTML:
"<td>" + like.id + "</td>" +
"<td>" + timeToStr(like.time_sent) + "</td>" +
"<td>" + like.elem_type + "</td>" +
"<td>" + like.elem_id + "</td>"
});
});
}

View File

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