]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/wclib.js
Allow multiple addresses to be selected.
[citadel.git] / webcit / static / wclib.js
index 9deeec67843f70d2173188cc0ee05fab06ed400c..ac8c4284bf51fff23afc7fe3dbfebc5887050168 100644 (file)
@@ -18,6 +18,11 @@ if (window.navigator.userAgent.toLowerCase().match("gecko")) {
 var ns6=document.getElementById&&!document.all;
 
 
+function CtdlRandomString()  {
+       return((Math.random()+'').substr(3));
+}
+
+
 
 // We love string tokenizers.
 function extract_token(source_string, token_num, delimiter) {
@@ -552,8 +557,7 @@ function ctdl_ts_getInnerText(el) {
 //
 function add_new_note() {
 
-       new_eid = Math.random() + '';
-       new_eid = new_eid.substr(3);
+       new_eid = CtdlRandomString();
 
        $('new_notes_here').innerHTML = $('new_notes_here').innerHTML
                + '<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">'
@@ -658,13 +662,48 @@ function CtdlShowUserInfoPopup(Element) {
 }
 
 
-// Pop open the address book
-function PopOpenAddressBook() {
+
+// Pop open the address book (target_input is the INPUT field to populate)
+
+function PopOpenAddressBook(target_input) {
+       $('address_book_popup').style.display = 'block';
+       p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
+       new Ajax.Updater(
+               'address_book_popup_middle_div',
+               'display_address_book_middle_div',
+               {
+                       method: 'get',
+                       parameters: p,
+                       evalScripts: true
+               }
+       );
+       Nifty('div#address_book_popup_container_div','big transparent');
+}
+
+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>";
-       Effect.Appear('address_book_popup', { duration: 0.5 } );
+       p = 'which_addr_book=' + which_addr_book
+         + '&target_input=' + target_input
+         + '&r=' + CtdlRandomString();
        new Ajax.Updater(
                'address_book_inner_div',
                'display_address_book_inner_div',
-               { method: 'get', parameters: Math.random() }
+               {
+                       method: 'get',
+                       parameters: p
+               }
        );
 }
+
+// What happens when a contact is selected from the address book popup
+// (populate the specified target)
+
+function AddContactsToTarget(target, whichaddr) {
+       while (whichaddr.selectedIndex != -1) {
+               if (target.value.length > 0) {
+                       target.value = target.value + ', ';
+               }
+               target.value = target.value + whichaddr.value;
+               whichaddr.options[whichaddr.selectedIndex].selected = false;
+       }
+}