The in-iconbar wholist is now expandable and collapsible.
[citadel.git] / webcit / static / wclib.js
index 6fddde5c814f11e7b156b6c941c0f0875e4a40f9..01057a82b3672fed3c1509bbd8e5cc436220ae65 100644 (file)
@@ -144,6 +144,11 @@ function activate_entmsg_autocompleters() {
        new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
 }
 
+function activate_iconbar_wholist_populat0r() 
+{
+       new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
+}
+
 function setupIconBar() {
   if (!document.getElementById("switch")) {
       return;
@@ -163,8 +168,16 @@ function setupIconBar() {
     }
   }
   var online_users = document.getElementById("online_users");
-  /* FIXME is there a way to not update this div when it is not showing? */
-  new Ajax.PeriodicalUpdater('online_users', 'do_template?template=who_iconbar', {method: 'get', frequency: 30});
+
+       /* WARNING: VILE, SLEAZY HACK.  We determine the state of the box based on the image loaded. */
+       if ( $('expand_wholist').src.substring($('expand_wholist').src.length - 12) == "collapse.gif" ) {
+               $('online_users').style.display = 'block';
+               activate_iconbar_wholist_populat0r();
+       }
+       else {
+               $('online_users').style.display = 'none';
+       }
+
 }
 function changeIconBarEvent(event) {
   changeIconBar(event.target);
@@ -867,18 +880,44 @@ function ConfirmLogoff() {
        new Ajax.Updater(
                'md-content',
                'do_template?template=confirmlogoff',
-                {
-                        method: 'get',
+               {
+                       method: 'get',
                        onSuccess: function(cl_success) {
                                toggleModal(1);
                        }
-                }
-        );
+               }
+       );
 }
 
 
 function switch_to_lang(new_lang) {
-        p = 'push?url=' + encodeURI(window.location);
-        new Ajax.Request(p, { method: 'get' } );
+       p = 'push?url=' + encodeURI(window.location);
+       new Ajax.Request(p, { method: 'get' } );
        window.location = 'switch_language?lang=' + new_lang ;
 }
+
+
+function toggle_wholist() 
+{
+       d = $('online_users').style.display;
+
+       if (d == 'block') {
+               $('online_users').style.display = 'none';
+               $('expand_wholist').src = 'static/expand.gif';
+               wstate=0;
+       }
+
+       else {
+               $('online_users').style.display = 'block';
+               $('expand_wholist').src = 'static/collapse.gif';
+               activate_iconbar_wholist_populat0r();
+               wstate=1;
+       }
+
+       // tell the server what I did
+       p = 'toggle_wholist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
+       new Ajax.Request(p, { method: 'get' } );
+
+       return false;   /* this prevents the click from registering as a wholist button press */
+
+}