addressbook_popup.c

00001 /*
00002  * $Id: addressbook_popup.c 5147 2007-05-08 15:36:22Z ajc $
00003  *
00004  * \defgroup AjaxAutoCompletion ajax-powered autocompletion...
00005  * \ingroup ClientPower
00006  */
00007 
00009 #include "webcit.h"
00010 
00011 
00015 void address_book_popup(void) {
00016         /* Open a new div, hidden initially, for address book popups. */
00017         wprintf("</div>\n");    /* End of 'content' div */
00018         wprintf("<div id=\"address_book_popup\" style=\"display:none;\">");
00019         wprintf("<div id=\"address_book_popup_container_div\">");
00020         wprintf("<div id=\"address_book_popup_middle_div\"></div>");
00021         wprintf("<div id=\"address_book_inner_div\"></div>");
00022         wprintf("</div>");
00023         /* The 'address_book_popup' div will be closed by wDumpContent() */
00024 }
00025 
00029 void display_address_book_middle_div(void) {
00030         char buf[256];
00031         char ebuf[256];
00032 
00033         begin_ajax_response();
00034 
00035         wprintf("<table border=0 width=100%%><tr valign=middle>");
00036         wprintf("<td align=left><img src=\"static/viewcontacts_32x.gif\"></td>");
00037         wprintf("<td align=center>");
00038 
00039         wprintf("<form>"
00040                 "<select class=\"address_book_popup_title\" size=1 id=\"which_addr_book\" "
00041                 " onChange=\"PopulateAddressBookInnerDiv($('which_addr_book').value,'%s')\">",
00042                 bstr("target_input")
00043         );
00044 
00045         wprintf("<option value=\"__LOCAL_USERS__\">");
00046         escputs(serv_info.serv_humannode);
00047         wprintf("</option>\n");
00048 
00049         serv_puts("LKRA");
00050         serv_getln(buf, sizeof buf);
00051         if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00052                 if (extract_int(buf, 6) == VIEW_ADDRESSBOOK) {
00053                         extract_token(ebuf, buf, 0, '|', sizeof ebuf);
00054                         wprintf("<option value=\"");
00055                         urlescputs(ebuf);
00056                         wprintf("\">");
00057                         escputs(ebuf);
00058                         wprintf("</option>\n");
00059                 }
00060         }
00061         wprintf("</select></form>");
00062 
00063         wprintf("</td>");
00064         wprintf("<td align=right "
00065                 "onclick=\"javascript:$('address_book_popup').style.display='none';\" "
00066                 "><img src=\"static/closewindow.gif\">");
00067         wprintf("</td></tr></table>");
00068 
00069         wprintf("<script type=\"text/javascript\">"
00070                 "PopulateAddressBookInnerDiv($('which_addr_book').value,'%s');"
00071                 "</script>\n",
00072                 bstr("target_input")
00073         );
00074 
00075         end_ajax_response();
00076 }
00077 
00078 
00079 
00083 void display_address_book_inner_div() {
00084         char buf[256];
00085         char username[256];
00086         int num_targets = 0;
00087         char target_id[64];
00088         char target_label[64];
00089         int i;
00090 
00091         begin_ajax_response();
00092 
00093         wprintf("<div align=center><form onSubmit=\"return false;\">"
00094                 "<select multiple name=\"whichaddr\" id=\"whichaddr\" size=\"15\">\n");
00095 
00096         if (!strcasecmp(bstr("which_addr_book"), "__LOCAL_USERS__")) {
00097                 serv_puts("LIST");
00098                 serv_getln(buf, sizeof buf);
00099                 if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00100                         extract_token(username, buf, 0, '|', sizeof username);
00101                         wprintf("<option value=\"");
00102                         escputs(username);
00103                         wprintf("\">");
00104                         escputs(username);
00105                         wprintf("</option>\n");
00106                 }
00107         }
00108 
00109         else {
00110                 serv_printf("GOTO %s", bstr("which_addr_book"));
00111                 serv_getln(buf, sizeof buf);
00112                 serv_puts("DVCA");
00113                 serv_getln(buf, sizeof buf);
00114                 if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00115                         wprintf("<option value=\"");
00116                         escputs(buf);
00117                         wprintf("\">");
00118                         escputs(buf);
00119                         wprintf("</option>\n");
00120                 }
00121         }
00122 
00123         wprintf("</select>\n");
00124 
00125         wprintf("%s: ", _("Add"));
00126 
00127         num_targets = num_tokens(bstr("target_input"), '|');
00128         for (i=0; i<num_targets; i+=2) {
00129                 extract_token(target_id, bstr("target_input"), i, '|', sizeof target_id);
00130                 extract_token(target_label, bstr("target_input"), i+1, '|', sizeof target_label);
00131                 wprintf("<INPUT TYPE=\"submit\" NAME=\"select_button\" VALUE=\"%s\" ", target_label);
00132                 wprintf("onClick=\"AddContactsToTarget($('%s'),$('whichaddr'));\">", target_id);
00133         }
00134 
00135         /* This 'close window' button works.  Omitting it because we already have a close button
00136          * in the upper right corner, and this one takes up space.
00137          *
00138         wprintf("<INPUT TYPE=\"submit\" NAME=\"close_button\" VALUE=\"%s\" ", _("Close window"));
00139         wprintf("onclick=\"javascript:$('address_book_popup').style.display='none';\">");
00140          */
00141 
00142         wprintf("</form></div>\n");
00143 
00144         end_ajax_response();
00145 }
00146 
00147 

Generated on Wed Jun 20 23:13:07 2007 for webcit by  doxygen 1.5.2