Merge branch 'ent-4883-Mensaje-erroneo-WebChat' into 'develop'

Ent 4883 mensaje erroneo web chat

See merge request artica/pandorafms!2856
This commit is contained in:
Alejandro Fraguas 2019-12-23 17:45:25 +01:00
commit 45c57abb70
1 changed files with 25 additions and 1 deletions

View File

@ -165,9 +165,13 @@ echo "<div style='width:100%'>".html_print_button(
check_users();
if (first_time) {
var date_first_message = unix_timestamp(data['log'][0]['timestamp']);
if(!date_first_message){
date_first_message = unix_timestamp(new Date()/1000);
}
print_messages({
0: {'type' : 'notification',
'text': '<?php echo __('Connection established...get last 24h messages...'); ?>'}
'text': '<?php echo __('Connection established - Retrieving messages since '); ?>'+date_first_message}
}, true);
first_time = false;
}
@ -308,4 +312,24 @@ echo "<div style='width:100%'>".html_print_button(
}
});
}
// Function to convert a timestamp to human date.
function unix_timestamp(timestamp){
var date = new Date(timestamp*1000);
const monthNames = [
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
];
var month = monthNames[date.getMonth()];
var day = date.getDate();
var year = date.getFullYear();
var hour = date.getHours();
var min = date.getMinutes();
return month + ' ' + day + ', '+ year + ', ' + hour+ ':' + min;
}
</script>