$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.
wprintf("</ul>\n");
+ /*
wprintf("<div id=\"dropstuff\" style=\"font-size:6pt\">");
wprintf("Drag to trash here...<br>");
wprintf("</div>");
+ */
wprintf("</div>\n");
}
/* 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");
}
int levels, oldlevels;
int i, t;
int nf;
+ int num_drop_targets = 0;
strcpy(floor_name, "");
strcpy(old_floor_name, "");
&& (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(" ");
if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
if (fold[i].selectable) {
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 */
}
}
+
+// 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;
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;
}
-// 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' } );
-}
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");
}