]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/wclib.js
More compfort for inline vieweable attachments
[citadel.git] / webcit / static / wclib.js
index 889b068e70f11b1b96ebec0c632263bc52096771..cf409d363c7a352599cdd6935f847f66c971902c 100644 (file)
@@ -47,6 +47,19 @@ function strcmp ( str1, str2 ) {
     return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
 }
 
+
+
+function ToggleVisibility ($Which)
+{
+       if (document.getElementById)
+       {
+               if (document.getElementById($Which).style.display  == "none")
+                       document.getElementById($Which).style.display  = "inline";
+               else
+                       document.getElementById($Which).style.display  = "none";
+       }
+}
+
 function emptyElement(element) {
   childNodes = element.childNodes;
   for(var i=0; i<childNodes.length; i++) {
@@ -144,6 +157,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,9 +181,16 @@ function setupIconBar() {
     }
   }
   var online_users = document.getElementById("online_users");
-  if (online_users.offsetParent != null && online_users.offsetTop > 0) {
-    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);
@@ -317,7 +342,7 @@ function roomListDropHandler(target, dropped) {
     for(msgId in currentlyMarkedRows) { //defined in summaryview.js
       msgIds += ","+msgId;
     }
-    var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
+    var mvCommand = encodeURI("g_cmd=MOVE " + msgIds + "|"+room+"|0");
     new Ajax.Request('ajax_servcmd', {
       method: 'post',
          parameters: mvCommand,
@@ -594,7 +619,7 @@ function ctdl_ts_getInnerText(el) {
 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
 function CtdlLoadScreen(elementid) {
 var elem = document.getElementById(elementid);
-elem.innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
+elem.innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br></div>";
 }
 
 
@@ -616,7 +641,7 @@ function PopOpenAddressBook(target_input) {
 }
 
 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
-       $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
+       $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br></div>";
        p = 'which_addr_book=' + which_addr_book
          + '&target_input=' + target_input
          + '&r=' + CtdlRandomString();
@@ -853,10 +878,11 @@ function RefreshSMTPqueueDisplay() {
 }
 
 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
+       var p = encodeURI('g_cmd=DELE ' + msgnum1 + ',' + msgnum2);
        new Ajax.Request(
                'ajax_servcmd', {
                        method: 'post',
-                       parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2,
+                       parameters: p,
                        onComplete: RefreshSMTPqueueDisplay()
                }
        );
@@ -867,34 +893,43 @@ function ConfirmLogoff() {
        new Ajax.Updater(
                'md-content',
                'do_template?template=confirmlogoff',
-                {
-                        method: 'get',
+               {
+                       method: 'get',
                        onSuccess: function(cl_success) {
                                toggleModal(1);
                        }
-                }
-        );
+               }
+       );
 }
 
 
-/*
- * Wrapper script to require logging in before completing an action
- */
-function GetLoggedInFirst(destination_url) {
+function switch_to_lang(new_lang) {
+       p = 'push?url=' + encodeURI(window.location);
+       new Ajax.Request(p, { method: 'get' } );
+       window.location = 'switch_language?lang=' + new_lang ;
+}
 
-       /* If logged in already, go directly to the destination. */
-       /* FIXME implement this */
 
-       /* If not logged in, go modal and ask the user to log in first. */
-       p = 'do_template?template=get_logged_in?destination_url=' + destination_url;
-       new Ajax.Updater(
-               'md-content',
-               p,
-                {
-                        method: 'get',
-                       onSuccess: function(cl_success) {
-                               toggleModal(1);
-                       }
-                }
-        );
+function toggle_wholist() 
+{
+       /* 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 = '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 */
+
 }