aboutsummaryrefslogtreecommitdiff
path: root/webclient
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-28 23:37:08 +0200
committertomsmeding <tom.smeding@gmail.com>2017-03-28 23:37:08 +0200
commit09f5c304a80608d349597e15fd5a096837c8ae48 (patch)
treed15616fb4fa8de1a52d9f243294c033cfa943782 /webclient
parent0b0ae76fae5c7aeb2611cc0346e8ee09c2eb5066 (diff)
webclient: /createroom, /invite
TODO: _push for invite in server
Diffstat (limited to 'webclient')
-rw-r--r--webclient/client.html44
1 files changed, 43 insertions, 1 deletions
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 <username> (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;