From bf573c6d29dd49bd1ebba9a26b85a03af9333eef Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 8 Apr 2017 12:14:40 +0200 Subject: webclient: Don't recalculate dates of meta msgs --- webclient/client.html | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'webclient/client.html') diff --git a/webclient/client.html b/webclient/client.html index 53a06bf..e0ca627 100644 --- a/webclient/client.html +++ b/webclient/client.html @@ -16,6 +16,10 @@ var uniqid=(function(){ }; })(); +function now(){ + return new Date().getTime(); +} + var net_callbacks={}; function net_send(msg,cb){ @@ -105,7 +109,7 @@ function reconnect(){ updateRoomList(); } else if(type=="join"){ var r=spl.word[2],u=spl.word[3]; - addRoomEntry(r,"notice",["User '"+u+"' joined this room"]); + addRoomEntry(r,"notice",[now(),"User '"+u+"' joined this room"]); } else { alert("Unknown push message type '"+type+"'!"); } @@ -142,7 +146,7 @@ function reconnect(){ function fetchRoomList(){ net_send("list_rooms",function(list,err){ if(err){ - addRoomEntry(":console","error",["Unable to fetch room list: "+err]); + addRoomEntry(":console","error",[now(),"Unable to fetch room list: "+err]); } else { var roomid; for(roomid in roomlogs.keys()){ @@ -163,7 +167,7 @@ function fetchRoomList(){ function fetchRoomHistory(roomid){ net_send("history "+roomid+" 10",function(list,err){ if(err){ - addRoomEntry(roomid,"error",["Unable to fetch history: "+err]); + addRoomEntry(roomid,"error",[now(),"Unable to fetch history: "+err]); } else { var i; for(i=0;i "]); + addRoomEntry(roomid,"error",[now(),"Usage: /"+cmd+" "]); break; } creds=[spl.word[1],spl.rest[2]]; net_send(cmd+" "+creds[0]+" "+creds[1],function(ok,err){ if(err){ - addRoomEntry(roomid,"error",["Unable to "+cmd+": "+err]); + addRoomEntry(roomid,"error",[now(),"Unable to "+cmd+": "+err]); } else if(cmd=="register"){ - addRoomEntry(roomid,"notice",["Successfully registered user '"+creds[0]+"'"]); + addRoomEntry(roomid,"notice",[now(),"Successfully registered user '"+creds[0]+"'"]); } else { username=creds[0]; - addRoomEntry(roomid,"notice",["Logged in as user '"+creds[0]+"'"]); + addRoomEntry(roomid,"notice",[now(),"Logged in as user '"+creds[0]+"'"]); updateStatus(); fetchRoomList(); } @@ -315,18 +321,18 @@ function executeCommand(roomid,text){ case "createroom": if(spl.word.length!=1){ - addRoomEntry(roomid,"error",["Usage: /createroom"]); + addRoomEntry(roomid,"error",[now(),"Usage: /createroom"]); break; } if(!username){ - addRoomEntry(roomid,"error",["createroom: not logged in"]); + addRoomEntry(roomid,"error",[now(),"createroom: not logged in"]); break; } net_send("create_room",function(name,err){ if(err){ - addRoomEntry(roomid,"error",["Unable to create a room: "+err]); + addRoomEntry(roomid,"error",[now(),"Unable to create a room: "+err]); } else { - addRoomEntry(roomid,"notice",["Successfully created room '"+name+"'"]); + addRoomEntry(roomid,"notice",[now(),"Successfully created room '"+name+"'"]); fetchRoomList(); } }); @@ -334,36 +340,36 @@ function executeCommand(roomid,text){ case "invite": if(spl.word.length<2){ - addRoomEntry(roomid,"error",["Usage: /invite (adds to current room)"]); + addRoomEntry(roomid,"error",[now(),"Usage: /invite (adds to current room)"]); break; } if(!username){ - addRoomEntry(roomid,"error",["invite: not logged in"]); + addRoomEntry(roomid,"error",[now(),"invite: not logged in"]); break; } if(!currentroom||currentroom[0]==":"){ - addRoomEntry(roomid,"error",["invite: cannot invite into room '"+currentroom+"'"]); + addRoomEntry(roomid,"error",[now(),"invite: cannot invite into room '"+currentroom+"'"]); break; } othername=spl.rest[1]; net_send("invite "+currentroom+" "+othername,function(ok,err){ if(err){ - addRoomEntry(roomid,"error",["Unable to invite '"+othername+"': "+err]); + addRoomEntry(roomid,"error",[now(),"Unable to invite '"+othername+"': "+err]); } else { - addRoomEntry(roomid,"notice",["Successfully invited '"+othername+"'"]); + addRoomEntry(roomid,"notice",[now(),"Successfully invited '"+othername+"'"]); } }); break; default: - addRoomEntry(roomid,"error",["Unknown command '"+cmd+"'"]); + addRoomEntry(roomid,"error",[now(),"Unknown command '"+cmd+"'"]); break; } } function sendMessage(roomid,text){ if(roomid[0]==":"){ - addRoomEntry(roomid,"error",["Cannot send a message here"]); + addRoomEntry(roomid,"error",[now(),"Cannot send a message here"]); return; } var sentAs=username,msg=text.replace(/\n/g,""); @@ -372,7 +378,7 @@ function sendMessage(roomid,text){ addRoomEntry(roomid,"message",[sentAs,new Date().getTime(),msg]); return; } - addRoomEntry(roomid,"error",["Unable to send message: "+err]); + addRoomEntry(roomid,"error",[now(),"Unable to send message: "+err]); }); } -- cgit v1.2.3-70-g09d2