Kevin prototype #124
@@ -2,7 +2,6 @@
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"])) {
|
||||
|
||||
27
website/public/js/friendButtons.js
Normal file
27
website/public/js/friendButtons.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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