Hendrik testing #149

Merged
11342374 merged 27 commits from hendrik-testing into master 2017-01-27 16:16:10 +01:00
6 changed files with 23 additions and 12 deletions
Showing only changes of commit 3b542e0878 - Show all commits

View File

@@ -5,7 +5,8 @@ session_start();
require("../../queries/post.php"); require("../../queries/post.php");
require("../../queries/connect.php"); require("../../queries/connect.php");
require("../../queries/checkInput.php"); require("../../queries/checkInput.php");
if ($_POST["button"] == "reaction") { print_r($_POST);
if ($_POST['button'] == 'reaction') {
if (empty($_POST['newcomment-content'])) { if (empty($_POST['newcomment-content'])) {
echo 0; echo 0;
} else { } else {
@@ -17,7 +18,7 @@ if ($_POST["button"] == "reaction") {
echo 0; echo 0;
} }
} }
} elseif ($_POST["button"] == "nietslecht") { } else if ($_POST['button'] == 'nietslecht') {
if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) { if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) {
echo 1; echo 1;
} else { } else {

View File

@@ -1,7 +1,9 @@
function postComment() { function postComment(buttonValue) {
formData = $("#newcommentform").serializeArray();
formData.push({name: "button", value: buttonValue});
$.post( $.post(
"API/postComment.php", "API/postComment.php",
$("#newcommentform").serialize() formData
); );
$("#newcomment").val(""); $("#newcomment").val("");
@@ -13,6 +15,4 @@ function postComment() {
).done(function (data) { ).done(function (data) {
$('#modal-response').html(data); $('#modal-response').html(data);
}); });
} }

View File

@@ -8,6 +8,7 @@
<style> <style>
@import url("styles/profile.css"); @import url("styles/profile.css");
@import url("styles/post-popup.css"); @import url("styles/post-popup.css");
@import url('https://fonts.googleapis.com/css?family=Anton');
</style> </style>
</head> </head>
<body> <body>

View File

@@ -72,6 +72,6 @@
} }
.nietslecht { .nietslecht {
font-family: Impact, sans-serif; font-family: Impact, Anton, sans-serif;
text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black; text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black;
} }

View File

@@ -99,7 +99,7 @@ function makeComment($postID, $userID, $content) : int {
function makeNietSlecht(int $postID, int $userID) : int { function makeNietSlecht(int $postID, int $userID) : int {
if (checkNietSlecht($postID, $userID)) { if (checkNietSlecht($postID, $userID)) {
return deleteNietSlecht(postID, $userID); return deleteNietSlecht($postID, $userID);
} else { } else {
return addNietSlecht($postID, $userID); return addNietSlecht($postID, $userID);
} }

View File

@@ -2,6 +2,7 @@
$postID = $_GET['postID']; $postID = $_GET['postID'];
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC); $post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")"; $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
session_start();
echo(" echo("
<div class='post-header header'> <div class='post-header header'>
@@ -21,12 +22,20 @@ echo("
<div class='post-comments'> <div class='post-comments'>
<div class="commentfield"> <div class="commentfield">
<form id="newcommentform" action="javascript:postComment();"> <form id="newcommentform" onsubmit="return false;">
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>"> <input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br> <textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
<button type="submit" name="button" value="reaction">Reageer!</button> <button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button>
<!-- TODO: if/else op "niet slecht." button voor like/unlike--> <!-- TODO: if/else op "niet slecht." button voor like/unlike-->
<button type="submit" name="button" value="nietslecht">Vind ik <span class="nietslecht">"Niet slecht."</span></button> <button onclick="postComment('nietslecht')" name="button" value="nietslecht">
<?php
if (checkNietSlecht($postID, $_SESSION["userID"])) {
echo 'Vind ik <span class="nietslecht">"Niet slecht."</span>';
} else {
echo 'Trek <span class="nietslecht">"Niet slecht."</span> terug';
}
?>
</button>
</form> </form>
</div> </div>