Added comments
This commit is contained in:
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
require("../../queries/friendship.php");
|
|
||||||
require("../../queries/user.php");
|
|
||||||
|
|
||||||
if(empty($_POST["userID"]) OR empty($_POST["delete"]) AND empty($_POST["accept"]) AND empty($_POST["request"])) {
|
|
||||||
echo "Not enough arguments.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$friendship_status = getFriendshipStatus($_POST["userID"]);
|
|
||||||
echo "\nfriendshipstatus: $friendship_status";
|
|
||||||
echo "You: " . $_SESSION["userID"];
|
|
||||||
echo "other user: " . $_POST["userID"];
|
|
||||||
|
|
||||||
|
|
||||||
if(!empty($_POST["request"]) AND $friendship_status == 0) {
|
|
||||||
echo "request";
|
|
||||||
requestFriendship($_POST["userID"]);
|
|
||||||
} else if(!empty($_POST["delete"]) AND in_array($friendship_status, array(1, 2, 3))) {
|
|
||||||
echo "delete";
|
|
||||||
removeFriendship($_POST["userID"]);
|
|
||||||
} else if (!empty($_POST["accept"]) AND $friendship_status == 3) {
|
|
||||||
echo "accept";
|
|
||||||
acceptFriendship($_POST["userID"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$username = getUsername($_POST["userID"]);
|
|
||||||
|
|
||||||
header("Location: ../profile.php?username=$username");
|
|
||||||
@@ -1,25 +1,19 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
// Toggle menu
|
||||||
$("#own-profile-picture").click(function() {
|
$("#own-profile-picture").click(function() {
|
||||||
if($("#notification-center").css('right') == "-256px") {
|
if ($("#notification-center").css('right') == "-256px") {
|
||||||
$(".content").animate({
|
// Make the menu visible and move the content to the left.
|
||||||
marginRight: "256px"
|
$("#chat-history").width("calc(100% - 587px)");
|
||||||
}, 500);
|
$(".modal").width("calc(100% - 512px)");
|
||||||
$(".chat-right").animate({
|
$(".content").css("margin-right", "256px");
|
||||||
width: $(".chat-right").width() - 266
|
$("#notification-center").css("right", "0px");
|
||||||
}, 500);
|
|
||||||
$("#notification-center").animate({
|
|
||||||
right: "0px"
|
|
||||||
}, 500);
|
|
||||||
} else {
|
} else {
|
||||||
$(".chat-right").animate({
|
// Make the menu invisible and move the content to the right.
|
||||||
width: $(".chat-right").width() + 266
|
$("#chat-history").width("calc(100% - 331px)");
|
||||||
}, 500);
|
$(".modal").width("calc(100% - 256px)");
|
||||||
$(".content").animate({
|
$(".content").css("margin-right", "0px");
|
||||||
marginRight: "0px"
|
$("#notification-center").css("right", "-256px");
|
||||||
}, 500);
|
|
||||||
$("#notification-center").animate({
|
|
||||||
right: "-256px"
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,49 +1,28 @@
|
|||||||
|
var menuFriendsData;
|
||||||
|
var menuGroupsData;
|
||||||
|
var notificationMessagesData;
|
||||||
|
var notificationRequestsData;
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Show more friends/users
|
|
||||||
|
|
||||||
// Show more friends
|
|
||||||
// $("#more-friends-click").click(function() {
|
|
||||||
// // Show only friends
|
|
||||||
// $("#groups-menu-section").slideUp();
|
|
||||||
// $("#friends-menu-section li").show();
|
|
||||||
//
|
|
||||||
// // Change buttons
|
|
||||||
// $("#more-friends-click").hide();
|
|
||||||
// $("#menu-back").show();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // Show more groups
|
|
||||||
// $("#more-groups-click").click(function() {
|
|
||||||
// // Show only groups
|
|
||||||
// $("#friends-menu-section").slideUp();
|
|
||||||
// $("#groups-menu-section li").show();
|
|
||||||
//
|
|
||||||
// // Change buttons
|
|
||||||
// $("#more-groups-click").hide();
|
|
||||||
// $("#menu-back").show();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Go back
|
|
||||||
// $("#menu-back").click(function() {
|
|
||||||
// // Show overview of friends and groups
|
|
||||||
// $("#friends-menu-section").slideDown();
|
|
||||||
// $("#groups-menu-section").slideDown();
|
|
||||||
// $(".extra-menu-items").hide();
|
|
||||||
//
|
|
||||||
// // Change buttons
|
|
||||||
// $("#menu-back").hide();
|
|
||||||
// $("#more-groups-click").show();
|
|
||||||
// $("#more-friends-click").show();
|
|
||||||
// });
|
|
||||||
|
|
||||||
loadMenuFriends(5);
|
loadMenuFriends(5);
|
||||||
loadNotificationFriends();
|
loadNotificationFriends();
|
||||||
loadUnreadMessages();
|
loadUnreadMessages();
|
||||||
loadMenuGroups();
|
loadMenuGroups();
|
||||||
|
setInterval(updateMenus, 3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Update the menu and notification items.
|
||||||
|
function updateMenus() {
|
||||||
|
loadMenuFriends(5);
|
||||||
|
loadNotificationFriends();
|
||||||
|
loadUnreadMessages();
|
||||||
|
loadMenuGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get, every 3 seconds, the friends and insert them in the menu.
|
||||||
function loadMenuFriends(limit) {
|
function loadMenuFriends(limit) {
|
||||||
$.post(
|
$.post(
|
||||||
"API/loadFriends.php",
|
"API/loadFriends.php",
|
||||||
@@ -51,16 +30,18 @@ function loadMenuFriends(limit) {
|
|||||||
limit: 5
|
limit: 5
|
||||||
}
|
}
|
||||||
).done(function(data) {
|
).done(function(data) {
|
||||||
|
if (menuFriendsData != data) {
|
||||||
|
menuFriendsData = data;
|
||||||
if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
|
if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
|
||||||
$("#friends-menu-section").show();
|
$("#friends-menu-section").show();
|
||||||
} else {
|
} else {
|
||||||
$("#friends-menu-section").hide();
|
$("#friends-menu-section").hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(loadMenuFriends, 3000, limit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get, every 3 seconds, the groups and insert them in the menu.
|
||||||
function loadMenuGroups() {
|
function loadMenuGroups() {
|
||||||
$.post(
|
$.post(
|
||||||
"API/loadGroups.php",
|
"API/loadGroups.php",
|
||||||
@@ -68,41 +49,45 @@ function loadMenuGroups() {
|
|||||||
limit: 5
|
limit: 5
|
||||||
}
|
}
|
||||||
).done(function(data) {
|
).done(function(data) {
|
||||||
|
if (menuGroupsData != data) {
|
||||||
|
menuGroupsData = data;
|
||||||
if (showGroups(data, "#menu-groups-list")) {
|
if (showGroups(data, "#menu-groups-list")) {
|
||||||
$("#groups-menu-section").show();
|
$("#groups-menu-section").show();
|
||||||
} else {
|
} else {
|
||||||
$("#groups-menu-section").hide();
|
$("#groups-menu-section").hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(loadMenuGroups, 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get, every 3 seconds, the friends requests and insert them in the notification center.
|
||||||
function loadNotificationFriends() {
|
function loadNotificationFriends() {
|
||||||
$.post(
|
$.post(
|
||||||
"API/loadFriendRequest.php"
|
"API/loadFriendRequest.php"
|
||||||
).done(function(data) {
|
).done(function(data) {
|
||||||
|
if (notificationRequestsData != data) {
|
||||||
|
notificationRequestsData = data;
|
||||||
if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
|
if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
|
||||||
$("#friend-request-section").show();
|
$("#friend-request-section").show();
|
||||||
} else {
|
} else {
|
||||||
$("#friend-request-section").hide();
|
$("#friend-request-section").hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(loadNotificationFriends, 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get, every 3 seconds, the unread messages and insert them in the notification center.
|
||||||
function loadUnreadMessages() {
|
function loadUnreadMessages() {
|
||||||
$.post(
|
$.post(
|
||||||
"API/loadChatNotifications.php"
|
"API/loadChatNotifications.php"
|
||||||
).done(function(data) {
|
).done(function(data) {
|
||||||
|
if (notificationMessagesData != data) {
|
||||||
|
notificationMessagesData = data;
|
||||||
if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
|
if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
|
||||||
console.log(data);
|
|
||||||
$("#unread-messages-section").show();
|
$("#unread-messages-section").show();
|
||||||
} else {
|
} else {
|
||||||
$("#unread-messages-section").hide();
|
$("#unread-messages-section").hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(loadUnreadMessages, 3000);
|
|
||||||
}
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
// function showChatNotifications(notifications) {
|
|
||||||
// $("#unreadChatlist").html("");
|
|
||||||
// for (i in notifications) {
|
|
||||||
// $("#unreadChatlist").append(" \
|
|
||||||
// <li class='friend-item'> \
|
|
||||||
// <form action='chat.php' method='get'> \
|
|
||||||
// <button type='submit' \
|
|
||||||
// name='chatID' \
|
|
||||||
// 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/loadChatNotifications.php"
|
|
||||||
// ).done(function(data) {
|
|
||||||
// if (data && data != "[]") {
|
|
||||||
// $("#unread-messages-section").show();
|
|
||||||
// showChatNotifications(JSON.parse(data));
|
|
||||||
// } else {
|
|
||||||
// $("#unread-messages-section").hide();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// setTimeout(loadNotifications, 10000);
|
|
||||||
// }
|
|
||||||
// $(document).ready(function() {
|
|
||||||
// loadNotifications();
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
</section>
|
</section>
|
||||||
<section id="friend-request-section">
|
<section id="friend-request-section">
|
||||||
<h4>
|
<h4>
|
||||||
Vriendchapsverzoeken
|
Verzoeken
|
||||||
</h4>
|
</h4>
|
||||||
<ul class="nav-list" id="friend-requests-list">
|
<ul class="nav-list" id="friend-requests-list">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user