* which_div_expanded is now persistent across page loads
authorArt Cancro <ajc@citadel.org>
Thu, 1 Dec 2005 22:43:22 +0000 (22:43 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 1 Dec 2005 22:43:22 +0000 (22:43 +0000)
webcit/ChangeLog
webcit/roomops.c
webcit/static/wclib.js
webcit/webcit.c
webcit/webcit.h

index eab62b0e9ef17cf55a4c8a931703ae4da059fe01..415a17eae0c49bba33146ff21d2e16fbba319372 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Thu Dec  1 17:42:48 EST 2005 ajc
+* which_div_expanded is now persistent across page loads
+
 Thu Dec  1 17:15:32 EST 2005 ajc
 * Clicking on the expanded floor div collapses it.
 
index e05ef719061819db3384258b117d3b706319c251..e461bcb1e95354f62c0726a473e45bac1758cf5f 100644 (file)
@@ -2521,6 +2521,12 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
 }
 
 
+void set_floordiv_expanded(char *which_floordiv) {
+       begin_ajax_response();
+       safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
+       end_ajax_response();
+}
+
 /*
  *
  */
@@ -2529,6 +2535,7 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
        char floor_name[256];
        char old_floor_name[256];
        char floordivtitle[256];
+       char floordiv_id[32];
        int levels, oldlevels;
        int i, t;
        int num_drop_targets = 0;
@@ -2556,10 +2563,14 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
                if (levels == 1) {
                        /* Begin floor */
                        stresc(floordivtitle, floor_name, 0, 0);
+                       sprintf(floordiv_id, "floordiv%d", i);
                        wprintf("<span class=\"ib_roomlist_floor\" "
-                               "onClick=\"expand_floor('floordiv%d')\">"
-                               "%s</span><br>\n", i, floordivtitle);
-                       wprintf("<div id=\"floordiv%d\" style=\"display:none\">", i);
+                               "onClick=\"expand_floor('%s')\">"
+                               "%s</span><br>\n", floordiv_id, floordivtitle);
+                       wprintf("<div id=\"%s\" style=\"display:%s\">",
+                               floordiv_id,
+                               (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
+                       );
                }
 
                oldlevels = levels;
@@ -2640,6 +2651,9 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
        }
 
        wprintf("num_drop_targets = %d;\n", num_drop_targets);
+       if (strlen(WC->floordiv_expanded) > 1) {
+               wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
+       }
 
        wprintf("\">\n");
        /* END: The old invisible pixel trick, to get our JavaScript to initialize */
index e0d643c360bc0b7e336bcfbebafa10efe6ad6a7b..8371add04ef8d718adae8967814472426fbc0ea8 100644 (file)
@@ -66,7 +66,9 @@ function switch_to_room_list() {
 
 function expand_floor(floor_div) {
        if (which_div_expanded != null) {
-               $(which_div_expanded).style.display = 'none' ;
+               if ($(which_div_expanded) != null) {
+                       $(which_div_expanded).style.display = 'none' ;
+               }
        }
        if (which_div_expanded == floor_div) {
                which_div_expanded = null;
@@ -74,6 +76,13 @@ function expand_floor(floor_div) {
        }
        $(floor_div).style.display = 'block';
        which_div_expanded = floor_div;
+
+       // notify the server of what we did
+       new Ajax.Request(
+               'set_floordiv_expanded/'+floor_div, {
+                       method: 'post',
+               }
+       );
 }
 
 function switch_to_menu_buttons() {
index 8083f49f2f33c1dada5d33f3023aa235fff55d98..26a7c43f776b4997cdaa9e1425f8e293574d6d5c 100644 (file)
@@ -1499,6 +1499,8 @@ void session_loop(struct httprequest *req)
                recp_autocomplete(bstr("cc"));
        } else if (!strcasecmp(action, "bcc_autocomplete")) {
                recp_autocomplete(bstr("bcc"));
+       } else if (!strcasecmp(action, "set_floordiv_expanded")) {
+               set_floordiv_expanded(arg1);
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1, 1, 1, 0, 0, 0);
                wprintf("Session: %d<hr />\n", WC->wc_session);
index 66cebdb8b069acb18040203fd87593f40becd7aa..f30d1530eb59cb68a3716501673cb3eaaddb50d6 100644 (file)
@@ -346,6 +346,7 @@ struct wcsession {
        time_t cache_timestamp;
 
        int current_iconbar;            /* What's currently in the iconbar? */
+       char floordiv_expanded[32];     /* which floordiv currently expanded */
 };
 
 /* values for WC->current_iconbar */
@@ -616,6 +617,7 @@ void commit_iconbar(void);
 int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
 void spawn_another_worker_thread(void);
 void display_rss(char *roomname, char *request_method);
+void set_floordiv_expanded(char *which_floordiv);
 
 void embed_room_banner(char *, int);
 /* navbar types that can be passed to embed_room_banner */