*/
#include "webcit.h"
-
+#include "webserver.h"
/*
* Display the screen containing multiuser chat for a room.
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("<div id=\"chat_seq_%d\">", WC->last_chat_seq);
-
- if (strcasecmp(cl_user, WC->last_chat_user)) {
- wc_printf("<table border=0 width=100%% "
- "cellspacing=1 cellpadding=0 "
- "bgcolor="#ffffff">"
- "<tr><td></tr></td></table>"
- );
-
- }
-
- wc_printf("<table border=0 width=100%% cellspacing=0 cellpadding=0 "
- "bgcolor="#eeeeee">");
-
- wc_printf("<tr><td>");
-
- if (!strcasecmp(cl_user, ":")) {
- wc_printf("<I>");
- }
+ /* who is speaking ... */
if (strcasecmp(cl_user, WC->last_chat_user)) {
wc_printf("<B>");
else {
wc_printf("<FONT COLOR="#0000FF">");
}
- jsescputs(cl_user);
+ escputs(cl_user);
+ strcpy(WC->last_chat_user, cl_user);
wc_printf("</FONT>: </B>");
}
else {
wc_printf(" ");
}
- jsescputs(cl_text);
- if (!strcasecmp(cl_user, ":")) {
- wc_printf("</I>");
- }
- wc_printf("</TD></TR></TABLE>\n");
- wc_printf("</div>\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("<br>\n");
}
-
- end_ajax_response();
-
}
(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);
}
-<div id="chatrecv">
-This is the receiving side of the chat window, fee fie foe foo
+<div id="chatrecv_history" class="chatrecv_history">
</div>
-<div id="chatsend">
+<div id="chatrecv" class="chatrecv">
+</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>">
+<img src="static/citadelchat_16x.gif">
<input type="text" size="80" maxlength="1024" id="send_this_id" name="send_this">
-<br />
-<input type="submit" name="send_button" value="<?_("Send")>">
-<input type="submit" name="help_button" value="<?_("Help")>">
-<input type="submit" name="list_button" value="<?_("List users")>">
-<input type="submit" name="exit_button" value="<?_("Exit")>">
</div>
<script type="text/javascript">
}
new Ajax.PeriodicalUpdater('chatrecv', 'chat_recv', {
- method: 'get', frequency: 2, insertion: 'bottom'
+ method: 'get', frequency: 2,
+ onSuccess: function(){
+ $('chatrecv_history').innerHTML =
+ $('chatrecv_history').innerHTML + $('chatrecv').innerHTML;
+ $('chatrecv').innerHTML = '';
+ $('chatrecv_history').scrollTop = 9999999;
+ }
});
</script>