Merge branch 'master' into hendrik-testing

This commit is contained in:
Hendrik
2017-01-27 16:15:42 +01:00
33 changed files with 901 additions and 573 deletions

View File

@@ -1,3 +1,5 @@
var previousDate = new Date("1970-01-01 00:00:00");
$(document).ready(function() {
loadMessages();
sayEmpty();
@@ -31,17 +33,28 @@ function sendMessage() {
}
function addMessages(messages) {
for(i in messages) {
for(var i in messages) {
thisDate = new Date(messages[i].creationdate);
thisDate.setHours(0,0,0,0);
if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self";
} else {
type = "chat-message-other";
}
if (thisDate > previousDate) {
previousDate = thisDate;
$("#chat-history").append('\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>\
');
}
$("#chat-history").append('\
<div class="chat-message"> \
<div class="' + type + '">\
' + messages[i].content + '\
' + fancyText(messages[i].content) + '\
</div> \
</div>\
');
@@ -49,6 +62,7 @@ function addMessages(messages) {
}
function switchUser(userID) {
previousDate = new Date("1970-01-01 00:00:00");
$(".chat-field").show();
$(".destinationID").val(userID);
$("#chat-history").html("");

View File

@@ -1,5 +1,4 @@
$(document).ready(function() {
// Toggle menu
$("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('right') == "-256px") {
@@ -8,12 +7,22 @@ $(document).ready(function() {
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
// Add cookie so the menu stays open on other pages
document.cookie = "menu=open; path=/";
} else {
// Make the menu invisible and move the content to the right.
$("#chat-history").width("calc(100% - 331px)");
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("right", "-256px");
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
});
if (getCookie("menu") == "open") {
$("#own-profile-picture").click();
}
});

View File

@@ -1,3 +1,34 @@
var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"];
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
function fancyText(text) {
// Add images and gifs.
var regex = /(https:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig;
text = text.replace(regex, function(img) {
return "<img src='" + img + "' />";
});
// Add links.
// regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig;
// text = text.replace(regex, function(link) {
// return "<a href='" + link + "'>LINK</a>";
// });
return text;
}
function getCookie(key) {
cookies = document.cookie.split("; ");
for (var i in cookies) {
cookie = cookies[i].split("=");
if (cookie[0] == key) {
return cookie[1];
}
}
return false;
}
function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() {

View File

@@ -70,9 +70,7 @@ function masonry(mode) {
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
columns[0][1].append($postInput);
$postInput.on("load", function() {
columns[0][0] = $postInput.height() + margin;
});
columns[0][0] = $postInput.height() + margin;
}
/*
@@ -99,11 +97,12 @@ function masonry(mode) {
/*
* Rearange the objects.
*/
jQuery.each(posts, function() {
$.each(posts, function() {
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
$post.append($("<h2>").text(this["title"]));
$post.append($("<h2>").html(this["title"]));
$post.append($("<p>").html(this["content"]));
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);

View File

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

View File

@@ -1,5 +1,5 @@
function checkLoggedIn() {
if (confirm("You are already logged in!\nDo you want to logout?\nPress ok to logout.") == true) {
if (confirm("U bent al ingelogd!!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
window.location.href = "logout.php";
} else {
window.location.href = "profile.php";
@@ -7,9 +7,9 @@ function checkLoggedIn() {
}
function bannedAlert(){
alert("Your account is banned");
alert("Uw account is geband!");
}
function emailNotConfirmed(){
alert("Your account has not been verified yet!\nAnother email has been sent to you")
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
}

View File

@@ -8,7 +8,6 @@ function searchUsers(n, m) {
filter: $("#search-filter").val()
}
).done(function(data) {
console.log(data);
if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) {
$("#search-users-list").text("Niemand gevonden");
}
@@ -25,7 +24,6 @@ function searchGroups(n, m) {
filter: $("#search-filter").val()
}
).done(function(data) {
console.log(data);
if (!showGroups(data, "#search-groups-list")) {
$("#search-groups-list").text("Geen groepen gevonden");
}