Friends and friendrequest are fully ajax. Also added friend-item

This commit is contained in:
Lars van Hijfte
2017-01-25 16:17:46 +01:00
parent 93ddefa42f
commit 91fae80326
13 changed files with 271 additions and 180 deletions

View File

@@ -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();
}
});