* Replaced all the "centered 99% tables" with 100% width tables wrapped
[citadel.git] / webcit / messages.c
index ece6f96bf6e817ae50ec96bfd124135b0219109d..123c894602f681d00ffb3ee84d602b5e2d47e150 100644 (file)
@@ -103,6 +103,11 @@ void fetchname_parsed_vcard(struct vCard *v, char *storename) {
        if (v->numprops) for (i=0; i<(v->numprops); ++i) {
                if (!strcasecmp(v->prop[i].name, "n")) {
                        strcpy(storename, v->prop[i].value);
+                       if ((strlen(storename)>0) && (storename[0] != ';')) {
+                               while(storename[strlen(storename)-1] == ';') {
+                                       storename[strlen(storename)-1] = 0;
+                               }
+                       }
                }
        }
 }
@@ -142,10 +147,11 @@ void display_parsed_vcard(struct vCard *v, int full) {
        if (!full) {
                wprintf("<TD>");
                name = vcard_get_prop(v, "fn", 1, 0, 0);
-               if (name == NULL) name = vcard_get_prop(v, "n", 1, 0, 0);
                if (name != NULL) {
-                       strcpy(buf, name);
-                       escputs(buf);
+                       escputs(name);
+               }
+               else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
+                       escputs(name);
                }
                else {
                        wprintf("&nbsp;");
@@ -369,7 +375,8 @@ void read_message(long msgnum) {
        }
 
        /* begin everythingamundo table */
-       wprintf("<table width=100% border=1 cellspacing=0 "
+       wprintf("<div style=\"margin-right:1px\">\n");
+       wprintf("<table width=100%% border=1 cellspacing=0 "
                "cellpadding=0><TR><TD>\n");
 
        /* begin message header table */
@@ -642,7 +649,8 @@ ENDBODY:
        wprintf("</TD></TR></TABLE>\n");
 
        /* end everythingamundo table */
-       wprintf("</TD></TR></TABLE><br />\n");
+       wprintf("</TD></TR></TABLE>\n");
+       wprintf("</div>\n");
 }
 
 
@@ -880,8 +888,8 @@ void fetch_ab_name(long msgnum, char *namebuf) {
  */
 int abcmp(const void *ab1, const void *ab2) {
        return(strcasecmp(
-               (((const struct addrbookent *)ab1)->ab_name),
-               (((const struct addrbookent *)ab2)->ab_name)
+               (((const struct addrbookent *)ab1)->ab_name),
+               (((const struct addrbookent *)ab2)->ab_name)
        ));
 }
 
@@ -1135,9 +1143,11 @@ void readloop(char *oper)
                }
        }
 
+       wprintf("<FORM NAME=\"msgomatic\" "
+               "METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n");
        if (is_summary) {
-               wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n"
-                       "<TABLE border=0 cellspacing=0 "
+               wprintf("<div style=\"margin-right:1px\">"
+                       "<table border=0 cellspacing=0 "
                        "cellpadding=0 width=100%%>\n"
                        "<TR>"
                        "<TD><I>Subject</I></TD>"
@@ -1215,7 +1225,7 @@ void readloop(char *oper)
        }
 
        if (is_summary) {
-               wprintf("</TABLE>\n");
+               wprintf("</table></div>\n");
        }
 
        /* Bump these because although we're thinking in zero base, the user
@@ -1228,8 +1238,8 @@ void readloop(char *oper)
        if (num_displayed == 1) {
           if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
 
-               wprintf("<CENTER>"
-                       "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
+               wprintf("<div style=\"margin-right:1px\">"
+                       "<table border=0 width=100%% bgcolor=\"#dddddd\"><tr><td>"
                        "Reading #%d of %d messages.</TD>\n"
                        "<TD ALIGN=RIGHT><FONT SIZE=+1>",
                        lowest_displayed, nummsgs);
@@ -1266,7 +1276,7 @@ void readloop(char *oper)
                        oper,
                        WC->msgarr[0]);
 
-               wprintf("</TD></TR></TABLE></CENTER>\n");
+               wprintf("</td></tr></table></div>\n");
            }
        }
 
@@ -1275,55 +1285,53 @@ void readloop(char *oper)
         * messages, then display the selector bar
         */
        if (num_displayed > 1) {
-          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
-               wprintf("<CENTER>"
-                       "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
-                       "Reading #%d-%d of %d messages.</TD>\n"
-                       "<TD ALIGN=RIGHT><FONT SIZE=+1>",
-                       lowest_displayed, highest_displayed, nummsgs);
+          if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
+             && (!is_notes) && (!is_singlecard)) {
 
-               if (is_summary) {
-                       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
-                               "VALUE=\"Delete selected\">\n");
-               }
+               wprintf("Reading #", lowest_displayed, highest_displayed);
 
+               wprintf("<SELECT NAME=\"whichones\" SIZE=\"1\" "
+                       "OnChange=\"location.href=msgomatic.whichones.options"
+                       "[selectedIndex].value\">\n");
 
                for (b=0; b<nummsgs; b = b + maxmsgs) {
                lo = b+1;
                hi = b+maxmsgs;
                if (hi > nummsgs) hi = nummsgs;
-                       if (WC->msgarr[b] != startmsg) {
-                               wprintf("<A HREF=\"/%s"
-                                       "?startmsg=%ld"
-                                       "&maxmsgs=%d"
-                                       "&summary=%d\">"
-                                       "%d-%d</A> \n",
-                                               oper,
-                                               WC->msgarr[b],
-                                               maxmsgs,
-                                               is_summary,
-                                               lo, hi);
-                       }
-                       else {
-                               wprintf("%d-%d \n", lo, hi);
-                       }
-
+                       wprintf("<OPTION %s VALUE="
+                               "\"/%s"
+                               "?startmsg=%ld"
+                               "&maxmsgs=%d"
+                               "&summary=%d\">"
+                               "%d-%d</OPTION> \n",
+                               ((WC->msgarr[b] == startmsg) ? "SELECTED" : ""),
+                               oper,
+                               WC->msgarr[b],
+                               maxmsgs,
+                               is_summary,
+                               lo, hi);
                }
-               wprintf("<A HREF=\"/%s?startmsg=%ld"
+               wprintf("<OPTION VALUE=\"/%s?startmsg=%ld"
                        "&maxmsgs=999999&summary=%d\">"
                        "ALL"
-                       "</A> ",
+                       "</OPTION> ",
                        oper,
                        WC->msgarr[0], is_summary);
 
-               wprintf("<A HREF=\"/%s?startmsg=%ld"
+               wprintf("<OPTION VALUE=\"/%s?startmsg=%ld"
                        "&maxmsgs=999999&summary=1\">"
                        "Summary"
-                       "</A>",
+                       "</OPTION>",
                        oper,
                        WC->msgarr[0]);
 
-               wprintf("</TD></TR></TABLE></CENTER>\n");
+               wprintf("</SELECT> of %d messages.", nummsgs);
+
+               if (is_summary) {
+                       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
+                               "VALUE=\"Delete selected\">\n");
+               }
+
            }
        }
        if (is_summary) wprintf("</FORM>\n");
@@ -1488,8 +1496,12 @@ void post_message(void)
                serv_gets(buf);
                if (buf[0] == '4') {
                        post_mime_to_server();
-                       sprintf(WC->ImportantMessage, 
-                               "Message has been posted.\n");
+                       if (strlen(bstr("recp")) > 0) {
+                               sprintf(WC->ImportantMessage, "Message has been sent.\n");
+                       }
+                       else {
+                               sprintf(WC->ImportantMessage, "Message has been posted.\n");
+                       }
                        dont_post = atol(bstr("postseq"));
                } else {
                        sprintf(WC->ImportantMessage, 
@@ -1603,12 +1615,18 @@ void display_enter(void)
                "&nbsp;"
        );
 
-       wprintf("<input type=\"submit\" name=\"sc\" value=\"Save message\">"
-               "&nbsp;"
+       wprintf("<input type=\"submit\" name=\"sc\" value=\"");
+       if (strlen(bstr("recp")) > 0) {
+               wprintf("Send message");
+       } else {
+               wprintf("Post message");
+       }
+       wprintf("\">&nbsp;"
                "<input type=\"submit\" name=\"sc\" value=\"Cancel\">\n");
 
        /* begin richedit box */
-       wprintf("<div style=\"position:absolute; left:0%%; width:100%%; top:15%; height:80%%\">\n");
+       wprintf("<div style=\"position:absolute; left:0%%; width:100%%; "
+               "top:15%; height:75%%\">\n");
 
        wprintf("<script type=\"text/javascript\" "
                "src=\"static/richtext.js\"></script>\n"
@@ -1632,18 +1650,23 @@ void display_enter(void)
        wprintf("<div style=\"position:absolute; bottom:0px; left:0px; width:100%%\">\n");
 
        /* Enumerate any attachments which are already in place... */
+       wprintf("<img src=\"/static/attachment.gif\" border=0 "
+               "align=middle height=16 width=16> Attachments: ");
+       wprintf("<select name=\"which_attachment\" size=1>");
        for (att = WC->first_attachment; att != NULL; att = att->next) {
-               wprintf("<IMG SRC=\"/static/attachment.gif\" "
-                       "BORDER=0 ALIGN=MIDDLE> Attachment: ");
+               wprintf("<option value=\"");
+               urlescputs(att->filename);
+               wprintf("\">");
                escputs(att->filename);
-               wprintf(" (%s, %d bytes)<br />\n",
-                       att->content_type, att->length);
+               /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
+               wprintf("</option>\n");
        }
+       wprintf("</select>");
 
        /* Now offer the ability to attach additional files... */
        wprintf("&nbsp;&nbsp;&nbsp;"
                "Attach file: <input NAME=\"attachfile\" "
-               "SIZE=48 TYPE=\"file\">\n&nbsp;&nbsp;"
+               "SIZE=16 TYPE=\"file\">\n&nbsp;&nbsp;"
                "<input type=\"submit\" name=\"attach\" value=\"Add\">\n");
 
        wprintf("</div>\n");    /* end attachments section */
@@ -1694,10 +1717,11 @@ void confirm_move_msg(void)
 
        output_headers(1, 1, 1, 0, 0, 0, 0);
 
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"#FFFFFF\"");
-       wprintf("<B>Confirm move of message</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       wprintf("<div style=\"margin-right:1px\">"
+               "<table width=100%% border=0 bgcolor=\"#444455\"><tr><td>");
+       wprintf("<font size=+1 color=\"#ffffff\"");
+       wprintf("<b>Confirm move of message</b>\n");
+       wprintf("</font></td></tr></table></div>\n");
 
        wprintf("<CENTER>");