* copy daves great handler script and modify it to fit the simpler needs of webcit.
[citadel.git] / webcit / addressbook_popup.c
index 3004a826095afc5a3023e75efe2f6bc914ba1b6d..230e09dc3d7369e48cbb7fa69d2b71723346bb60 100644 (file)
@@ -1,16 +1,14 @@
 /*
  * $Id$
  *
- * \defgroup AjaxAutoCompletion ajax-powered autocompletion...
- * \ingroup ClientPower
+ * AJAX-powered auto-completion
  */
 
-/*@{*/
 #include "webcit.h"
 
 
-/**
- * \brief Call this right before wDumpContent() on any page which requires the address book popup
+/*
+ * Call this right before wDumpContent() on any page which requires the address book popup
  */
 void address_book_popup(void) {
        /* Open a new div, hidden initially, for address book popups. */
@@ -23,8 +21,8 @@ void address_book_popup(void) {
        /* The 'address_book_popup' div will be closed by wDumpContent() */
 }
 
-/**
- * \brief Address book popup window
+/*
+ * Address book popup window
  */
 void display_address_book_middle_div(void) {
        char buf[256];
@@ -51,7 +49,7 @@ void display_address_book_middle_div(void) {
        wprintf("</option>\n");
 
        
-       List = NewHash();
+       List = NewHash(1, NULL);
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -62,7 +60,7 @@ void display_address_book_middle_div(void) {
                }
        }
 
-       SortByHashKey(List);
+       SortByHashKey(List, 1);
        it = GetNewHashPos();
        while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
                wprintf("<option value=\"");
@@ -92,8 +90,8 @@ void display_address_book_middle_div(void) {
 
 
 
-/**
- * \brief Address book popup results
+/*
+ * Address book popup results
  */
 void display_address_book_inner_div() {
        char buf[256];
@@ -110,7 +108,7 @@ void display_address_book_inner_div() {
 
        begin_ajax_response();
 
-       List = NewHash();
+       List = NewHash(1, NULL);
        wprintf("<div align=center><form onSubmit=\"return false;\">"
                "<select multiple name=\"whichaddr\" id=\"whichaddr\" size=\"15\">\n");
 
@@ -123,7 +121,7 @@ void display_address_book_inner_div() {
                        Put(List, Name, len, Name, NULL);
 
                }
-               SortByHashKey(List);
+               SortByHashKey(List, 1);
                it = GetNewHashPos();
                while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
                        wprintf("<option value=\"");
@@ -147,7 +145,7 @@ void display_address_book_inner_div() {
                        Put(List, Name, len, Name, NULL);
 
                }
-               SortByHashKey(List);
+               SortByHashKey(List, 1);
                it = GetNewHashPos();
                while (GetNextHashPos(List, it, &len, &Name, (void**)&Namee)) {
                        wprintf("<option value=\"");
@@ -158,7 +156,7 @@ void display_address_book_inner_div() {
                }
                DeleteHashPos(&it);
                DeleteHash(&List);
-               gotoroom((char*)BSTR(saved_roomname)); /* TODO: get rid of typecast */
+               gotoroom(saved_roomname);
        }
 
        wprintf("</select>\n");
@@ -186,4 +184,12 @@ void display_address_book_inner_div() {
 }
 
 
-/** @} */
+
+
+void 
+InitModule_ADDRBOOK_POPUP
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_address_book_middle_div"), display_address_book_middle_div, 0);
+       WebcitAddUrlHandler(HKEY("display_address_book_inner_div"), display_address_book_inner_div, 0);
+}