diff --git a/website/public/API/getPosts.php b/website/public/API/getPosts.php new file mode 100644 index 0000000..eef8261 --- /dev/null +++ b/website/public/API/getPosts.php @@ -0,0 +1,24 @@ +fetchAll(PDO::FETCH_ASSOC); + +for($i = 0; $i < sizeof($results); $i++) { + $results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]); +} + +//$results[0]["niceTime"] = nicetime($results[0]["creationdate"]); + +echo json_encode($results); \ No newline at end of file diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 3b872ba..0b31443 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -11,12 +11,10 @@ function scrollbarMargin(width, overflow) { }); } -function requestPost(post) { +function requestPost(postID) { $(".modal").show(); - $.get( - "API/loadPost.php", - $(post).children("form").serialize() - ).done(function (data) { + + $.get("API/loadPost.php", { postID : postID }).done(function(data) { $('.modal-default').hide(); var scrollBarWidth = window.innerWidth - document.body.offsetWidth; scrollbarMargin(scrollBarWidth, 'hidden'); @@ -26,37 +24,54 @@ function requestPost(post) { } $(window).on("load", function() { - console.log("LOADED"); - container = $("div.posts"); - posts = container.children(); - posts.remove(); - - column = $('
').append(posts); - container.append(column); - - mansonry(); - mansonry(); + $(".modal-close").click(function () { + $(".modal").hide(); + scrollbarMargin(0, 'auto'); + $('#modal-response').hide(); + $('.modal-default').show(); + }); }); +var masonryMode = 0; + $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizeFinished = setTimeout(function() { - mansonry(); + masonry(masonryMode); }, 250); }); -function mansonry() { +var $container = $(".posts"); +function masonry(mode) { + masonryMode = mode; + $container.children().remove(); columnCount = Math.floor($(".posts").width() / 250); - console.log("columns: " + columnCount); /* * Initialise columns. */ var columns = new Array(columnCount); + var $columns = new Array(columnCount); for (i = 0; i < columnCount; i++) { - columns[i] = [0, []]; - console.log(columns[i]); + $column = $("
"); + $column.width(100/columnCount + "%"); + $container.append($column); + columns[i] = [0, $column]; + } + + if(mode == 1) { + $postInput = $("
"); + $form = $postInput.append($("
")); + + $form.append($("")); + $form.append($(" - -
-
- fetch()) { - $nicetime = nicetime($post["creationdate"]); - $postID = $post["postID"]; - echo " -
-

${post["title"]}

-

${post["content"]}

-

${nicetime} geplaatst.

-
- -
-
- "; - } - ?> + + + + + + + + +fetch()) { +// $nicetime = nicetime($post["creationdate"]); +// echo " +//
+//

${post["title"]}

+//

${post["content"]}

+//

${nicetime} geplaatst.

+//
+// "; +// } +// ?> + + + + + + + + +fetch()) { +// $nicetime = nicetime($post["creationdate"]); +// $postID = $post["postID"]; +// echo " +//
+//

${post["title"]}

+//

${post["content"]}

+//

${nicetime} geplaatst.

+//
+// +//
+//
+// "; +// } +// ?>