Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Now showing date of messages in chat
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioDiaz98 committed Apr 3, 2019
1 parent 5394704 commit 329f5bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
18 changes: 14 additions & 4 deletions lib/commgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ class GroupCommunication {

for ( var i=0; i<messages.length; i++){
var mesg = messages[i].content;
var mesgToAdd = "";
var format = mesg.split(".");
var mesgToAdd = "";
var year = messages[i].dateTime.split("-")[0];
var month = messages[i].dateTime.split("-")[1];
var day = messages[i].dateTime.split("-")[2].split("T")[0];
var hourMinute = messages[i].dateTime.split("T")[1];
var hour = hourMinute.split(":")[0];
var minute = hourMinute.split(":")[1];
var dateToAdd = year + "-" + month + "-" + day + " - " + hour + ":" + minute;
console.log(dateToAdd);
var format = mesg.split(".");
if (format[format.length-1] == "jpg" || format[format.length-1] == "gif" || format[format.length-1] == "png"){
mesgToAdd = "<p><img src='" + mesg + "'></p>";
}else{
Expand All @@ -66,7 +74,8 @@ class GroupCommunication {
var toAppend = '<div class="incoming_msg" id="incoming_msg">'+
'<div class="received_msg">' +
'<div class="received_withd_msg" id="addOtherMessages">'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>';+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+'\n'+
'<span id="dateMessage" class="badge badge-secondary">' + dateToAdd +'</span>'+
'</div>'+
'</div>'+
'</div>';
Expand All @@ -78,7 +87,8 @@ class GroupCommunication {

var toAppend = '<div class="outgoing_msg" id="outgoing_msg">'+
'<div class="sent_msg" id="addOurMessages">'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+'\n'+
'<span id="dateMessage" class="badge badge-secondary">' + dateToAdd +'</span>'+
'</div>'+
'</div>';
if(!testing){
Expand Down
14 changes: 12 additions & 2 deletions lib/commprivate.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ class PrivateCommunication {
for ( var i=messages.length-1; i>=0; i--){
var mesg = messages[i].content;
var mesgToAdd = "";
var year = messages[i].dateTime.split("-")[0];
var month = messages[i].dateTime.split("-")[1];
var day = messages[i].dateTime.split("-")[2].split("T")[0];
var hourMinute = messages[i].dateTime.split("T")[1];
var hour = hourMinute.split(":")[0];
var minute = hourMinute.split(":")[1];
var dateToAdd = year + "-" + month + "-" + day + " - " + hour + ":" + minute;;
var format = mesg.split(".");
console.log(dateToAdd);
if (format[format.length-1] == "jpg" || format[format.length-1] == "gif" || format[format.length-1] == "png"){
mesgToAdd = "<p><img src='" + mesg + "'></p>";
}else{
Expand All @@ -121,7 +129,8 @@ class PrivateCommunication {
var toAppend = '<div class="incoming_msg" id="incoming_msg">'+
'<div class="received_msg">' +
'<div class="received_withd_msg" id="addOtherMessages">'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>';+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+'\n'+
'<span id="dateMessage" class="badge badge-secondary">' + dateToAdd +'</span>'+
'</div>'+
'</div>'+
'</div>';
Expand All @@ -133,7 +142,8 @@ class PrivateCommunication {

var toAppend = '<div class="outgoing_msg" id="outgoing_msg">'+
'<div class="sent_msg" id="addOurMessages">'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+
mesgToAdd + '<span id="userName" class="badge badge-secondary">'+messages[i].sender+'</span>'+'\n'+
'<span id="dateMessage" class="badge badge-secondary">' + dateToAdd +'</span>'+
'</div>'+
'</div>';
if(!testing){
Expand Down

0 comments on commit 329f5bf

Please sign in to comment.