Merge branch 'lars' into 'master'

Lars

See merge request !137
This commit was merged in pull request #141.
This commit is contained in:
Lars van Hijfte
2017-01-27 12:23:04 +01:00
5 changed files with 61 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
var previousDate = new Date("1970-01-01 00:00:00");
$(document).ready(function() { $(document).ready(function() {
loadMessages(); loadMessages();
sayEmpty(); sayEmpty();
@@ -31,13 +33,25 @@ function sendMessage() {
} }
function addMessages(messages) { 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()) { if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self"; type = "chat-message-self";
} else { } else {
type = "chat-message-other"; type = "chat-message-other";
} }
if (thisDate > previousDate) {
console.log(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('\ $("#chat-history").append('\
<div class="chat-message"> \ <div class="chat-message"> \
<div class="' + type + '">\ <div class="' + type + '">\

View File

@@ -1,5 +1,4 @@
$(document).ready(function() { $(document).ready(function() {
// Toggle menu // Toggle menu
$("#own-profile-picture, #open-notifications").click(function() { $("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('right') == "-256px") { if ($("#notification-center").css('right') == "-256px") {
@@ -8,12 +7,22 @@ $(document).ready(function() {
$(".modal").width("calc(100% - 512px)"); $(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px"); $(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px"); $("#notification-center").css("right", "0px");
// Add cookie so the menu stays open on other pages
document.cookie = "menu=open; path=/";
} else { } else {
// Make the menu invisible and move the content to the right. // Make the menu invisible and move the content to the right.
$("#chat-history").width("calc(100% - 331px)"); $("#chat-history").width("calc(100% - 331px)");
$(".modal").width("calc(100% - 256px)"); $(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px"); $(".content").css("margin-right", "0px");
$("#notification-center").css("right", "-256px"); $("#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,17 @@
var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"];
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
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) { function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value }) $.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() { .done(function() {

View File

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

View File

@@ -1,3 +1,8 @@
body {
overflow: hidden;
}
/* Overall chat-screen */ /* Overall chat-screen */
.chat { .chat {
position: fixed; position: fixed;
@@ -37,6 +42,22 @@
} }
/* Chat-message takes the whole width of the chat area */ /* Chat-message takes the whole width of the chat area */
.day-message {
width: 100%;
min-height: 40px;
padding: 10px 0;
clear: both;
text-align: center;
}
.day-message-content {
width: auto;
padding: 10px;
background-color: #F8F8F8;
color: #666;
}
.chat-message { .chat-message {
width: 100%; width: 100%;
min-height: 40px; min-height: 40px;