aboutsummaryrefslogtreecommitdiff
path: root/webclient
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-04-08 12:14:40 +0200
committertomsmeding <tom.smeding@gmail.com>2017-04-08 12:14:40 +0200
commitbf573c6d29dd49bd1ebba9a26b85a03af9333eef (patch)
tree4bb60e973fed15e9386b937fa03679dbae9f01ea /webclient
parentc334bea0a39a2627e63102fb95b62517dc4c0b69 (diff)
webclient: Don't recalculate dates of meta msgs
Diffstat (limited to 'webclient')
-rw-r--r--webclient/client.html50
1 files changed, 28 insertions, 22 deletions
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<list.length;i++){
@@ -238,7 +242,7 @@ function drawRoomEntry(type,args){
var td0=document.createElement("td");
var td1=document.createElement("td");
var td2=document.createElement("td");
- var node0=document.createTextNode(formatTime(new Date()));
+ var node0=document.createTextNode("");
var node1=document.createTextNode("");
var node2=document.createTextNode("");
td0.appendChild(node0);
@@ -258,14 +262,16 @@ function drawRoomEntry(type,args){
case "error":
tr.classList.add("error");
+ node0.nodeValue=formatTime(new Date(args[0]));
node1.nodeValue="--";
- node2.nodeValue=args[0];
+ node2.nodeValue=args[1];
break;
case "notice":
tr.classList.add("notice");
+ node0.nodeValue=formatTime(new Date(args[0]));
node1.nodeValue="--";
- node2.nodeValue=args[0];
+ node2.nodeValue=args[1];
break;
default:
@@ -295,18 +301,18 @@ function executeCommand(roomid,text){
case "register":
case "login":
if(spl.word.length<3){
- addRoomEntry(roomid,"error",["Usage: /"+cmd+" <username> <password>"]);
+ addRoomEntry(roomid,"error",[now(),"Usage: /"+cmd+" <username> <password>"]);
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 <username> (adds to current room)"]);
+ addRoomEntry(roomid,"error",[now(),"Usage: /invite <username> (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]);
});
}