* Completed the JavaScript-detection of room names in the iconbar as drop
authorArt Cancro <ajc@citadel.org>
Wed, 30 Nov 2005 04:22:26 +0000 (04:22 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 30 Nov 2005 04:22:26 +0000 (04:22 +0000)
  targets.  For now it simply displays an alert box.  Doing the actual
  message move will only require some simple glue code...

webcit/ChangeLog
webcit/iconbar.c
webcit/roomops.c
webcit/static/wclib.js
webcit/webcit.c

index 288be7d18d39a62b1e7d186a5e608b63c12896fd..2fab0ee41e205afc8ad1ffae84b698257cf55dae 100644 (file)
@@ -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.
index f1d4c8ed43291f958f936f55ab2140f9448d7569..ca37f213aca6bbdb7b578b24f65cedaaa4845586 100644 (file)
@@ -309,9 +309,11 @@ void do_iconbar(void) {
 
        wprintf("</ul>\n");
 
+       /*
        wprintf("<div id=\"dropstuff\" style=\"font-size:6pt\">");
        wprintf("Drag to trash here...<br>");
        wprintf("</div>");
+       */
 
        wprintf("</div>\n");
 }
@@ -381,9 +383,11 @@ void do_iconbar_roomlist(void) {
        /* embed the room list */
        list_all_rooms_by_floor("iconbar");
 
+       /*
        wprintf("<div id=\"dropstuff\" style=\"font-size:6pt\">");
        wprintf("Drag to trash here...<br>");
        wprintf("</div>");
+       */
 
        wprintf("</div>\n");
 }
index 7a1131929f186e0c655a38d7f6275fd4dcd53484..d7a98a2a130a07781b4daf4b25ad9138a742c3f1 100644 (file)
@@ -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("<br>\n");
-                       wprintf("</div>\n");    /* nfmd */
+                       wprintf("</div>\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("<span class=\"ib_roomlist_floor\" "
-                               "onClick=\"expand_floor('nfmd%d')\">"
+                               "onClick=\"expand_floor('floordiv%d')\">"
                                "%s</span><br>\n", i, boxtitle);
-                       wprintf("<div id=\"nfmd%d\" style=\"display:none\">", i);
+                       wprintf("<div id=\"floordiv%d\" style=\"display:none\">", i);
                }
 
                oldlevels = levels;
 
                if (levels > 1) {
+                       wprintf("<div id=\"roomdiv%d\">", i);
                        wprintf("&nbsp;");
                        if (levels>2) for (t=0; t<(levels-2); ++t) wprintf("&nbsp;&nbsp;&nbsp;");
                        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("<br />\n");
+                       wprintf("<br />");
+                       wprintf("</div>\n");    /* roomdiv */
+               }
+       }
+       wprintf("</div>\n");    /* floordiv */
+
+
+       /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
+       wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
+
+       num_drop_targets = 0;
+
+       for (i=0; i<max_folders; ++i) {
+               levels = num_tokens(fold[i].name, '|');
+               if (levels > 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("</div>\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 */
 }
 
 
index f4f32e7a0c9c019c62a6eea995609401e5b788a2..6bfc7e65c18f705d4b960202b48fafb866d8d873 100644 (file)
@@ -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<num_drop_targets; ++i) {
 
-       l = parseInt($('dropstuff').offsetLeft);
-       t = parseInt($('dropstuff').offsetTop);
-       r = parseInt($('dropstuff').offsetLeft) + parseInt($('dropstuff').offsetWidth);
-       b = parseInt($('dropstuff').offsetTop) + parseInt($('dropstuff').offsetHeight);
+               x = (ns6 ? evt.clientX : event.clientX);
+               y = (ns6 ? evt.clientY : event.clientY);
 
-       // alert('Offsets are: ' + l + ' ' + t + ' ' + r + ' ' + b + '.');
+               l = parseInt(drop_targets_elements[i].offsetLeft);
+               t = parseInt(drop_targets_elements[i].offsetTop);
+               r = parseInt(drop_targets_elements[i].offsetLeft)
+                 + parseInt(drop_targets_elements[i].offsetWidth);
+               b = parseInt(drop_targets_elements[i].offsetTop)
+                 + parseInt(drop_targets_elements[i].offsetHeight);
 
-       if ( (x >= 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' } );
-}
index c58876f9b473e6e2039101342def2018b5802803..76080040e2c02e07f591ba381f203278263ce949 100644 (file)
@@ -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");
        }