3 <title>Citadel Instant Messenger
</title>
4 <script type=
"text/javascript" src=
"prototype.js"></script>
5 <script type=
"text/javascript" src=
"wclib.js"></script>
7 <body onLoad='FetchNewMsgs();'
>
9 <div id=
"thetop" style=
"position:fixed;width:100%;height:15%;top:0%;left:0%">
10 <div id=
"spacer1" style=
"background:#aaaaaa"><br></div>
11 <div id=
"tab_bar" style=
"background:#aaaaaa"> </div>
12 <div id=
"spacer2" style=
"background:#aaaaaa"><br></div>
15 <div id=
"main" style=
"position:fixed;width:100%;height:85%;top:15%;left:0%;overflow:auto;background:#ffffff"></div>
17 <script type=
"text/javascript">
19 var gexp_divs
= new Array();
20 var num_gexp_divs
= 0;
24 function SendSomething(which_div
, sendform
, recipient
) {
25 thetext
= document
.forms
[sendform
].elements
['sendthis'].value
;
27 // If the user didn't type anything, don't do anything.
33 document
.forms
[sendform
].elements
['sendthis'].value
= '';
35 // Write it to the tab
36 $(which_div
).innerHTML
= $(which_div
).innerHTML
38 + '<font color=\"#FF0000\">'
45 // Scroll to the bottom of the tab
46 $('main').scrollTop
= 999999;
48 // Send the text to the server
49 parms
= 'r=' + Math
.random()
50 + '&g_cmd=SEXP ' + recipient
+ '|-\n' + escape(thetext
);
51 new Ajax
.Request('../ajax_servcmd',
58 // Refocus to the text box
59 document
.forms
[sendform
].elements
['sendthis'].focus();
61 // Don't submit the form
65 function TabSelect(which_div
) {
66 if (shown_div
!= '') {
67 $(shown_div
).style
.display
= 'none' ;
68 if ($('select_'+shown_div
)) {
69 $('select_'+shown_div
).style
.fontWeight
= 'normal';
70 $('select_'+shown_div
).style
.backgroundColor
= '#cccccc';
73 shown_div
= 'tab_' + which_div
;
74 $(shown_div
).style
.display
= 'block' ;
75 if ($('select_'+shown_div
)) {
76 $('select_'+shown_div
).style
.fontWeight
='bold';
77 $('select_'+shown_div
).style
.backgroundColor
= '#ffffff';
82 function ShowNewMsg(gexp_xmlresponse
) {
84 // It isn't really XML. It's a Citadel server response.
85 gexp_response
= gexp_xmlresponse
.responseText
;
87 if (gexp_response
.substring(0, 1) != '1') {
92 breakpos
= gexp_response
.indexOf('\n');
93 result
= gexp_response
.substring(0, breakpos
-1);
94 the_message
= gexp_response
.substring(breakpos
+1);
95 the_message
= the_message
.substring(0, the_message
.indexOf('\n000'));
96 sender
= extract_token(result
.substring(4), 3, '|');
98 // Figure out which div to write it to...
100 if (num_gexp_divs
> 0) {
101 for (i
=0; i
<num_gexp_divs
; ++i
) {
102 if (gexp_divs
[i
] == sender
) {
103 which_div
= 'gexp' + i
;
108 // Not found? Create it.
109 if (which_div
== '') {
110 gexp_divs
[num_gexp_divs
] = sender
;
111 which_div
= 'gexp' + num_gexp_divs
;
113 $('main').innerHTML
=
115 + '<div id=\"tab_' + which_div
+ '\" style=\"display:none;cursor:pointer\">'
116 + '<div id=\"' + which_div
+ '\">'
117 + '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />'
118 + '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />'
120 + '<div align=\"center\" id=\"response_'
121 + which_div
+ '\" style=\"background:#ddddee\">'
122 + '<br><form method=\"post\" action=\"null\" name=\"sendform_' + which_div
+ '\" '
123 + 'onSubmit=\"return SendSomething(\'' + which_div
+ '\', \'sendform_'
124 + which_div
+ '\', \'' + sender
+ '\');\">'
125 + '<img src=\"citadelchat_16x.gif\"> '
126 + '<input type=\"text\" size=\"72\" maxlength=\"600\" name=\"sendthis\">'
130 $('tab_bar').innerHTML
=
131 $('tab_bar').innerHTML
132 + '<span id=\"select_tab_' + which_div
+ '\" onClick=\"TabSelect(\'' + which_div
+ '\');\">'
133 + ' ' + sender
+ ' '
134 + '</span> ';
136 // Raise the window in case it was buried
141 TabSelect(which_div
);
143 // Write it to the tab
144 $(which_div
).innerHTML
= $(which_div
).innerHTML
146 + '<font color=\"#0000FF\">'
153 // Scroll to the bottom of the tab
154 $('main').scrollTop
= 999999;
156 // Refocus to the send box
157 document
.forms
['sendform_'+which_div
].elements
['sendthis'].focus();
159 // Keep trying for new messages until the server tells us to stop.
163 // This is called periodically to check for new incoming messages
164 function FetchNewMsgs() {
165 parms
= 'g_cmd=GEXP&r=' + Math
.random();
166 new Ajax
.Request('../ajax_servcmd',
170 onSuccess
: ShowNewMsg
175 // Perform some initialization.
176 parms
= 'g_cmd=GREG _SELF_&r=' + Math
.random();
177 new Ajax
.Request('../ajax_servcmd',
181 onSuccess
: GrabMyName
186 function GrabMyName(greg_xmlresponse
) {
188 // It isn't really XML. It's a Citadel server response.
189 greg_response
= greg_xmlresponse
.responseText
;
191 if (greg_response
.substring(0, 1) != '1') {
196 breakpos
= greg_response
.indexOf('\n');
197 result
= greg_response
.substring(0, breakpos
);
198 my_name
= result
.substring(4);
202 // Cause FetchNewMsgs() to be called periodically.
203 new PeriodicalExecuter(FetchNewMsgs
, 10);