From 799bbb4e79d11e17b56efb7b195c988219fe634f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 1 Dec 2005 22:43:22 +0000 Subject: [PATCH] * which_div_expanded is now persistent across page loads --- webcit/ChangeLog | 3 +++ webcit/roomops.c | 20 +++++++++++++++++--- webcit/static/wclib.js | 11 ++++++++++- webcit/webcit.c | 2 ++ webcit/webcit.h | 2 ++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index eab62b0e9..415a17eae 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -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. diff --git a/webcit/roomops.c b/webcit/roomops.c index e05ef7190..e461bcb1e 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -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("" - "%s
\n", i, floordivtitle); - wprintf("
", i); + "onClick=\"expand_floor('%s')\">" + "%s
\n", floordiv_id, floordivtitle); + wprintf("
", + 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 */ diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index e0d643c36..8371add04 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -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() { diff --git a/webcit/webcit.c b/webcit/webcit.c index 8083f49f2..26a7c43f7 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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
\n", WC->wc_session); diff --git a/webcit/webcit.h b/webcit/webcit.h index 66cebdb8b..f30d1530e 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -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 */ -- 2.39.2