mirror of
https://github.com/YunoHost-Apps/minchat_ynh.git
synced 2024-09-03 19:36:29 +02:00
Display the date
This commit is contained in:
parent
b4de152c2a
commit
841e2a1f99
2 changed files with 20 additions and 12 deletions
|
@ -119,17 +119,22 @@ if ($name.$room=="") {
|
|||
dataType: 'json',
|
||||
async: false,
|
||||
success: function(data) {
|
||||
pos = data.pos;
|
||||
var html = '';
|
||||
var html='';
|
||||
var date;
|
||||
var heure='';
|
||||
for (var k in data.data) {
|
||||
lastdate = data.data[k][0];
|
||||
date = new Date(parseInt(lastdate)*1000);
|
||||
date = date.toLocaleTimeString().substr(0,5);
|
||||
heure = date.toLocaleTimeString().substr(0,5);
|
||||
html = html
|
||||
+"("+date+") <b>"
|
||||
+"("+heure+") <b>"
|
||||
+data.data[k][1]+"</b>: "+data.data[k][2]+"<br>";
|
||||
}
|
||||
if (pos==0 && heure!=''){
|
||||
html='<b>----- '+date.toLocaleDateString()+' -----</b><br>'+html;
|
||||
}
|
||||
pos = data.pos;
|
||||
|
||||
$("#chatbox").append(html);
|
||||
var newscrollHeight = $("#chatbox")[0].scrollHeight;
|
||||
if (newscrollHeight > oldscrollHeight) {
|
||||
|
|
|
@ -11,16 +11,19 @@ if (!ctype_digit($pos) || !file_exists($file)) return;
|
|||
settype($pos, "integer");
|
||||
settype($lastdate, "integer");
|
||||
|
||||
if ($date!=date('Y-m-d',$lastdate)) $pos=0;
|
||||
|
||||
$data = array();
|
||||
$fh =fopen($file, "r");
|
||||
|
||||
if (fseek($fh, $pos)==0) {
|
||||
$i=0;
|
||||
while($lig=fgets($fh)){ $data[$i++] = explode('>', $lig); }
|
||||
$pos =ftell($fh);
|
||||
echo json_encode(array('pos' => $pos, 'data' => $data));
|
||||
if ($pos!=0 && $date!=date('Y-m-d',$lastdate)) {
|
||||
$pos=0;
|
||||
} else {
|
||||
$fh =fopen($file, "r");
|
||||
|
||||
if (fseek($fh, $pos)==0) {
|
||||
$i=0;
|
||||
while($lig=fgets($fh)){ $data[$i++] = explode('>', $lig); }
|
||||
$pos =ftell($fh);
|
||||
}
|
||||
}
|
||||
echo json_encode(array('pos' => $pos, 'data' => $data));
|
||||
|
||||
?>
|
Loading…
Reference in a new issue