Made small improvements to friendship buttons and corresponding API files.
This commit is contained in:
@@ -44,42 +44,12 @@ include("../views/profile.php");
|
||||
include("../views/footer.php");
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
<script src="js/friendButtons.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
userID = <?= $userID ?>;
|
||||
placeFriendButtons();
|
||||
});
|
||||
|
||||
function placeFriendButtons() {
|
||||
$.post("API/getFriendshipStatus.php", { usr: userID })
|
||||
.done(function(data) {
|
||||
friendshipStatus = data;
|
||||
$buttonContainer = $("div.friend-button-container");
|
||||
$buttonContainer.children().remove();
|
||||
if (friendshipStatus == -1) {
|
||||
return;
|
||||
} else if(friendshipStatus == 0) {
|
||||
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
|
||||
} else if(friendshipStatus == 1) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
|
||||
} else if(friendshipStatus == 2) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
|
||||
} else if(friendshipStatus == 3) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Weiger</button>"));
|
||||
$buttonContainer.append($("<button class=\"green friend-button\" value=\"accept\"><i class=\"fa fa-check\"></i> Accepteer</button>"));
|
||||
}
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
$.post("API/editFriendship.php", { usr: userID, action: this.value })
|
||||
.done(function() {
|
||||
placeFriendButtons();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user