Merge branch 'lars' into 'master'

Lars

See merge request !142
This commit was merged in pull request #146.
This commit is contained in:
Lars van Hijfte
2017-01-27 16:05:11 +01:00
3 changed files with 23 additions and 2 deletions

View File

@@ -42,7 +42,6 @@ function addMessages(messages) {
type = "chat-message-other"; type = "chat-message-other";
} }
if (thisDate > previousDate) { if (thisDate > previousDate) {
console.log(previousDate);
previousDate = thisDate; previousDate = thisDate;
$("#chat-history").append('\ $("#chat-history").append('\
<div class="day-message"> \ <div class="day-message"> \
@@ -55,7 +54,7 @@ function addMessages(messages) {
$("#chat-history").append('\ $("#chat-history").append('\
<div class="chat-message"> \ <div class="chat-message"> \
<div class="' + type + '">\ <div class="' + type + '">\
' + messages[i].content + '\ ' + fancyText(messages[i].content) + '\
</div> \ </div> \
</div>\ </div>\
'); ');
@@ -63,6 +62,7 @@ function addMessages(messages) {
} }
function switchUser(userID) { function switchUser(userID) {
previousDate = new Date("1970-01-01 00:00:00");
$(".chat-field").show(); $(".chat-field").show();
$(".destinationID").val(userID); $(".destinationID").val(userID);
$("#chat-history").html(""); $("#chat-history").html("");

View File

@@ -1,6 +1,23 @@
var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"]; var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"];
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] 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) { function getCookie(key) {
cookies = document.cookie.split("; "); cookies = document.cookie.split("; ");
for (var i in cookies) { for (var i in cookies) {

View File

@@ -127,3 +127,7 @@ body {
background: #4CAF50; background: #4CAF50;
color: white; color: white;
} }
.chat-message img {
max-width: 100%;
}