diff options
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/client.html | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/webclient/client.html b/webclient/client.html index 512a2ed..f88ee07 100644 --- a/webclient/client.html +++ b/webclient/client.html @@ -12,6 +12,7 @@ var sock=null,negotiated_version=false,username=null; var messagecache=new Map(); // msgid => [user,message] var roomlist=[":console"]; var currentroom=":console"; +var currentreply=null; // [msgid, table row] or null var roomlogs=new Map([[":console",[]]]); // see drawRoomEntry for entry types var commandlist=[ @@ -102,6 +103,7 @@ function resetState() { username=null; messagecache.clear(); net_callbacks={}; + cancelReply(); } function reconnect(){ @@ -330,6 +332,11 @@ function drawRoomEntry(type,args){ td2.insertBefore(replyNode,node2); td2.insertBefore(document.createElement("br"),node2); } + + tr.addEventListener("click",function(){ + if(currentreply&¤treply[0]==args[2])cancelReply(); + else startReply(args[2],tr); + }); break; case "error": // [timestamp_ms, text] @@ -364,6 +371,21 @@ function addRoomEntry(roomid,type,args){ } } +function cancelReply(){ + if(!currentreply)return; + currentreply[1].classList.remove("replying"); + document.getElementById("roominput_td").classList.remove("replying"); + currentreply=null; +} + +function startReply(msgid,tr){ + cancelReply(); + currentreply=[msgid,tr]; + tr.classList.add("replying"); + document.getElementById("roominput_td").classList.add("replying"); + document.getElementById("roominput").focus(); +} + function showUsage(roomid,cmd){ for(var i=0;i<commandlist.length;i++){ if(commandlist[i].cmd==cmd){ @@ -464,11 +486,15 @@ function sendMessage(roomid,text){ addRoomEntry(roomid,"error",[now(),"Cannot send a message here"]); return; } + var sentAs=username,msg=text.replace(/\n/g,""); - net_send("send "+roomid+" -1 "+msg,function(msgid,err){ + var replyid=currentreply?currentreply[0]:"-1"; + cancelReply(); + + net_send("send "+roomid+" "+replyid+" "+msg,function(msgid,err){ if(msgid!=null){ msgid=msgid.toString(); - addRoomEntry(roomid,"message",[sentAs,new Date().getTime(),msgid,"-1",msg]); + addRoomEntry(roomid,"message",[sentAs,new Date().getTime(),msgid,replyid,msg]); return; } addRoomEntry(roomid,"error",[now(),"Unable to send message: "+err]); @@ -520,6 +546,10 @@ table{ height:100%; } +.invisible{ + display:none; +} + /* SIDEBAR */ #sidebar{ width:150px; @@ -599,6 +629,13 @@ table{ } #roomlog > tr.message{ color:inherit; + cursor:pointer; +} +#roomlog > tr.message:hover{ + background-color:#202030; +} +#roomlog > tr.replying{ + background-color:#090 !important; } #roomlog > tr.error{ color:#f44; @@ -627,6 +664,9 @@ table{ vertical-align:top; padding:0px 1px 0px 10px; } +#roominput_td.replying{ + background-color:#090; +} #roominput{ position:absolute; background-color:rgba(0,0,0,0); |