4 * \defgroup AjaxAutoCompletion ajax-powered autocompletion...
13 * \brief Call this right before wDumpContent() on any page which requires the address book popup
15 void address_book_popup(void) {
16 /* Open a new div, hidden initially, for address book popups. */
17 wprintf("</div>\n"); /* End of 'content' div */
18 wprintf("<div id=\"address_book_popup\" style=\"display:none;\">");
19 wprintf("<div id=\"address_book_popup_container_div\">");
20 wprintf("<div id=\"address_book_popup_middle_div\"></div>");
21 wprintf("<div id=\"address_book_inner_div\"></div>");
23 /* The 'address_book_popup' div will be closed by wDumpContent() */
27 * \brief Address book popup window
29 void display_address_book_middle_div(void) {
37 begin_ajax_response();
39 wprintf("<table border=0 width=100%%><tr valign=middle>");
40 wprintf("<td align=left><img src=\"static/viewcontacts_32x.gif\"></td>");
41 wprintf("<td align=center>");
44 "<select class=\"address_book_popup_title\" size=1 id=\"which_addr_book\" "
45 " onChange=\"PopulateAddressBookInnerDiv($('which_addr_book').value,'%s')\">",
49 wprintf("<option value=\"__LOCAL_USERS__\">");
50 escputs(serv_info.serv_humannode);
51 wprintf("</option>\n");
56 serv_getln(buf, sizeof buf);
57 if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
58 if (extract_int(buf, 6) == VIEW_ADDRESSBOOK) {
59 Name = (char*) malloc(len + 1);
60 len = extract_token(Name, buf, 0, '|', len);
61 Put(List, Name, len, Name, NULL);
67 while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
68 wprintf("<option value=\"");
69 urlescputs((char*)Namee);
71 escputs((char*)Namee);
72 wprintf("</option>\n");
76 wprintf("</select></form>");
79 wprintf("<td align=right "
80 "onclick=\"javascript:$('address_book_popup').style.display='none';\" "
81 "><img src=\"static/closewindow.gif\">");
82 wprintf("</td></tr></table>");
84 wprintf("<script type=\"text/javascript\">"
85 "PopulateAddressBookInnerDiv($('which_addr_book').value,'%s');"
96 * \brief Address book popup results
98 void display_address_book_inner_div() {
102 char target_label[64];
109 char saved_roomname[128];
111 begin_ajax_response();
114 wprintf("<div align=center><form onSubmit=\"return false;\">"
115 "<select multiple name=\"whichaddr\" id=\"whichaddr\" size=\"15\">\n");
117 if (!strcasecmp(bstr("which_addr_book"), "__LOCAL_USERS__")) {
119 serv_getln(buf, sizeof buf);
120 if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
121 Name = (char*) malloc(len + 1);
122 len = extract_token(Name, buf, 0, '|', len + 1);
123 Put(List, Name, len, Name, NULL);
127 it = GetNewHashPos();
128 while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
129 wprintf("<option value=\"");
130 escputs((char*)Namee);
132 escputs((char*)Namee);
133 wprintf("</option>\n");
140 safestrncpy(saved_roomname, WC->wc_roomname, sizeof saved_roomname);
141 gotoroom(bstr("which_addr_book"));
143 serv_getln(buf, sizeof buf);
144 if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
145 Name = (char*) malloc(len + 1);
146 len = extract_token(Name, buf, 0, '|', len + 1);
147 Put(List, Name, len, Name, NULL);
151 it = GetNewHashPos();
152 while (GetNextHashPos(List, it, &len, &Name, (void**)&Namee)) {
153 wprintf("<option value=\"");
154 escputs((char*)Namee);
156 escputs((char*)Namee);
157 wprintf("</option>\n");
161 gotoroom((char*)BSTR(saved_roomname)); /* TODO: get rid of typecast */
164 wprintf("</select>\n");
166 wprintf("%s: ", _("Add"));
168 num_targets = num_tokens(bstr("target_input"), '|');
169 for (i=0; i<num_targets; i+=2) {
170 extract_token(target_id, bstr("target_input"), i, '|', sizeof target_id);
171 extract_token(target_label, bstr("target_input"), i+1, '|', sizeof target_label);
172 wprintf("<INPUT TYPE=\"submit\" NAME=\"select_button\" VALUE=\"%s\" ", target_label);
173 wprintf("onClick=\"AddContactsToTarget($('%s'),$('whichaddr'));\">", target_id);
176 /* This 'close window' button works. Omitting it because we already have a close button
177 * in the upper right corner, and this one takes up space.
179 wprintf("<INPUT TYPE=\"submit\" NAME=\"close_button\" VALUE=\"%s\" ", _("Close window"));
180 wprintf("onclick=\"javascript:$('address_book_popup').style.display='none';\">");
183 wprintf("</form></div>\n");