* More tweaks to the room chat window. Now displays the list of users in chat.
authorArt Cancro <ajc@citadel.org>
Mon, 26 Apr 2010 18:48:24 +0000 (18:48 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 26 Apr 2010 18:48:24 +0000 (18:48 +0000)
citadel/modules/roomchat/serv_roomchat.c
webcit/roomchat.c
webcit/static/t/roomchat.html
webcit/static/webcit.css

index c1a08c56617040b574f61a5aa4c5da7afcfc0b6d..b3348078c991912b0db6bac756f5c7ee33886be7 100644 (file)
@@ -198,6 +198,38 @@ void roomchat_poll(char *argbuf) {
 }
 
 
+
+/*
+ * list users in chat in this room
+ */
+void roomchat_rwho(char *argbuf) {
+       struct CitContext *nptr;
+       int nContexts, i;
+
+       if (!CC->cs_flags & CS_CHAT) {
+               cprintf("%d Session is not in chat mode.\n", ERROR);
+               return;
+       }
+
+       cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );
+       
+       nptr = CtdlGetContextArray(&nContexts) ;                // grab a copy of the wholist
+       if (nptr) {
+               for (i=0; i<nContexts; i++)  {                  // list the users
+                       if ( (nptr[i].room.QRnumber == CC->room.QRnumber) 
+                          && (nptr[i].cs_flags & CS_CHAT)
+                       ) {
+                               cprintf("%s\n", nptr[i].user.fullname);
+                       }
+               }
+               free(nptr);                                     // free our copy
+       }
+
+       cprintf("000\n");
+}
+
+
+
 /*
  * Participate in real time chat in a room
  */
@@ -223,6 +255,9 @@ void cmd_rcht(char *argbuf)
        else if (!strcasecmp(subcmd, "poll")) {
                roomchat_poll(argbuf);
        }
+       else if (!strcasecmp(subcmd, "rwho")) {
+               roomchat_rwho(argbuf);
+       }
        else {
                cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED);
        }
index 1e2d8499199f5e5b17870611b213dd00dfe8cecb..c7eed1334d9c3d55e1721e0218f91149964f91fc 100644 (file)
@@ -62,10 +62,10 @@ void chat_recv(void) {
                if (strcasecmp(cl_user, WC->last_chat_user)) {
                        wc_printf("<br>\n");
                        if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) {
-                               wc_printf("<span class=\"chat_username_me\">");
+                               wc_printf("<span class=\"chat_myname\">");
                        }
                        else {
-                               wc_printf("<span class=\"chat_username_notme\">");
+                               wc_printf("<span class=\"chat_notmyname\">");
                        }
                        escputs(cl_user);
                        strcpy(WC->last_chat_user, cl_user);
@@ -102,14 +102,6 @@ void chat_send(void) {
                strcpy(send_this, "");
        }
 
-       if (havebstr("help_button")) {
-               strcpy(send_this, "/help");
-       }
-
-       if (havebstr("list_button")) {
-               strcpy(send_this, "/who");
-       }
-
        if (havebstr("exit_button")) {
                strcpy(send_this, "/quit");
        }
@@ -126,12 +118,37 @@ void chat_send(void) {
 }
 
 
+/*
+ * wholist for chat
+ */
+void chat_rwho(void) {
+       char buf[1024];
+
+       serv_puts("RCHT rwho");
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '1') {
+               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                       if (!strcasecmp(buf, ChrPtr(WC->wc_fullname))) {
+                               wc_printf("<span class=\"chat_myname\">");
+                       }
+                       else {
+                               wc_printf("<span class=\"chat_notmyname\">");
+                       }
+                       wc_printf("<img src=\"static/citadelchat_16x.gif\">");
+                       escputs(buf);
+                       wc_printf("</span><br>\n");
+               }
+       }
+}
+
+
 void 
 InitModule_ROOMCHAT
 (void)
 {
        WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0);
        WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX);
+       WebcitAddUrlHandler(HKEY("chat_rwho"), "", 0, chat_rwho, AJAX);
        WebcitAddUrlHandler(HKEY("chat_send"), "", 0, chat_send, 0);
 }
 
index 5cb9559b6efcb72ac0bcee7a0c68e03fbd08a56c..f5daf0a395133391a0372a4b8e915c3ecc6e4b09 100644 (file)
@@ -2,6 +2,8 @@
 </div>
 <div id="chatrecv" class="chatrecv">
 </div>
+<div id="chat_userlist" class="chat_userlist">
+</div>
 <div id="chatsend" class="chatsend">
 <form method="POST" onsubmit="return chatsendfunc()" action="chat_send" id="chatsendid" name="chatsendform">
 <input type="hidden" name="nonce" value="<?NONCE>">
@@ -37,4 +39,8 @@ new Ajax.PeriodicalUpdater('chatrecv', 'chat_recv', {
                }
 });
 
+new Ajax.PeriodicalUpdater('chat_userlist', 'chat_rwho', {
+       method: 'get', frequency: 15
+});
+
 </script>
index 1778aa34edbc22a4f272d5f37ecc03cb15102f85..79e46b92cd8fb79588a51d232e34c1b4e301538d 100644 (file)
@@ -1615,13 +1615,37 @@ li.event_unread span, a.event_read_title {
 }
 
 .chatrecv_history {
-       margin-left: 5px;
-       margin-right: 5px;
+       position: absolute;
+       top: 0;
+       left: 1%;
+       width: 74%;
+       margin-top: 5px;
+       margin-bottom: 5px;
+       height: 70%;
+       background-color: #FFFFFF;
+       overflow: auto;
+       border-style: solid;
+       border-color: #022750;
+       border-width: 1px;
+       padding-left: 3px;
+       padding-right: 3px;
+}
+
+.chat_userlist {
+       position: absolute;
+       top: 0;
+       right: 1%;
+       width: 23%;
        margin-top: 5px;
        margin-bottom: 5px;
        height: 70%;
        background-color: #FFFFFF;
        overflow: auto;
+       border-style: solid;
+       border-color: #022750;
+       border-width: 1px;
+       padding-left: 3px;
+       padding-right: 3px;
 }
 
 .chatrecv {
@@ -1629,20 +1653,28 @@ li.event_unread span, a.event_read_title {
 }
 
 .chatsend {
-       width: 90%;
+       position: absolute;
+       left: 1%;
+       right: 1%;
+       top: 71%;
        margin-left: auto;
        margin-right: auto;
+       border-style: solid;
+       border-color: #022750;
+       border-width: 1px;
+       padding-left: 3px;
+       padding-right: 3px;
 }
 
-.chat_username_me {
+.chat_myname {
        font-weight: bold;
-       color: #f00;
-};
+       color: #ff0000;
+}
 
-.chat_username_notme {
+.chat_notmyname {
        font-weight: bold;
-       color: #00f;
-};
+       color: #0000ff;
+}
 
 .chat_text {
-};
+}