diff --git a/website/public/js/chat.js b/website/public/js/chat.js
index 2b2fe34..773a819 100644
--- a/website/public/js/chat.js
+++ b/website/public/js/chat.js
@@ -42,7 +42,6 @@ function addMessages(messages) {
type = "chat-message-other";
}
if (thisDate > previousDate) {
- console.log(previousDate);
previousDate = thisDate;
$("#chat-history").append('\
\
@@ -55,7 +54,7 @@ function addMessages(messages) {
$("#chat-history").append('\
\
\
- ' + messages[i].content + '\
+ ' + fancyText(messages[i].content) + '\
\
\
');
@@ -63,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("");
diff --git a/website/public/js/main.js b/website/public/js/main.js
index 587f020..dfd6c38 100644
--- a/website/public/js/main.js
+++ b/website/public/js/main.js
@@ -1,6 +1,23 @@
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 "

";
+ });
+
+ // Add links.
+ // regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig;
+ // text = text.replace(regex, function(link) {
+ // return "
LINK";
+ // });
+
+ return text;
+}
+
function getCookie(key) {
cookies = document.cookie.split("; ");
for (var i in cookies) {
diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css
index 600bb41..0ba5af4 100644
--- a/website/public/styles/chat.css
+++ b/website/public/styles/chat.css
@@ -126,4 +126,8 @@ body {
.active-friend-chat {
background: #4CAF50;
color: white;
+}
+
+.chat-message img {
+ max-width: 100%;
}
\ No newline at end of file