Added comments

This commit is contained in:
Lars van Hijfte
2017-01-26 11:31:15 +01:00
parent 95ee91748f
commit 8fb8df075f
5 changed files with 61 additions and 156 deletions

View File

@@ -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");

View File

@@ -1,25 +1,19 @@
$(document).ready(function() {
// Toggle menu
$("#own-profile-picture").click(function() {
if ($("#notification-center").css('right') == "-256px") {
$(".content").animate({
marginRight: "256px"
}, 500);
$(".chat-right").animate({
width: $(".chat-right").width() - 266
}, 500);
$("#notification-center").animate({
right: "0px"
}, 500);
// Make the menu visible and move the content to the left.
$("#chat-history").width("calc(100% - 587px)");
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
} else {
$(".chat-right").animate({
width: $(".chat-right").width() + 266
}, 500);
$(".content").animate({
marginRight: "0px"
}, 500);
$("#notification-center").animate({
right: "-256px"
}, 500);
// Make the menu invisible and move the content to the right.
$("#chat-history").width("calc(100% - 331px)");
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("right", "-256px");
}
});
});

View File

@@ -1,49 +1,28 @@
var menuFriendsData;
var menuGroupsData;
var notificationMessagesData;
var notificationRequestsData;
$(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);
loadNotificationFriends();
loadUnreadMessages();
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) {
$.post(
"API/loadFriends.php",
@@ -51,16 +30,18 @@ function loadMenuFriends(limit) {
limit: 5
}
).done(function(data) {
if (menuFriendsData != data) {
menuFriendsData = data;
if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
$("#friends-menu-section").show();
} else {
$("#friends-menu-section").hide();
}
}
});
setTimeout(loadMenuFriends, 3000, limit);
}
// Get, every 3 seconds, the groups and insert them in the menu.
function loadMenuGroups() {
$.post(
"API/loadGroups.php",
@@ -68,41 +49,45 @@ function loadMenuGroups() {
limit: 5
}
).done(function(data) {
if (menuGroupsData != data) {
menuGroupsData = data;
if (showGroups(data, "#menu-groups-list")) {
$("#groups-menu-section").show();
} else {
$("#groups-menu-section").hide();
}
}
});
setTimeout(loadMenuGroups, 3000);
}
// Get, every 3 seconds, the friends requests and insert them in the notification center.
function loadNotificationFriends() {
$.post(
"API/loadFriendRequest.php"
).done(function(data) {
if (notificationRequestsData != data) {
notificationRequestsData = data;
if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
$("#friend-request-section").show();
} else {
$("#friend-request-section").hide();
}
}
});
setTimeout(loadNotificationFriends, 3000);
}
// Get, every 3 seconds, the unread messages and insert them in the notification center.
function loadUnreadMessages() {
$.post(
"API/loadChatNotifications.php"
).done(function(data) {
if (notificationMessagesData != data) {
notificationMessagesData = data;
if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
console.log(data);
$("#unread-messages-section").show();
} else {
$("#unread-messages-section").hide();
}
});
setTimeout(loadUnreadMessages, 3000);
}
});
}

View File

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

View File

@@ -7,7 +7,7 @@
</section>
<section id="friend-request-section">
<h4>
Vriendchapsverzoeken
Verzoeken
</h4>
<ul class="nav-list" id="friend-requests-list">