From d0e91c8de4c97de9bed71636c93ba7929ca6fa93 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 24 Apr 2010 05:04:20 +0000 Subject: [PATCH] * Finally got room chat working properly. Just need to add the bells and whistles. --- webcit/roomchat.c | 54 +++++++---------------------------- webcit/static/t/roomchat.html | 21 ++++++++------ webcit/static/webcit.css | 20 +++++++++++++ 3 files changed, 42 insertions(+), 53 deletions(-) diff --git a/webcit/roomchat.c b/webcit/roomchat.c index 0933fa616..88ef6533a 100644 --- a/webcit/roomchat.c +++ b/webcit/roomchat.c @@ -21,7 +21,7 @@ */ #include "webcit.h" - +#include "webserver.h" /* * Display the screen containing multiuser chat for a room. @@ -51,43 +51,14 @@ void do_chat(void) void chat_recv(void) { char buf[SIZ]; char cl_user[SIZ]; - char cl_text[SIZ]; - int cl_text_len = 0; - - begin_ajax_response(); serv_printf("RCHT poll|%d", WC->last_chat_seq); serv_getln(buf, sizeof buf); if (buf[0] == '1') { WC->last_chat_seq = extract_int(&buf[4], 0); extract_token(cl_user, &buf[4], 2, '|', sizeof cl_user); - cl_text[0] = 0; - cl_text_len = 0; - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - safestrncpy(&cl_text[cl_text_len], buf, (sizeof(cl_text) - cl_text_len)); - cl_text_len += strlen(buf); - } - - wc_printf("
", WC->last_chat_seq); - - if (strcasecmp(cl_user, WC->last_chat_user)) { - wc_printf("" - "
" - ); - - } - - wc_printf(""); - - wc_printf("
"); - - if (!strcasecmp(cl_user, ":")) { - wc_printf(""); - } + /* who is speaking ... */ if (strcasecmp(cl_user, WC->last_chat_user)) { wc_printf(""); @@ -97,27 +68,22 @@ void chat_recv(void) { else { wc_printf(""); } - jsescputs(cl_user); + escputs(cl_user); + strcpy(WC->last_chat_user, cl_user); wc_printf(": "); } else { wc_printf("   "); } - jsescputs(cl_text); - if (!strcasecmp(cl_user, ":")) { - wc_printf(""); - } - wc_printf("
\n"); - wc_printf("
\n"); + /* what did they say ... */ + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + escputs(buf); + } - strcpy(WC->last_chat_user, cl_user); - /* FIXME make this work wc_printf("parent.chat_transcript.scrollTo(999999,999999);\">\n"); */ + wc_printf("
\n"); } - - end_ajax_response(); - } @@ -166,7 +132,7 @@ InitModule_ROOMCHAT (void) { WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0); - WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, 0); + WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX); WebcitAddUrlHandler(HKEY("chat_send"), "", 0, chat_send, 0); } diff --git a/webcit/static/t/roomchat.html b/webcit/static/t/roomchat.html index 87eefe009..e5de02af3 100644 --- a/webcit/static/t/roomchat.html +++ b/webcit/static/t/roomchat.html @@ -1,15 +1,12 @@ -
-This is the receiving side of the chat window, fee fie foe foo +
-
+
+
+
+ -
-"> -"> -"> -">
diff --git a/webcit/static/webcit.css b/webcit/static/webcit.css index 0bd8bf79b..9d1c4c0c4 100644 --- a/webcit/static/webcit.css +++ b/webcit/static/webcit.css @@ -1613,3 +1613,23 @@ li.event_unread span, a.event_read_title { background-color: #FF0000; color: #FFFFFF; } + +.chatrecv_history { + margin-left: 5px; + margin-right: 5px; + margin-top: 5px; + margin-bottom: 5px; + height: 70%; + background-color: #FFFFFF; + overflow: auto; +} + +.chatrecv { + display: none; +} + +.chatsend { + width: 90%; + margin-left: auto; + margin-right: auto; +} -- 2.30.2