Friends and friendrequest are fully ajax. Also added friend-item
This commit is contained in:
@@ -1,45 +1,3 @@
|
||||
function showFriendNotifications(notifications) {
|
||||
$("#friendrequestslist").html("");
|
||||
for (i in notifications) {
|
||||
var outgoing = "";
|
||||
if (notifications[i].friend_state == "3") {
|
||||
outgoing = "<button\
|
||||
name='accept' \
|
||||
class='accept-notification' \
|
||||
value='"+ notifications[i].userID +"'> \
|
||||
<i class='fa fa-check'></i> \
|
||||
</button>";
|
||||
}
|
||||
|
||||
$("#friendrequestslist").append(" \
|
||||
<li class='friend-item'> \
|
||||
<form action='profile.php' method='get'> \
|
||||
<button type='submit' \
|
||||
name='username' \
|
||||
value='"+ notifications[i].username +"'> \
|
||||
<div class='friend'> \
|
||||
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
|
||||
"+ notifications[i].username +" \
|
||||
</div> \
|
||||
</button> \
|
||||
</form> \
|
||||
<div class='notification-options'>\
|
||||
<form action='API/edit_friendship.php' method='post'> \
|
||||
<input type='hidden' name='userID' value='"+ notifications[i].userID +"' /> \
|
||||
"+ outgoing +" \
|
||||
<button type='submit' \
|
||||
name='delete' \
|
||||
class='deny-notification' \
|
||||
value='"+ notifications[i].userID +"'> \
|
||||
<i class='fa fa-times'></i> \
|
||||
</button>\
|
||||
<form>\
|
||||
</div> \
|
||||
</li> \
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
function showChatNotifications(notifications) {
|
||||
$("#unreadChatlist").html("");
|
||||
for (i in notifications) {
|
||||
@@ -64,18 +22,14 @@ function showChatNotifications(notifications) {
|
||||
}
|
||||
|
||||
function loadNotifications() {
|
||||
$.post(
|
||||
"API/loadFriendRequestNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
showFriendNotifications(JSON.parse(data));
|
||||
}
|
||||
});
|
||||
$.post(
|
||||
"API/loadChatNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
$("#unread-messages-section").show();
|
||||
showChatNotifications(JSON.parse(data));
|
||||
} else {
|
||||
$("#unread-messages-section").hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user