From 09f5c304a80608d349597e15fd5a096837c8ae48 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 28 Mar 2017 23:37:08 +0200 Subject: webclient: /createroom, /invite TODO: _push for invite in server --- webclient/client.html | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'webclient') diff --git a/webclient/client.html b/webclient/client.html index 7ea65cf..b68b51f 100644 --- a/webclient/client.html +++ b/webclient/client.html @@ -280,7 +280,7 @@ function executeCommand(roomid,text){ var spl=fancySplit(text,true); if(spl.word.length==0)return; var cmd=spl.word[0]; - var creds=null; + var creds=null,othername; switch(cmd){ case "register": case "login": @@ -303,6 +303,48 @@ function executeCommand(roomid,text){ }); break; + case "createroom": + if(spl.word.length!=1){ + addRoomEntry(roomid,"error",["Usage: /createroom"]); + break; + } + if(!username){ + addRoomEntry(roomid,"error",["createroom: not logged in"]); + break; + } + net_send("create_room",function(name,err){ + if(err){ + addRoomEntry(roomid,"error",["Unable to create a room: "+err]); + } else { + addRoomEntry(roomid,"notice",["Successfully created room '"+name+"'"]); + fetchRoomList(); + } + }); + break; + + case "invite": + if(spl.word.length<2){ + addRoomEntry(roomid,"error",["Usage: /invite (adds to current room)"]); + break; + } + if(!username){ + addRoomEntry(roomid,"error",["invite: not logged in"]); + break; + } + if(!currentroom||currentroom[0]==":"){ + addRoomEntry(roomid,"error",["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]); + } else { + addRoomEntry(roomid,"notice",["Successfully invited '"+othername+"'"]); + } + }); + break; + default: addRoomEntry(roomid,"error",["Unknown command '"+cmd+"'"]); break; -- cgit v1.2.3-70-g09d2