Index: openacs-4/packages/xowiki/www/ajax/streaming-chat.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/ajax/Attic/streaming-chat.js,v diff -u -r1.6 -r1.7 --- openacs-4/packages/xowiki/www/ajax/streaming-chat.js 13 Sep 2012 16:05:34 -0000 1.6 +++ openacs-4/packages/xowiki/www/ajax/streaming-chat.js 17 Feb 2013 11:48:06 -0000 1.7 @@ -2,30 +2,13 @@ // $Id$ // -gustaf neumann April 2006 -function getHttpObject() { - var http_request = false; - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - } else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject('Msxml2.XMLHTTP'); - } catch (e) { - try { - http_request = new ActiveXObject('Microsoft.XMLHTTP'); - } catch (e) {} - } - } - - if (!http_request) { - alert('Cannot create and instance of XMLHTTP'); - } - return http_request; -} +var http = getHttpObject(); +var http_last = 0; +var http_send = getHttpObject(); function getData() { //alert('access responseText'); // hmm, IE does not allow us to access responstext in state == 3 :( var response = http.responseText.substring(http_last); - //alert('access responseText done'); // we recognize a complete message by a trailing }\n if (response.match(/\}[\n ]+$/)) { var messages = document.getElementById('messages'); @@ -44,7 +27,7 @@ p.appendChild(span); span = document.createElement('span'); - span.innerHTML = data.messages[i].msg; + span.innerHTML = decodeURI(unescape(data.messages[i].msg)); span.className = 'message'; p.appendChild(span); @@ -55,17 +38,12 @@ } } -var http = getHttpObject(); -var http_last = 0; -var http_send = getHttpObject(); - function chatSendMsg() { var msg = document.getElementById('chatMsg').value; if (msg == '') { return; } - //alert(send_url + encodeURIComponent(msg)); - http_send.open('GET', send_url + encodeURIComponent(msg), true); + http_send.open('GET', send_url + encodeURIComponent(escape(msg)), true); http_send.onreadystatechange = function() { if (http_send.readyState == 4) { if (http_send.status != 200) { @@ -84,18 +62,15 @@ getData(); } else if (http.readyState == 4) { // alert('status code =' + http.status); - if (http.status == 200) { + var status = http.status; + if (status == 200 || status == 0) { document.getElementById('chatMsg').value = 'logout'; chatSendMsg(); } else { - alert('Something wrong in HTTP request, status code = ' + http.status); + alert('Something wrong in HTTP request, status code = ' + status); } } }; http.send(null); http_last = 0; -} -function tell(msg) { - document.monitor.window.value = msg; -} - +} \ No newline at end of file