add unpolished post viewing
This commit is contained in:
61
website/public/API/loadPost.php
Normal file
61
website/public/API/loadPost.php
Normal 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";
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
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() {
|
||||
console.log("LOADED");
|
||||
container = $("div.posts");
|
||||
@@ -74,9 +90,11 @@ function mansonry() {
|
||||
|
||||
$("div.posts div.column").width(100/columnCount + "%");
|
||||
|
||||
$(".post").click(function () {
|
||||
$(".modal").show();
|
||||
});
|
||||
// $(".post").click(function () {
|
||||
// $(".modal").show();
|
||||
// console.log("testerino");
|
||||
// loadPost($(this).children("form.first"));
|
||||
// });
|
||||
|
||||
$(".modal-close").click(function () {
|
||||
$(".modal").hide();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
function loadPost(postID) {
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$(postID).serialize()
|
||||
).done(function (data) {
|
||||
$('#modal-response').innerHTML= JSON.parse(data);
|
||||
});
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<script src="js/masonry.js"></script>
|
||||
<!-- <script src="js/profile.js"></script>-->
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
|
||||
|
||||
.modal {
|
||||
/*display: none; !* Hidden by default *!*/
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
z-index: 1; /* Sit on top */
|
||||
left: 0;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
// $postID = $_GET['postID'];
|
||||
$postID = 1;
|
||||
$postID = 10;
|
||||
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
|
||||
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
|
||||
?>
|
||||
|
||||
<div class="post-header">
|
||||
<h4><?php echo $post['title'];?></h4>
|
||||
<span class="postinfo">
|
||||
gepost door <?php echo $fullname;?>,
|
||||
<span class="posttime" title="<?php echo $post['creationdate']?>">
|
||||
<?php echo nicetime($post['creationdate']); ?>
|
||||
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>"
|
||||
?>
|
||||
|
||||
<div class="post-content">
|
||||
<p><?php echo $post['content']; ?></p>
|
||||
|
||||
@@ -56,11 +56,18 @@
|
||||
|
||||
while($post = $posts->fetch()) {
|
||||
$nicetime = nicetime($post["creationdate"]);
|
||||
$postID = $post["postID"];
|
||||
echo "
|
||||
<div class='post platform'>
|
||||
<div class='post platform' onclick='requestPost(this)'>
|
||||
<h2>${post["title"]}</h2>
|
||||
<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>
|
||||
";
|
||||
}
|
||||
@@ -72,7 +79,9 @@
|
||||
<div class="modal-close">
|
||||
×
|
||||
</div>
|
||||
<?php include("../views/post-view.php"); ?>
|
||||
<div class="modal-response" id="modal-response">
|
||||
Loading...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user