diff --git a/website/public/js/chat.js b/website/public/js/chat.js
index 773a819..014d723 100644
--- a/website/public/js/chat.js
+++ b/website/public/js/chat.js
@@ -1,25 +1,31 @@
var previousDate = new Date("1970-01-01 00:00:00");
+var previousTime = "00:00";
+var gettingMessages = false;
+var previousType = "robot";
$(document).ready(function() {
- loadMessages();
+ setInterval(loadMessages, 1000);
sayEmpty();
$(".chat-field").hide();
});
function loadMessages() {
- $.post(
- "API/loadMessages.php",
- $("#lastIDForm").serialize()
- ).done(function(data) {
- if (data && data != "[]") {
- messages = JSON.parse(data);
- addMessages(messages);
- $("#lastID").val(messages[messages.length - 1].messageID);
- $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight);
- }
- });
-
- setTimeout(loadMessages, 1000);
+ if (!gettingMessages) {
+ gettingMessages = true;
+ $.post(
+ "API/loadMessages.php",
+ $("#lastIDForm").serialize()
+ ).done(function (data) {
+ if (data && data != "[]") {
+ messages = JSON.parse(data);
+ addMessages(messages);
+ $("#lastID").val(messages[messages.length - 1].messageID);
+ }
+ gettingMessages = false;
+ });
+ } else {
+ setTimeout(loadMessages, 500);
+ }
}
@@ -30,35 +36,55 @@ function sendMessage() {
);
$("#newContent").val("");
+ loadMessages();
}
function addMessages(messages) {
+ var messagesText = "";
for(var i in messages) {
- thisDate = new Date(messages[i].creationdate);
+ // Initialize message variables
+ var thisDate = new Date(messages[i].creationdate);
+ var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
+ var type;
thisDate.setHours(0,0,0,0);
+
if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self";
} else {
type = "chat-message-other";
}
- if (thisDate > previousDate) {
+ if (i == 0) {
+ messagesText += '
';
+ } else if (type != previousType || thisTime != previousTime || thisDate > previousDate) {
+ messagesText += '
\
+ ' + thisTime + '\
+
';
+
previousDate = thisDate;
- $("#chat-history").append('\
- \
-
\
- ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
-
\
-
\
- ');
+ previousTime = thisTime;
+ previousType = type;
+ if (thisDate > previousDate) {
+ messagesText += '\
+ \
+
\
+ ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
+
\
+
';
+ }
+
+ messagesText += '';
}
- $("#chat-history").append('\
-
\
-
\
- ' + fancyText(messages[i].content) + '\
-
\
-
\
- ');
+ messagesText += fancyText(messages[i].content) + "
";
}
+
+ // Close the last message
+ messagesText += '
\
+ ' + thisTime + '\
+
';
+
+ $("#chat-history").append(messagesText);
+
+ $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight);
}
function switchUser(userID) {
@@ -72,5 +98,5 @@ function switchUser(userID) {
}
function sayEmpty() {
- $("#chat-history").html("Begin nu met chatten!");
+ $("#chat-history").html("Probeer ook eens foto's en video's te sturen");
}
\ No newline at end of file
diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js
index bdc3cc8..d62e919 100644
--- a/website/public/js/friendButtons.js
+++ b/website/public/js/friendButtons.js
@@ -1,26 +1,73 @@
function placeFriendButtons() {
$.post("API/getFriendshipStatus.php", { usr: userID })
.done(function(data) {
- friendshipStatus = data;
- $buttonContainer = $("div.friend-button-container");
- $buttonContainer.children().remove();
- $("#start-profile-chat-form").hide();
- if (friendshipStatus == -1) {
- return;
- } else if(friendshipStatus == 0) {
- $buttonContainer.append($(""));
- } else if(friendshipStatus == 1) {
- $buttonContainer.append($(""));
- $("#start-profile-chat-form").show();
- } else if(friendshipStatus == 2) {
- $buttonContainer.append($(""));
- } else if(friendshipStatus == 3) {
- $buttonContainer.append($(""));
- $buttonContainer.append($(""));
- }
+ var friendshipStatus = data;
+ var $buttonContainer = $("div.friend-button-container");
+ $("#start-profile-chat").hide();
+ $buttonContainer.html("");
+ var value1 = "";
+ var class1 = "empty-button";
+ var icon1 = "";
+ var text1 = "";
+
+ var value2 = "";
+ var class2 = "empty-button";
+ var icon2 = "";
+ var text2 = "";
+
+ switch (friendshipStatus) {
+ case "0":
+ value1 = "request";
+ class1 = "green";
+ text1 = "Bevriend";
+ icon1 = "fa-handshake-o";
+ break;
+ case "1":
+ value1 = userID;
+ class1 = "green";
+ text1 = "Chat";
+ icon1 = "fa-comment-o";
+ value2 = "delete";
+ class2 = "red";
+ text2 = "Verwijder";
+ icon2 = "fa-times";
+ break;
+ case "2":
+ value1 = "delete";
+ class1 = "red";
+ text1 = "Trek verzoek in";
+ icon1 = "fa-cross";
+ break;
+ case "3":
+ value1 = "accept";
+ class1 = "green";
+ text1 = "Accepteer";
+ icon1 = "fa-check";
+ value2 = "delete";
+ class2 = "red";
+ text2 = "Weiger";
+ icon2 = "fa-times";
+ break;
+ default:
+ console.log(friendshipStatus);
+ break;
+ }
+
+ $buttonContainer.append(
+ "");
+ $buttonContainer.append(
+ "");
+
$buttonContainer.children().click(function() {
- editFriendship(userID, this.value);
+ if (isNaN(this.value))
+ editFriendship(userID, this.value);
+ else if (this.value != "")
+ window.location.href = "chat.php?username=" + this.value;
});
});
}
\ No newline at end of file
diff --git a/website/public/js/main.js b/website/public/js/main.js
index dfd6c38..d23bbbf 100644
--- a/website/public/js/main.js
+++ b/website/public/js/main.js
@@ -2,19 +2,39 @@ var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag",
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 "
";
+ // Add links, images, gifs and (youtube) video's.
+ var regex = /(https?:\/\/.[^ ]*)/ig;
+ text = text.replace(regex, function(link) {
+ // Add images
+ if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
+ return "
";
+ }
+ // Add mp4 video's
+ else if (link.match(/(https?:\/\/.[^ ]*\.(?:mp4))/ig)) {
+ return "";
+ }
+ // Add ogg video's
+ else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
+ return "";
+ }
+ // Add youtube video's
+ else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
+ return '';
+ }
+ // Add links
+ else {
+ return "" + link + "";
+ }
});
- // Add links.
- // regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig;
- // text = text.replace(regex, function(link) {
- // return "LINK";
- // });
-
return text;
}
diff --git a/website/public/styles/adminbutton.css b/website/public/styles/adminbutton.css
new file mode 100644
index 0000000..2a8fb2a
--- /dev/null
+++ b/website/public/styles/adminbutton.css
@@ -0,0 +1,3 @@
+#quick-links i {
+ font-size: 32px;
+}
\ No newline at end of file
diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css
index 0ba5af4..47b0639 100644
--- a/website/public/styles/chat.css
+++ b/website/public/styles/chat.css
@@ -130,4 +130,18 @@ body {
.chat-message img {
max-width: 100%;
+}
+
+.chat-message a {
+ text-decoration: underline;
+}
+
+.chat-time {
+ color: #666666;
+ font-size: 12px;
+ margin-bottom: -3px;
+}
+
+.chat-message-other .chat-time {
+ text-align: right;
}
\ No newline at end of file
diff --git a/website/public/styles/main.css b/website/public/styles/main.css
index 0c37afa..abb1604 100644
--- a/website/public/styles/main.css
+++ b/website/public/styles/main.css
@@ -97,16 +97,16 @@ p {
}
.item-box, .item-box-full-width {
- margin: 20px 0 0 0;
padding: 25px;
background-color: #FFFFFF;
}
.item-box {
- width: calc(50% - 60px);
+ width: calc(33% - 50px);
+ display: inline-table;
}
-@media only screen and (max-width: 900px) {
+@media only screen and (max-width: 1400px) {
.item-box {
width: calc(100% - 50px);
}
@@ -183,6 +183,10 @@ button.green {
background-color: forestgreen;
}
+button.gray{
+ background-color: #FFF;
+ color: #333;
+}
button,
input[type="submit"],
@@ -224,6 +228,7 @@ td {
/* Custom title box, appears instantaneously */
a[data-title]:hover,
+i[data-title]:hover,
img[data-title]:hover,
span[data-title]:hover,
div[data-title]:hover {
@@ -231,6 +236,7 @@ div[data-title]:hover {
}
a[data-title]:hover:after,
+i[data-title]:hover:after,
img[data-title]:hover:after,
span[data-title]:hover:after,
div[data-title]:hover:after {
diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css
index becbeca..03ab19f 100644
--- a/website/public/styles/profile.css
+++ b/website/public/styles/profile.css
@@ -1,15 +1,60 @@
-.profile-box {
- min-height: 150px;
- padding: 25px;
- background-color: #FFFFFF;
+/* New */
+
+.user-box {
+ text-align: center;
}
-.profile-box .profile-picture, .profile-box .group-picture {
+.status-buttons-container {
+ position: relative;
+ float: left;
+ width: 200px;
+ display: inline-block;
+}
+
+.friend-button-container {
+ position: relative;
+ float: right;
+ width: 200px;
+ display: inline-block;
+}
+
+.friend-button-container button, .status-buttons-container button {
+ display: block;
+
+ margin: 7px 0;
+ width: 200px;
+
+ font-size: 18px;
+}
+
+.empty-button {
+ background: none;
+ cursor: auto;
+}
+.empty-button:active {
+ box-shadow: none;
+}
+
+.profile-info {
+ display: inline-block;
+
+ min-width: 250px;
+ width: auto;
+ padding-top: 30px;
+}
+
+.main-picture {
+ position: relative;
+ border: #4CAF50 solid 5px;
+
+ display: inline-block;
width: 150px;
height: 150px;
- margin: 0 20px 20px 0;
+ margin-bottom: -45px;
}
+/* Old */
+
.profile-box h1.profile-username {
padding-top: 50px;
}
@@ -18,14 +63,12 @@
}
div.posts {
- padding-top: 20px;
width: calc(100% + 20px);
display: inline-flex;
}
div.posts div.post {
display: block;
- margin: 20px 0 0 0;
padding: 10px;
width: calc(100% - 40px);
cursor: pointer;
@@ -60,6 +103,12 @@ div.posts .post form textarea.newpost {
height: 100px;
}
+.post .post-date {
+ float: right;
+ color: #aaaaaa;
+ font-size: 0.8em;
+}
+
@media only screen and (max-width: 1500px) {
.post-box {
width: calc(50% - 68px);
@@ -72,23 +121,3 @@ div.posts .post form textarea.newpost {
width: calc(100% - 65px);
}
}
-
-.post .post-date {
- float: right;
- color: #aaaaaa;
- font-size: 0.8em;
-}
-
-button.friend-button {
- float: right;
- height: auto;
- padding: 10px;
- margin-left: 10px;
- border-radius: 5px;
- transition-duration: 250ms;
- cursor: pointer;
-}
-
-button.friend-button:hover {
- box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
-}
\ No newline at end of file
diff --git a/website/queries/friendship.php b/website/queries/friendship.php
index 8d71376..038752d 100644
--- a/website/queries/friendship.php
+++ b/website/queries/friendship.php
@@ -29,6 +29,12 @@ function selectLimitedFriends($userID, $limit) {
`friendship`.`user1ID` = `user`.`userID`) AND
`user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed'
+ ORDER BY
+ CASE
+ WHEN `friendship`.`user2ID` = `user`.`userID` THEN `friendship`.`chatLastVisted1`
+ WHEN `friendship`.`user1ID` = `user`.`userID` THEN `friendship`.`chatLastVisted2`
+ END
+ DESC
LIMIT :limitCount
");
diff --git a/website/queries/private_message.php b/website/queries/private_message.php
index 6f3abb5..430fddb 100644
--- a/website/queries/private_message.php
+++ b/website/queries/private_message.php
@@ -15,7 +15,7 @@ function getOldChatMessages($user2ID) {
`origin` = :user2 AND
`destination` = :user1
ORDER BY
- `messageID` ASC
+ `creationdate` ASC
");
$stmt->bindParam(":user1", $user1ID);
@@ -74,7 +74,7 @@ function getNewChatMessages($lastID, $destination) {
`destination` = :user1) AND
`messageID` > :lastID
ORDER BY
- `messageID` ASC
+ `creationdate` ASC
");
$stmt->bindParam(':user1', $_SESSION["userID"]);
diff --git a/website/queries/user.php b/website/queries/user.php
index e3bf758..6d93793 100644
--- a/website/queries/user.php
+++ b/website/queries/user.php
@@ -46,6 +46,7 @@ function selectUser($me, $other) {
`bio`,
`user`.`creationdate`,
`onlinestatus`,
+ `role`,
`fname`,
`lname`,
CASE `status` IS NULL
diff --git a/website/views/head.php b/website/views/head.php
index b6c2f21..eb86d56 100644
--- a/website/views/head.php
+++ b/website/views/head.php
@@ -5,7 +5,6 @@
-
";
+ }
+ ?>
+
diff --git a/website/views/profile.php b/website/views/profile.php
index 036cab4..fd00c1f 100644
--- a/website/views/profile.php
+++ b/website/views/profile.php
@@ -1,24 +1,41 @@