Index: openacs-4/packages/chat/chat.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/chat.info,v diff -u -N -r1.7.2.1 -r1.7.2.2 --- openacs-4/packages/chat/chat.info 30 Mar 2006 09:15:12 -0000 1.7.2.1 +++ openacs-4/packages/chat/chat.info 31 Mar 2006 16:09:56 -0000 1.7.2.2 @@ -7,25 +7,27 @@ f f - + Peter Alberer Server based chat with an html and ajax client. - 2006-03-24 + 2006-03-31 OpenACS - Adapted by Peter Alberer 2006/03/25 to allow java and ajax to coexist. Adapted by Tekne 2006/03/01 to replace JAVA server with AJAX; make use of generalized chat class from xotcl-core + Adapted by Peter Alberer 2006/03/25 to allow java and ajax to coexist. +Adapted by Tekne 2006/03/01 to replace JAVA server with AJAX; make use of generalized chat class from xotcl-core. 0 - + - - + + + Index: openacs-4/packages/chat/www/ajax/chat.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/www/ajax/Attic/chat.js,v diff -u -N -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/chat/www/ajax/chat.js 31 Mar 2006 12:52:49 -0000 1.1.2.2 +++ openacs-4/packages/chat/www/ajax/chat.js 31 Mar 2006 16:09:56 -0000 1.1.2.3 @@ -48,7 +48,7 @@ var tr, td, e, s; var msgCount = 0; for (var i = 0 ; i < node.childNodes.length ; i++) { - if (node.childNodes[i].nodeType == 3 ){ + if (node.childNodes[i].nodeType == 3 ) { // if this is a textnode, skip it continue; } @@ -91,19 +91,29 @@ var xmlobject = (new DOMParser()).parseFromString(content, 'application/xhtml+xml'); var body = xmlobject.getElementsByTagName('body'); - var usersNode = body[0].childNodes[1].childNodes[0]; - if (usersNode.hasChildNodes()) { - var usersDoc = frames['ichat-users'].document; - var usersTbody = frames['ichat-users'].document.getElementById('users').tBodies[0]; - usersReceiver(usersNode,usersDoc,usersTbody); + for (var i = 0 ; i < body[0].childNodes.length ; i++) { + if (body[0].childNodes[i].nodeType == 3 ) { + // if this is a textnode, skip it + continue; } - - var messagesNode = body[0].childNodes[0]; + var attribute = body[0].childNodes[i].getAttribute('id'); + switch (attribute) { + case "messages": + var messagesNode = body[0].childNodes[i]; if (messagesNode.hasChildNodes()) { var messagesDoc = frames['ichat'].document; var messagesDiv = frames['ichat'].document.getElementById('messages'); messagesReceiver(messagesNode,messagesDoc,messagesDiv); } + break; + case "users": + var usersNode = body[0].childNodes[i].childNodes[0]; + var usersDoc = frames['ichat-users'].document; + var usersTbody = frames['ichat-users'].document.getElementById('users').tBodies[0]; + usersReceiver(usersNode,usersDoc,usersTbody); + break; + } + } } function usersReceiver(node,doc,tbody) { Index: openacs-4/packages/chat/www/ajax/chat.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/www/ajax/Attic/chat.tcl,v diff -u -N -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/chat/www/ajax/chat.tcl 31 Mar 2006 12:52:49 -0000 1.1.2.2 +++ openacs-4/packages/chat/www/ajax/chat.tcl 31 Mar 2006 16:09:56 -0000 1.1.2.3 @@ -12,7 +12,7 @@ } set message_output "" -set user_output "" +set user_output "-" ::chat::Chat c1 -volatile -chat_id $id -session_id $s @@ -43,7 +43,7 @@ default {ns_log error "--c unknown method $m called."} } -ns_return 200 text/html " +set output " -
$message_output
$user_output
-" \ No newline at end of file +" + +if { $message_output ne "" } { + append output "
$message_output
\n" +} + +if { $user_output ne "-" } { + append output "$user_output
\n" +} + +append output " + +" + +ns_return 200 text/html $output \ No newline at end of file