]> code.citadel.org Git - citadel.git/commitdiff
* Two-pane mail reading now uses Ajax instead of a hidden iframe, and it's
authorArt Cancro <ajc@citadel.org>
Mon, 19 Sep 2005 02:56:21 +0000 (02:56 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 19 Sep 2005 02:56:21 +0000 (02:56 +0000)
  very crisp and responsive.
* "Print message" function now opens up a new window for the print
  preview.  I just couldn't figure out a way to keep the b0rken IE from
  printing the screen instead of the message.

webcit/ChangeLog
webcit/messages.c
webcit/webcit.c
webcit/webcit.h

index f6febbc0888fb7c91418619de371f6c41159a94a..d2eedda3ced90d82e45516475abfaf3bda8ee978 100644 (file)
@@ -1,4 +1,11 @@
 $Log$
+Revision 625.17  2005/09/19 02:56:21  ajc
+* Two-pane mail reading now uses Ajax instead of a hidden iframe, and it's
+  very crisp and responsive.
+* "Print message" function now opens up a new window for the print
+  preview.  I just couldn't figure out a way to keep the b0rken IE from
+  printing the screen instead of the message.
+
 Revision 625.16  2005/09/19 02:07:17  ajc
 * Renamed 'ScriptaculousEffect' back to 'Effect' because there is no
   longer any namespace conflict.
@@ -3030,3 +3037,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 47d515f3a238c82d13b6c49d61f170c9b5a79baa..79cb312bb919153050113b587e5e41fe28c5af88 100644 (file)
@@ -469,7 +469,7 @@ void display_vcard(char *vcard_source, char alpha, int full, char *storename) {
 /*
  * I wanna SEE that message!
  */
-void read_message(long msgnum, int suppress_buttons) {
+void read_message(long msgnum, int printable_view) {
        char buf[SIZ];
        char mime_partnum[256];
        char mime_filename[256];
@@ -523,9 +523,11 @@ void read_message(long msgnum, int suppress_buttons) {
        }
 
        /* begin everythingamundo table */
-       wprintf("<div id=\"fix_scrollbar_bug\">\n");
-       wprintf("<table width=100%% border=1 cellspacing=0 "
-               "cellpadding=0><TR><TD>\n");
+       if (!printable_view) {
+               wprintf("<div id=\"fix_scrollbar_bug\">\n");
+               wprintf("<table width=100%% border=1 cellspacing=0 "
+                       "cellpadding=0><TR><TD>\n");
+       }
 
        /* begin message header table */
        wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 "
@@ -704,7 +706,7 @@ void read_message(long msgnum, int suppress_buttons) {
        wprintf("</TD>\n");
 
        /* start msg buttons */
-       if (!suppress_buttons) {
+       if (!printable_view) {
                wprintf("<td align=right>\n");
 
                /* Reply */
@@ -747,8 +749,8 @@ void read_message(long msgnum, int suppress_buttons) {
                        );
                }
 
-               wprintf("<a href=\"/msg?msgnum=%ld?sourceiframe=msgloader1?print_it=yes\" target=\"msgloader1\">"
-                       "[%s]</a>", msgnum, _("Print"));
+               wprintf("<a href=\"#\" onClick=\"window.open('/printmsg?msgnum=%ld', 'print%ld', 'toolbar=no,location=no,directories=no,copyhistory=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=400'); \" >"
+                       "[%s]</a>", msgnum, msgnum, _("Print"));
 
                wprintf("</td>");
        }
@@ -899,8 +901,10 @@ ENDBODY:
        wprintf("</TD></TR></TABLE>\n");
 
        /* end everythingamundo table */
-       wprintf("</TD></TR></TABLE>\n");
-       wprintf("</div><br />\n");
+       if (!printable_view) {
+               wprintf("</TD></TR></TABLE>\n");
+               wprintf("</div><br />\n");
+       }
 
 #ifdef HAVE_ICONV
        if (ic != (iconv_t)(-1) ) {
@@ -917,63 +921,42 @@ ENDBODY:
  */
 void embed_message(void) {
        long msgnum = 0L;
-       char *sourceiframe;
-       char *targetdiv;
-       char *print_it;
 
        msgnum = atol(bstr("msgnum"));
-       sourceiframe = bstr("sourceiframe");
-       targetdiv = bstr("targetdiv");
-       print_it = bstr("print_it");
+       begin_ajax_response();
+       read_message(msgnum, 0);
+       end_ajax_response();
+}
 
-       output_headers(1, 0, 0, 0, 1, 0);
-       begin_burst();
 
-       wprintf("<html><head>");
+/*
+ * Printable view of a message
+ */
+void print_message(void) {
+       long msgnum = 0L;
 
-       /* If we're loading into a hidden iframe, chances are the caller told us
-        * about a target div somewhere that we need to copy into when we're done.
-        */
-       if (strlen(targetdiv) > 0) wprintf(
-"                                                                      \n"
-" <script type=\"text/javascript\">                                    \n"
-"      function loaded_now_copy_it() {                                 \n"
-"              parent.document.getElementById(\"%s\").innerHTML = parent.frames['%s'].document.body.innerHTML; \n"
-"      }                                                               \n"
-"</script>\n",
-               targetdiv,
-               sourceiframe
-       );
+       msgnum = atol(bstr("msgnum"));
+        output_headers(0, 0, 0, 0, 0, 0);
+
+        wprintf("Content-type: text/html\r\n"
+                "Server: %s\r\n"
+                "Connection: close\r\n",
+                SERVER);
+        begin_burst();
 
-       if (!strcasecmp(print_it, "yes")) wprintf(
-"                                                                      \n"
-" <script type=\"text/javascript\">                                    \n"
-"      function loaded_now_print_it() {                                \n"
-"              parent.frames['%s'].focus();                            \n"
-"              parent.frames['%s'].print();                            \n"
-"      }                                                               \n"
-"</script>\n",
-               sourceiframe,
-               sourceiframe
+       wprintf("\r\n\r\n<html>\n"
+               "<head><title>Printable view</title></head>\n"
+               "<body onLoad=\" window.print(); window.close(); \">\n"
        );
+       
+       read_message(msgnum, 1);
 
-       wprintf("</head>");
-       wprintf("<body");
-       if (strlen(targetdiv) > 0) {
-               wprintf(" onLoad='loaded_now_copy_it();'");
-       }
-       if (!strcasecmp(print_it, "yes")) {
-               wprintf(" onLoad='loaded_now_print_it();'");
-       }
-       wprintf(">\n");
-       read_message(msgnum, (!strcasecmp(print_it, "yes") ? 1 : 0) );
-       wprintf("</body></html>\n");
+       wprintf("\n</body></html>\n\n");
        wDumpContent(0);
 }
 
 
 
-
 /*
  * Read message in simple, JavaScript-embeddable form for 'forward'
  * or 'reply quoted' operations.
@@ -1282,10 +1265,7 @@ void display_summarized(int num) {
 
        wprintf("<TD>");
        if (WC->summ[num].is_new) wprintf("<B>");
-       wprintf("<A HREF=\"/msg?msgnum=%ld?sourceiframe=msgloader1?targetdiv=preview_pane\" target=\"msgloader1\">",
-               WC->summ[num].msgnum);
        escputs(WC->summ[num].subj);
-       wprintf("</A>");
        if (WC->summ[num].is_new) wprintf("</B>");
        wprintf("</TD><TD>");
        if (WC->summ[num].is_new) wprintf("<B>");
@@ -1969,9 +1949,13 @@ void readloop(char *oper)
                        /* If a tabular view, set up the line */
                        if (is_summary) {
                                bg = 1 - bg;
-                               wprintf("<TR BGCOLOR=\"#%s\">",
+                               wprintf("<tr bgcolor=\"#%s\" ",
                                        (bg ? "DDDDDD" : "FFFFFF")
                                );
+
+                               wprintf("onClick=\" new Ajax.Updater('preview_pane', '/msg', { method: 'get', parameters: 'msgnum=%ld' } ); \" ", WC->summ[a].msgnum);
+
+                               wprintf(">");
                        }
 
                        /* Display the message */
index 82422c2c573fe8b8e2d5aec80c1baaf3c6cd201c..9c510fab5cadc3ab2f028a674472c44dc8b72b39 100644 (file)
@@ -1187,6 +1187,8 @@ void session_loop(struct httprequest *req)
                readloop("headers");
        } else if (!strcasecmp(action, "msg")) {
                embed_message();
+       } else if (!strcasecmp(action, "printmsg")) {
+               print_message();
        } else if (!strcasecmp(action, "display_enter")) {
                display_enter();
        } else if (!strcasecmp(action, "post")) {
index 6506edffe4159471d06b880be84f92425e93c9c4..9dfa8ab538f726fa448764adfcb0433699ef8095 100644 (file)
@@ -387,6 +387,7 @@ void serv_read(char *buf, int bytes);
 int haschar(char *, char);
 void readloop(char *oper);
 void embed_message(void);
+void print_message(void);
 void text_to_server(char *ptr, int convert_to_html);
 void display_enter(void);
 void post_message(void);