]> code.citadel.org Git - citadel.git/blob - webcit/static/wclib.js
* Removed the 'mark message as seen' C code (in the mailbox view) because it
[citadel.git] / webcit / static / wclib.js
1 //
2 // $Id: wclib.js,v 625.2 2005/09/18 04:04:32 ajc Exp $
3 //
4 // JavaScript function library for WebCit
5 //
6 //
7
8
9 //
10 // This code handles the popups for instant messages.
11 //
12
13 var browserType;
14
15 if (document.layers) {browserType = "nn4"}
16 if (document.all) {browserType = "ie"}
17 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
18         browserType= "gecko"
19 }
20
21 function hide_page_popup() {
22         if (browserType == "gecko" )
23                 document.poppedLayer = eval('document.getElementById(\'page_popup\')');
24         else if (browserType == "ie")
25                 document.poppedLayer = eval('document.all[\'page_popup\']');
26         else
27                 document.poppedLayer = eval('document.layers[\'`page_popup\']');
28
29         document.poppedLayer.style.visibility = "hidden";
30 }
31
32 function hide_imsg_popup() {
33         if (browserType == "gecko" )
34                 document.poppedLayer = eval('document.getElementById(\'important_message\')');
35         else if (browserType == "ie")
36                 document.poppedLayer = eval('document.all[\'important_message\']');
37         else
38                 document.poppedLayer = eval('document.layers[\'`important_message\']');
39
40         document.poppedLayer.style.visibility = "hidden";
41 }
42
43 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
44 function activate_entmsg_autocompleters() {
45         new Ajax.Autocompleter('cc_id', 'cc_name_choices', '/cc_autocomplete', {} );
46         new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', '/bcc_autocomplete', {} );
47         new Ajax.Autocompleter('recp_id', 'recp_name_choices', '/recp_autocomplete', {} );
48 }
49
50
51 // Static variables for mailbox view...
52 //
53 var CtdlNumMsgsSelected = 0;
54 var CtdlMsgsSelected = new Array(100);  // arbitrary
55
56 // This gets called when you single click on a message in the mailbox view.
57 // We know that the element id of the table row will be the letter 'm' plus the message number.
58 //
59 function CtdlSingleClickMsg(msgnum) {
60
61         // $('preview_pane').innerHTML = '<div align="center">Loading...</div>' ;
62
63         if (CtdlNumMsgsSelected > 0) {
64                 for (i=0; i<CtdlNumMsgsSelected; ++i) {
65                         $('m'+CtdlMsgsSelected[i]).style.backgroundColor = '#fff';
66                         $('m'+CtdlMsgsSelected[i]).style.color = '#000';
67                 }
68                 CtdlNumMsgsSelected = 0;
69         }
70
71         $('m'+msgnum).style.backgroundColor='#69aaff';
72         $('m'+msgnum).style.color='#fff';
73         CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
74         CtdlMsgsSelected[CtdlNumMsgsSelected-1] = msgnum;
75
76         // Update the preview pane
77         new Ajax.Updater('preview_pane', '/msg/'+msgnum, { method: 'get' } );
78
79         // Mark the message as read
80         new Ajax.Request(
81                 '/ajax_servcmd', {
82                         method: 'post',
83                         parameters: 'g_cmd=SEEN '+msgnum+'|1',
84                         onComplete: CtdlRemoveTheUnseenBold(msgnum)
85                 }
86         );
87 }
88
89 function CtdlRemoveTheUnseenBold(msgnum) {
90         $('m'+msgnum).style.fontWeight='normal' ;
91 }
92