* The checkboxes are gone! Implemented ajax delete of selected messages,
authorArt Cancro <ajc@citadel.org>
Sat, 5 Nov 2005 05:51:39 +0000 (05:51 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 5 Nov 2005 05:51:39 +0000 (05:51 +0000)
  via either the Delete button or the Delete key.

webcit/ChangeLog
webcit/messages.c
webcit/static/wclib.js
webcit/webcit.c
webcit/webcit.h

index 613890bd75115fd5567a2243fc51934f53ee7515..76de0260b9eaa8e533bc7764974ac77c0623b595 100644 (file)
@@ -1,5 +1,9 @@
 $Id$
 
+Sat Nov  5 00:50:25 EST 2005 ajc
+* The checkboxes are gone!  Implemented ajax delete of selected messages,
+  via either the Delete button or the Delete key.
+
 Fri Nov  4 23:47:23 EST 2005 ajc
 * Multi select using ctrl now handles the condition of a message already being
   selected and the user doing ctrl-click to deselect it.
index 270c34cf2ae988402a09ebb421e542623b98c67d..2988b7539bfe9d9721105ce9e494b5fe7834d853 100644 (file)
@@ -1354,11 +1354,6 @@ void display_summarized(int num) {
        escputs(datebuf);
        wprintf("</td>");
 
-       wprintf("<td><input type=\"checkbox\" name=\"msg_%ld\" value=\"yes\">",
-               WC->summ[num].msgnum
-       );
-       wprintf("</td>");
-
        wprintf("</tr>\n");
 }
 
@@ -2007,21 +2002,31 @@ void readloop(char *oper)
        }
 
        if (is_summary) {
-               wprintf("</div>");              /* end of 'content' div */
+               wprintf("</div>\n");            /* end of 'content' div */
+
+               wprintf("<script language=\"javascript\" type=\"text/javascript\">"
+                       " document.onkeydown = CtdlMsgListKeyPress;     "
+                       " if (document.layers) {                        "
+                       "       document.captureEvents(Event.KEYPRESS); "
+                       " }                                             "
+                       "</script>\n"
+               );
 
+               /* note that Date and Delete are now in the same column */
                wprintf("<div id=\"message_list\">"
 
                        "<div id=\"fix_scrollbar_bug\">\n"
 
-                       "<form name=\"msgomatic\" "
-                       "method=\"POST\" action=\"do_stuff_to_msgs\">\n"
-
                        "<span class=\"mailbox_summary\">"
                        "<table id=\"summary_headers\" rules=rows cellspacing=0 style=\"width:100%%\"><tr>"
                        "<td><b><i>%s</i></b> %s</td>"
                        "<td><b><i>%s</i></b> %s</td>"
-                       "<td><b><i>%s</i></b> %s</td>"
-                       "<td><input type=\"submit\" name=\"delete_button\" style=\"font-size:6pt\" value=\"%s\"></td>"
+                       "<td><b><i>%s</i></b> %s"
+                       "&nbsp;"
+                       "<input type=\"submit\" name=\"delete_button\" style=\"font-size:6pt\" "
+                       " onClick=\"CtdlDeleteSelectedMessages(event)\" "
+                       " value=\"%s\">"
+                       "</td>"
                        "</tr>\n"
                        ,
                        _("Subject"),   subjsort_button,
@@ -2084,23 +2089,11 @@ void readloop(char *oper)
        }
 
        if (is_summary) {
-               wprintf("</table></span></form>"
+               wprintf("</table></span>"
                        "</div>\n");                    /* end of 'fix_scrollbar_bug' div */
                wprintf("</div>");                      /* end of 'message_list' div */
 
                wprintf("<div id=\"preview_pane\">");   /* The preview pane will initially be empty */
-
-               /* Now register each message (whose element ID is "m9999",
-                * where "9999" is the message number) as draggable.
-                * (NOTE: uses script.aculo.us draggables, which will probably not be
-                * adequate for this purpose.)
-               wprintf("<script type=\"text/javascript\">\n");
-               for (a = 0; a < nummsgs; ++a) {
-                       wprintf("new Draggable('m%ld',{revert:true});\n",
-                               WC->summ[a].msgnum);
-               }
-               wprintf("</script>\n");
-                */
        }
 
        /* Bump these because although we're thinking in zero base, the user
@@ -2117,9 +2110,6 @@ void readloop(char *oper)
           if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
              && (!is_notes) && (!is_singlecard) && (!is_summary)) {
 
-               wprintf("<form name=\"msgomatic\" "
-                       "method=\"POST\" action=\"do_stuff_to_msgs\">\n");
-
                wprintf(_("Reading #"), lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
@@ -2192,8 +2182,6 @@ void readloop(char *oper)
                );
        
                wprintf("</select>");
-
-               wprintf("</form>\n");
            }
        }
 
@@ -2784,55 +2772,3 @@ void move_msg(void)
        readloop("readnew");
 
 }
-
-/*
- * This gets called when a user selects multiple messages in a summary
- * list and then clicks to perform a transformation of some sort on them
- * (such as deleting them).
- */
-void do_stuff_to_msgs(void) {
-       char buf[256];
-
-       struct stuff_t {
-               struct stuff_t *next;
-               long msgnum;
-       };
-
-       struct stuff_t *stuff = NULL;
-       struct stuff_t *ptr;
-       int delete_button_pressed = 0;
-
-
-       serv_puts("MSGS ALL");
-       serv_getln(buf, sizeof buf);
-
-       if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               ptr = malloc(sizeof(struct stuff_t));
-               ptr->msgnum = atol(buf);
-               ptr->next = stuff;
-               stuff = ptr;
-       }
-
-       if (strlen(bstr("delete_button")) > 0) {
-               delete_button_pressed = 1;
-       }
-
-       while (stuff != NULL) {
-
-               sprintf(buf, "msg_%ld", stuff->msgnum);
-               if (!strcasecmp(bstr(buf), "yes")) {
-
-                       if (delete_button_pressed) {
-                               serv_printf("MOVE %ld|_TRASH_|0", stuff->msgnum);
-                               serv_getln(buf, sizeof buf);
-                       }
-
-               }
-
-               ptr = stuff->next;
-               free(stuff);
-               stuff = ptr;
-       }
-
-       readloop("readfwd");
-}
index 764801f994462635aac8bef417b2de520bc5e2f1..f88a43821a58f0c8be18641c39ad2c9a3a141842 100644 (file)
@@ -1,7 +1,7 @@
 //
 // $Id: wclib.js,v 625.2 2005/09/18 04:04:32 ajc Exp $
 //
-// JavaScript function library for WebCit
+// JavaScript function library for WebCit.
 //
 //
 
@@ -51,7 +51,7 @@ function activate_entmsg_autocompleters() {
 // Static variables for mailbox view...
 //
 var CtdlNumMsgsSelected = 0;
-var CtdlMsgsSelected = new Array(100); // arbitrary
+var CtdlMsgsSelected = new Array(65536);       // arbitrary
 
 // This gets called when you single click on a message in the mailbox view.
 // We know that the element id of the table row will be the letter 'm' plus the message number.
@@ -108,6 +108,43 @@ function CtdlSingleClickMsg(evt, msgnum) {
        );
 }
 
+// Take the boldface away from a message to indicate that it has been seen.
 function CtdlRemoveTheUnseenBold(msgnum) {
        $('m'+msgnum).style.fontWeight='normal' ;
 }
+
+// A message has been deleted, so yank it from the list.
+function CtdlClearDeletedMsg(msgnum) {
+       $('m'+msgnum).innerHTML = '' ;
+}
+
+
+// Delete selected messages.
+function CtdlDeleteSelectedMessages(evt) {
+       if (CtdlNumMsgsSelected < 1) {
+               // Nothing to delete, so exit silently.
+               return false;
+       }
+       for (i=0; i<CtdlNumMsgsSelected; ++i) {
+               new Ajax.Request(
+                       '/ajax_servcmd', {
+                               method: 'post',
+                               parameters: 'g_cmd=MOVE ' + CtdlMsgsSelected[i] + '|_TRASH_|0',
+                               onComplete: CtdlClearDeletedMsg(CtdlMsgsSelected[i])
+                       }
+               );
+       }
+       CtdlNumMsgsSelected = 0;
+
+       // Clear the preview pane too.
+       $('preview_pane').innerHTML = '';
+}
+
+// This gets called when the user touches the keyboard after selecting messages...
+function CtdlMsgListKeyPress(evt) {
+       if (evt.which == 46) {                          // DELETE key
+               CtdlDeleteSelectedMessages(evt);
+       }
+       return true;
+}
+
index 7c27c62478de852e914968a0684c9959186cef50..c2b0c1c2dc8efc2316f1af055f548a9d6710654f 100644 (file)
@@ -1424,8 +1424,6 @@ void session_loop(struct httprequest *req)
                create_user();
        } else if (!strcasecmp(action, "changeview")) {
                change_view();
-       } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
-               do_stuff_to_msgs();
        } else if (!strcasecmp(action, "change_start_page")) {
                change_start_page();
        } else if (!strcasecmp(action, "display_floorconfig")) {
index efdcf285d0b2c9f67f606f329fa4aa501dd9b809..615bdeda401fa8bae1e701e3b264ec38f05c47de 100644 (file)
@@ -502,7 +502,6 @@ void edituser(void);
 void do_change_view(int);
 void change_view(void);
 void folders(void);
-void do_stuff_to_msgs(void);
 void load_preferences(void);
 void save_preferences(void);
 void get_preference(char *key, char *value, size_t value_len);