From dff335424e39a7370b3b56b5c7fb69e43aa4eb88 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 30 Nov 2005 04:22:26 +0000 Subject: [PATCH] * Completed the JavaScript-detection of room names in the iconbar as drop targets. For now it simply displays an alert box. Doing the actual message move will only require some simple glue code... --- webcit/ChangeLog | 5 +++ webcit/iconbar.c | 4 +++ webcit/roomops.c | 36 ++++++++++++++++---- webcit/static/wclib.js | 76 +++++++++++++++++++++++++----------------- webcit/webcit.c | 7 ++-- 5 files changed, 89 insertions(+), 39 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 288be7d18..2fab0ee41 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,5 +1,10 @@ $Id$ +Tue Nov 29 23:20:23 EST 2005 ajc +* Completed the JavaScript-detection of room names in the iconbar as drop + targets. For now it simply displays an alert box. Doing the actual + message move will only require some simple glue code... + Mon Nov 28 23:04:13 EST 2005 ajc * Made the iconbar room list somewhat usable (collapse/expand). It is not yet a drop target, though, which is why we did all this in the first place. diff --git a/webcit/iconbar.c b/webcit/iconbar.c index f1d4c8ed4..ca37f213a 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -309,9 +309,11 @@ void do_iconbar(void) { wprintf("\n"); + /* wprintf("
"); wprintf("Drag to trash here...
"); wprintf("
"); + */ wprintf("\n"); } @@ -381,9 +383,11 @@ void do_iconbar_roomlist(void) { /* embed the room list */ list_all_rooms_by_floor("iconbar"); + /* wprintf("
"); wprintf("Drag to trash here...
"); wprintf("
"); + */ wprintf("\n"); } diff --git a/webcit/roomops.c b/webcit/roomops.c index 7a1131929..d7a98a2a1 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -2542,6 +2542,7 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { int levels, oldlevels; int i, t; int nf; + int num_drop_targets = 0; strcpy(floor_name, ""); strcpy(old_floor_name, ""); @@ -2560,23 +2561,23 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { && (strlen(old_floor_name) > 0) ) { /* End inner box */ wprintf("
\n"); - wprintf("\n"); /* nfmd */ + wprintf("\n"); /* floordiv */ } strcpy(old_floor_name, floor_name); if (levels == 1) { /* Begin floor */ stresc(boxtitle, floor_name, 1, 0); - svprintf("BOXTITLE", WCS_STRING, boxtitle); wprintf("" + "onClick=\"expand_floor('floordiv%d')\">" "%s
\n", i, boxtitle); - wprintf("
", i); + wprintf("
", i); } oldlevels = levels; if (levels > 1) { + wprintf("
", i); wprintf(" "); if (levels>2) for (t=0; t<(levels-2); ++t) wprintf("   "); if (fold[i].selectable) { @@ -2605,10 +2606,33 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { if (!strcasecmp(fold[i].name, "My Folders|Mail")) { wprintf(" (INBOX)"); } - wprintf("
\n"); + wprintf("
"); + wprintf("
\n"); /* roomdiv */ + } + } + wprintf("
\n"); /* floordiv */ + + + /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */ + wprintf(" 1) { + wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i); + wprintf("drop_targets_roomnames[%d]='", num_drop_targets); + jsescputs(fold[i].room); + wprintf("';\n"); + ++num_drop_targets; } } - wprintf("
\n"); /* nfmd */ + + wprintf("num_drop_targets = %d;\n", num_drop_targets); + + 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 f4f32e7a0..6bfc7e65c 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -52,6 +52,32 @@ function activate_entmsg_autocompleters() { } + +// Toggle the icon bar between menu/roomlist... +var which_div_expanded = null; +var num_drop_targets = 0; +var drop_targets_elements = new Array(); +var drop_targets_roomnames = new Array(); + +function switch_to_room_list() { + new Ajax.Updater('iconbar', 'iconbar_ajax_rooms', { method: 'get' } ); +} + +function expand_floor(floor_div) { + if (which_div_expanded != null) { + $(which_div_expanded).style.display = 'none' ; + } + $(floor_div).style.display = 'block'; + which_div_expanded = floor_div; +} + +function switch_to_menu_buttons() { + which_div_expanded = null; + num_drop_targets = 0; + new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } ); +} + + // Static variables for mailbox view... // var CtdlNumMsgsSelected = 0; @@ -310,24 +336,34 @@ function CtdlMoveMsgMouseUp(evt) { mm_div = null; } + if (num_drop_targets < 1) { // nowhere to drop + return true; + } + // Did we release the mouse button while hovering over a drop target? // NOTE: this only works cross-browser because the iconbar div is always // positioned at 0,0. Browsers differ in whether the 'offset' // functions return pos relative to the document or parent. - x = (ns6 ? evt.clientX : event.clientX); - y = (ns6 ? evt.clientY : event.clientY); + for (i=0; i= l) && (x <= r) && (y >= t) && (y <= b) ) { - // Yes, we dropped it on a hotspot. Just delete for now... FIXME - CtdlDeleteSelectedMessages(evt); + /* alert('Offsets are: ' + l + ' ' + t + ' ' + r + ' ' + b + '.'); */ + + if ( (x >= l) && (x <= r) && (y >= t) && (y <= b) ) { + // Yes, we dropped it on a hotspot. Just delete for now... FIXME + // CtdlDeleteSelectedMessages(evt); + alert('you dropped on ' + drop_targets_roomnames[i]); + } } return true; @@ -356,23 +392,3 @@ function ctdl_ts_getInnerText(el) { } -// icon bar toggler tabs... - -var which_div_expanded = null; - -function switch_to_room_list() { - new Ajax.Updater('iconbar', 'iconbar_ajax_rooms', { method: 'get' } ); -} - -function expand_floor(floor_div) { - if (which_div_expanded != null) { - $(which_div_expanded).style.display = 'none' ; - } - $(floor_div).style.display = 'block'; - which_div_expanded = floor_div; -} - -function switch_to_menu_buttons() { - which_div_expanded = null; - new Ajax.Updater('iconbar', 'iconbar_ajax_menu', { method: 'get' } ); -} diff --git a/webcit/webcit.c b/webcit/webcit.c index c58876f9b..76080040e 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -832,17 +832,18 @@ void ajax_servcmd(void) begin_ajax_response(); - /* lprintf(9, "Sending cmd: %s\n", bstr("g_cmd")); */ + lprintf(9, "Sending cmd: %s\n", bstr("g_cmd")); serv_printf("%s", bstr("g_cmd")); serv_getln(buf, sizeof buf); - /* lprintf(9, " Response: %s\n", buf); */ + wprintf("%s\n", buf); + lprintf(9, " Response: %s\n", buf); if (buf[0] == '8') { serv_printf("\n\n000"); } if ((buf[0] == '1') || (buf[0] == '8')) { while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) { - /* maybe do something with it? */ + wprintf("%s\n", gcontent); } wprintf("000"); } -- 2.39.2