add unpolished post viewing

This commit is contained in:
Hendrik
2017-01-25 13:28:47 +01:00
parent b9fc016f7d
commit db333b6e98
7 changed files with 114 additions and 16 deletions

View File

@@ -0,0 +1,61 @@
<?php
require_once("../../queries/connect.php");
require_once("../../queries/post.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/nicetime.php");
if(isset($_GET['postID'])) {
$postID = $_GET['postID'];
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
echo "
<div class='post-header'>
<h4>" . $post['title'] . "</h4>
<span class='postinfo'>
gepost door $fullname,
<span class='posttime' title='" . $post['creationdate'] . "'>
" . nicetime($post['creationdate']) . "
</span>
</span>
</div>
<div class='post-content'>
<p>" . $post['content'] . "</p>
</div>
<div class='post-comments'>
<div class=\"commentfield\">
<form name=\"newcomment\" method=\"post\">
<textarea>Vul in</textarea> <br>
<input type=\"submit\" value=\"Reageer\">
</form>
</div>";
$q = selectCommentsByPostId($postID);
while($comment = $q->fetch(PDO::FETCH_ASSOC)) {
$commentauthor = $comment['fname'] . " " . $comment['lname'] . " (" . $comment['username'] . ")";
$commentdate = $comment['creationdate'];
$commentnicetime = nicetime($commentdate);
$commentcontent = $comment['content'];
echo("
<div class='comment'>
<div class='commentinfo'>
$commentauthor
<span class='commentdate', title='$commentdate'>
$commentnicetime
</span>
</div>
<div class='commentcontent'>
$commentcontent
</div>
</div>
");
}
echo "</div>";
} else {
echo "Failed to load";
}

View File

@@ -1,5 +1,21 @@
margin = 20; margin = 20;
function loadPost(postForm) {
$.get(
"API/loadPost.php",
$(postForm).serialize()
).done(function (data) {
console.log(data);
$('#modal-response').html(data);
});
}
function requestPost(post) {
$(".modal").show();
console.log($(post).children("form"));
loadPost($(post).children("form"));
}
$(window).on("load", function() { $(window).on("load", function() {
console.log("LOADED"); console.log("LOADED");
container = $("div.posts"); container = $("div.posts");
@@ -74,9 +90,11 @@ function mansonry() {
$("div.posts div.column").width(100/columnCount + "%"); $("div.posts div.column").width(100/columnCount + "%");
$(".post").click(function () { // $(".post").click(function () {
$(".modal").show(); // $(".modal").show();
}); // console.log("testerino");
// loadPost($(this).children("form.first"));
// });
$(".modal-close").click(function () { $(".modal-close").click(function () {
$(".modal").hide(); $(".modal").hide();

View File

@@ -0,0 +1,8 @@
function loadPost(postID) {
$.get(
"API/loadPost.php",
$(postID).serialize()
).done(function (data) {
$('#modal-response').innerHTML= JSON.parse(data);
});
}

View File

@@ -3,6 +3,7 @@
<head> <head>
<?php include("../views/head.php"); ?> <?php include("../views/head.php"); ?>
<script src="js/masonry.js"></script> <script src="js/masonry.js"></script>
<!-- <script src="js/profile.js"></script>-->
<style> <style>
@import url("styles/profile.css"); @import url("styles/profile.css");
@import url("styles/post-popup.css"); @import url("styles/post-popup.css");

View File

@@ -1,7 +1,7 @@
/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */ /* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
.modal { .modal {
/*display: none; !* Hidden by default *!*/ display: none; /* Hidden by default */
position: fixed; /* Stay in place */ position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */ z-index: 1; /* Sit on top */
left: 0; left: 0;

View File

@@ -1,19 +1,20 @@
<?php <?php
// $postID = $_GET['postID']; // $postID = $_GET['postID'];
$postID = 1; $postID = 10;
$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'] . ")";
?>
<div class="post-header"> echo "
<h4><?php echo $post['title'];?></h4> <div class='post-header'>
<span class="postinfo"> <h4>" . $post['title'] . "</h4>
gepost door <?php echo $fullname;?>, <span class='postinfo'>
<span class="posttime" title="<?php echo $post['creationdate']?>"> gepost door $fullname,
<?php echo nicetime($post['creationdate']); ?> <span class='posttime' title='" . $post['creationdate'] . "'>
" . nicetime($post['creationdate']) . "
</span> </span>
</span> </span>
</div> </div>"
?>
<div class="post-content"> <div class="post-content">
<p><?php echo $post['content']; ?></p> <p><?php echo $post['content']; ?></p>

View File

@@ -56,11 +56,18 @@
while($post = $posts->fetch()) { while($post = $posts->fetch()) {
$nicetime = nicetime($post["creationdate"]); $nicetime = nicetime($post["creationdate"]);
$postID = $post["postID"];
echo " echo "
<div class='post platform'> <div class='post platform' onclick='requestPost(this)'>
<h2>${post["title"]}</h2> <h2>${post["title"]}</h2>
<p>${post["content"]}</p> <p>${post["content"]}</p>
<p class=\"subscript\">${nicetime} geplaatst.</p> <p class=\"subscript\" title='" . $post["creationdate"] ."'>${nicetime} geplaatst.</p>
<form>
<input type='hidden'
name='postID'
value='$postID'
/>
</form>
</div> </div>
"; ";
} }
@@ -72,7 +79,9 @@
<div class="modal-close"> <div class="modal-close">
&times; &times;
</div> </div>
<?php include("../views/post-view.php"); ?> <div class="modal-response" id="modal-response">
Loading...
</div>
</div> </div>
</div> </div>
</div> </div>