fix dlen
[citadel.git] / webcit / static / instant_messenger.html
index 87f9ab533e7189db3c97409501a8e818e23c8a16..c43ac2426dd2286b667b2e0bd096aeee16e785ac 100644 (file)
@@ -3,6 +3,7 @@
        <title>Citadel Instant Messenger</title>
        <script type="text/javascript" src="prototype.js"></script>
        <script type="text/javascript" src="wclib.js"></script>
+       <script type="text/javascript" src="authmethods.js"></script>
 </head>
 <body onLoad='FetchNewMsgs();'>
 
 <div id="main" style="position:fixed;width:100%;height:85%;top:15%;left:0%;overflow:auto;background:#ffffff"></div>
 
 <script type="text/javascript">
+/*
+ * Copyright 2000 - 2010 The Citadel Team
+ * Licensed under the GPL V3
+ *
+ * Chat window for Person 2 Person Chat
+ *
+ */
 
 var gexp_divs = new Array();
 var num_gexp_divs = 0;
@@ -40,17 +48,18 @@ function SendSomething(which_div, sendform, recipient) {
                                + '</font>'
                                + ':</b> '
                                + thetext
-                               + '<br />\n';
+                               + '<br>\n';
 
        // Scroll to the bottom of the tab
        $('main').scrollTop = 999999;
 
        // Send the text to the server
        parms = 'r=' + Math.random()
-               + '&g_cmd=SEXP ' + recipient + '|' + thetext;
-       new Ajax.Request('../ajax_servcmd',
+               + '&recp=' + encodeURIComponent(recipient)
+               + '&msg=' + encodeURIComponent(thetext);
+       new Ajax.Request('../ajax_send_instant_message',
                {
-                       method: 'get',
+                       method: 'post',
                        parameters: parms
                }
        );
@@ -93,6 +102,12 @@ function ShowNewMsg(gexp_xmlresponse) {
        result = gexp_response.substring(0, breakpos-1);
        the_message = gexp_response.substring(breakpos+1);
        the_message = the_message.substring(0, the_message.indexOf('\n000'));
+
+       // Sanitize HTML in the message
+       the_message = the_message.replaceAll("&", "&amp;");
+       the_message = the_message.replaceAll("<", "&lt;");
+       the_message = the_message.replaceAll(">", "&gt;");
+
        sender = extract_token(result.substring(4), 3, '|');
 
        // Figure out which div to write it to...
@@ -114,13 +129,16 @@ function ShowNewMsg(gexp_xmlresponse) {
                          $('main').innerHTML
                        + '<div id=\"tab_' + which_div + '\" style=\"display:none;cursor:pointer\">'
                        + '<div id=\"' + which_div + '\">'
+                       + '<br><br><br><br><br><br><br><br><br><br>'
+                       + '<br><br><br><br><br><br><br><br><br><br>'
                        + '</div>'
-                       + '<div id=\"response_' + which_div + '\" style=\"background:#ddddee\">'
+                       + '<div align=\"center\" id=\"response_'
+                       + which_div + '\" style=\"background:#ddddee\">'
                        + '<br><form method=\"post\" action=\"null\" name=\"sendform_' + which_div + '\" '
                        + 'onSubmit=\"return SendSomething(\'' + which_div + '\', \'sendform_'
                        + which_div + '\', \'' + sender + '\');\">'
-                       + '<img src=\"citadelchat_16x.gif\">&nbsp;'
-                       + '<input type=\"text\" size=\"72\" maxlength=\"72\" name=\"sendthis\">'
+                       + '<img src=\"webcit_icons/essen/16x16/chat.png\">&nbsp;'
+                       + '<input type=\"text\" size=\"72\" maxlength=\"600\" name=\"sendthis\">'
                        + '</form>'
                        + '<br></div>'
                        + '</div>\n';
@@ -145,7 +163,7 @@ function ShowNewMsg(gexp_xmlresponse) {
                                + '</font>'
                                + ':</b> '
                                + the_message
-                               + '<br />\n';
+                               + '<br>\n';
 
        // Scroll to the bottom of the tab
        $('main').scrollTop = 999999;
@@ -159,7 +177,7 @@ function ShowNewMsg(gexp_xmlresponse) {
 
 // This is called periodically to check for new incoming messages
 function FetchNewMsgs() {
-       parms = 'g_cmd=GEXP&r=' + Math.random();
+       parms = encodeURI('g_cmd=GEXP&r=' + Math.random());
        new Ajax.Request('../ajax_servcmd',
                {
                        method: 'get',
@@ -170,7 +188,7 @@ function FetchNewMsgs() {
 }
 
 // Perform some initialization.
-parms = 'g_cmd=GREG _SELF_&r=' + Math.random();
+parms = encodeURI('g_cmd=GREG _SELF_&r=' + Math.random());
 new Ajax.Request('../ajax_servcmd',
        {
                method: 'get',
@@ -197,7 +215,7 @@ function GrabMyName(greg_xmlresponse) {
 
 
 // Cause FetchNewMsgs() to be called periodically.
-new PeriodicalExecuter(FetchNewMsgs, 5);
+new PeriodicalExecuter(FetchNewMsgs, 10);
 
 </script>