FINALLY FIXED THE UNREAD CHAT MESSAGES!

This commit is contained in:
Lars van Hijfte
2017-01-24 14:26:15 +01:00
parent c4e4508b53
commit a88483ae47
12 changed files with 167 additions and 39 deletions

View File

@@ -53,8 +53,8 @@ function switchUser(userID) {
$(".destinationID").val(userID);
$("#chat-history").html("");
$("#lastID").val("");
$(".chat-left .friend-item").removeClass("active-friend-chat");
$(".chat-left #friend-item-" + userID).addClass("active-friend-chat");
$("#chat-recent-panel .friend-item").removeClass("active-friend-chat");
$("#chat-left #friend-item-" + userID).addClass("active-friend-chat");
}
function sayEmpty() {

View File

@@ -1,7 +1,7 @@
function showNotifications(notifications, id) {
$("#" + id).html("");
function showFriendNotifications(notifications) {
$("#friendrequestslist").html("");
for (i in notifications) {
$("#" + id).append(" \
$("#friendrequestslist").append(" \
<li class='friend-item $extraItem'> \
<form action='profile.php' method='get'> \
<button type='submit' \
@@ -18,19 +18,42 @@ function showNotifications(notifications, id) {
}
}
function showChatNotifications(notifications) {
$("#unreadChatlist").html("");
for (i in notifications) {
$("#unreadChatlist").append(" \
<li class='friend-item $extraItem'> \
<form action='chat.php' method='get'> \
<button type='submit' \
name='username' \
value='"+ notifications[i].userID +"'> \
<div class='friend'> \
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
<div class='friend-name'> \
"+ notifications[i].name +"<br/> \
<span style='color: #666'>"+ notifications[i].content +"</span> \
</div> \
</div> \
</button> \
</form> \
</li> \
");
}
}
function loadNotifications() {
$.post(
"API/loadFriendRequestNotifications.php"
).done(function(data) {
if (data && data != "[]") {
showNotifications(JSON.parse(data), "friendrequestslist");
showFriendNotifications(JSON.parse(data));
}
});
$.post(
"API/loadChatNotifications.php"
).done(function(data) {
if (data && data != "[]") {
showNotifications(JSON.parse(data), "unreadChatlist");
showChatNotifications(JSON.parse(data));
}
});