]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_view.c
* Font sizes for the hour markers in the calendar day view are now set to the height...
[citadel.git] / webcit / calendar_view.c
index f9863836bf81e9b5314b3716ee0def62686bc485..9a9cd74cda354a542ef6a561a2cbbc11faf295b2 100644 (file)
@@ -7,13 +7,16 @@
 #include "webcit.h"
 #include "webserver.h"
 
+/* These define how high the hour rows are in the day view */
+#define TIMELINE       30
+#define EXTRATIMELINE  (TIMELINE / 2)
 
-void embeddable_mini_calendar(int year, int month, char *urlformat)
+void embeddable_mini_calendar(int year, int month)
 {
        struct tm starting_tm;
        struct tm tm;
        time_t thetime;
-       int i, len;
+       int i;
        time_t previous_month;
        time_t next_month;
        time_t colheader_time;
@@ -22,8 +25,7 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
        long weekstart = 0;
        char url[256];
        char div_id[256];
-       char escaped_urlformat[256];
-
+       
        snprintf(div_id, sizeof div_id, "mini_calendar_%d", rand() );
 
        /* Determine what day to start.  If an impossible value is found, start on Sunday.
@@ -102,7 +104,7 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
                        }
 
                        if (tm.tm_mon == month-1) {
-                               snprintf(url, sizeof url, urlformat,
+                               snprintf(url, sizeof url, "readfwd?calview=day&year=%d&month=%d&day=%d", 
                                        tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
                                wprintf("<td><a href=\"%s\">%d</a></td>", url, tm.tm_mday);
                        }
@@ -123,21 +125,15 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
        wprintf("</table>"                      /* end of inner table */
                "</div>\n");
 
-       /* javascript for previous and next month */
-       len = strlen(urlformat);
-       for (i=0; i<len; ++i) {
-               sprintf(&escaped_urlformat[i*2], "%02X", urlformat[i]);
-       }
-
        StrBufAppendPrintf(WC->trailing_javascript,
                "       function minical_change_month(year, month) {                                    \n"
                "               p = 'year=' + year + '&month=' + month                                  \n"
-               "                       + '&urlformat=%s&r=' + CtdlRandomString();                      \n"
+               "                       + '&r=' + CtdlRandomString();                                   \n"
                "               new Ajax.Updater('%s', 'mini_calendar',                                 \n"
                "                       { method: 'get', parameters: p, evalScripts: true } );          \n"
                "       }                                                                               \n"
                "",
-               escaped_urlformat, div_id
+               div_id
        );
 
 }
@@ -145,19 +141,9 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
 /*
  * ajax embedder for the above mini calendar 
  */
-void ajax_mini_calendar(void) {
-       char urlformat[256];
-       int i, len;
-       char *escaped_urlformat;
-
-       escaped_urlformat = bstr("urlformat");
-        len = strlen(escaped_urlformat) * 2 ;
-       for (i=0; i<len; ++i) {
-               urlformat[i] = xtoi(&escaped_urlformat[i*2], 2);
-               urlformat[i+1] = 0;
-       }
-
-       embeddable_mini_calendar( ibstr("year"), ibstr("month"), urlformat );
+void ajax_mini_calendar(void) 
+{
+       embeddable_mini_calendar( ibstr("year"), ibstr("month"));
 }
 
 
@@ -953,15 +939,15 @@ void calendar_day_view_display_events(time_t thetime,
                                /* Calculate the location of the top of the box */
                                if (event_te.tm_hour < dstart) {
                                        startmin = diffmin = event_te.tm_min / 6;
-                                       top = (event_te.tm_hour * 10) + startmin;
+                                       top = (event_te.tm_hour * EXTRATIMELINE) + startmin;
                                }
                                else if ((event_te.tm_hour >= dstart) && (event_te.tm_hour <= dend)) {
                                        startmin = diffmin = (event_te.tm_min / 2);
-                                       top = (dstart * 10) + ((event_te.tm_hour - dstart) * 30) + startmin;
+                                       top = (dstart * EXTRATIMELINE) + ((event_te.tm_hour - dstart) * TIMELINE) + startmin;
                                }
                                else if (event_te.tm_hour >dend) {
                                        startmin = diffmin = event_te.tm_min / 6;
-                                       top = (dstart * 10) + ((dend - dstart - 1) * 30) + ((event_tm.tm_hour - dend + 1) * 10) + startmin ;
+                                       top = (dstart * EXTRATIMELINE) + ((dend - dstart - 1) * TIMELINE) + ((event_tm.tm_hour - dend + 1) * EXTRATIMELINE) + startmin ;
                                }
                                else {
                                        /* should never get here */
@@ -970,15 +956,15 @@ void calendar_day_view_display_events(time_t thetime,
                                /* Calculate the location of the bottom of the box */
                                if (event_tm.tm_hour < dstart) {
                                        endmin = diffmin = event_tm.tm_min / 6;
-                                       bottom = (event_tm.tm_hour * 10) + endmin;
+                                       bottom = (event_tm.tm_hour * EXTRATIMELINE) + endmin;
                                }
                                else if ((event_tm.tm_hour >= dstart) && (event_tm.tm_hour <= dend)) {
                                        endmin = diffmin = (event_tm.tm_min / 2);
-                                       bottom = (dstart * 10) + ((event_tm.tm_hour - dstart) * 30) + endmin ;
+                                       bottom = (dstart * EXTRATIMELINE) + ((event_tm.tm_hour - dstart) * TIMELINE) + endmin ;
                                }
                                else if (event_tm.tm_hour >dend) {
                                        endmin = diffmin = event_tm.tm_min / 6;
-                                       bottom = (dstart * 10) + ((dend - dstart + 1) * 30) + ((event_tm.tm_hour - dend - 1) * 10) + endmin;
+                                       bottom = (dstart * EXTRATIMELINE) + ((dend - dstart + 1) * TIMELINE) + ((event_tm.tm_hour - dend - 1) * EXTRATIMELINE) + endmin;
                                }
                                else {
                                        /* should never get here */
@@ -1038,8 +1024,8 @@ void calendar_day_view(int year, int month, int day) {
        char d_str[128];
        int time_format;
        time_t today_t;
-       int timeline = 30;
-       int extratimeline = 0;
+       int timeline = TIMELINE;
+       int extratimeline = EXTRATIMELINE;
        int gap = 0;
 
        time_format = get_time_format_cached ();
@@ -1086,18 +1072,19 @@ void calendar_day_view(int year, int month, int day) {
 
        /* Now the middle of the day... */
 
-       extratimeline = timeline / 3;   
-
        for (hour = 0; hour < daystart; ++hour) {       /* could do HEIGHT=xx */
                wprintf("<dt class=\"extrahour\"        "
                        "style=\"               "
                        "position: absolute;    "
                        "top: %dpx; left: 0px;  "
-                       "height: %dpx;          "       
+                       "height: %dpx;          "
+                       "font-size: %dpx;       "
                        "\" >                   "
                        "<a href=\"display_edit_event?msgnum=0"
                        "?calview=day?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
-                       (hour * extratimeline ), extratimeline, 
+                       (hour * extratimeline ),
+                       extratimeline,
+                       extratimeline - 2,
                        year, month, day, hour
                        );
 
@@ -1120,12 +1107,15 @@ void calendar_day_view(int year, int month, int day) {
                 wprintf("<dt class=\"hour\"     "
                         "style=\"               "
                         "position: absolute;    "
-                        "top: %ldpx; left: 0px;  "
+                        "top: %ldpx; left: 0px; "
                         "height: %dpx;          "
+                       "font-size: %dpx;       "
                         "\" >                   "
                         "<a href=\"display_edit_event?msgnum=0?calview=day"
                         "?year=%d?month=%d?day=%d?hour=%d?minute=0\">",
-                        gap + ((hour - daystart) * timeline ), timeline,
+                        gap + ((hour - daystart) * timeline ),
+                       timeline,
+                       timeline - 2,
                         year, month, day, hour
                        );
 
@@ -1225,7 +1215,7 @@ void calendar_day_view(int year, int month, int day) {
 
        /* Embed a mini month calendar in this space */
        wprintf("<br />\n");
-       embeddable_mini_calendar(year, month, "readfwd?calview=day?year=%d?month=%d?day=%d");
+       embeddable_mini_calendar(year, month);
 
        wprintf("</font></center>\n");
 
@@ -1241,9 +1231,9 @@ void calendar_day_view(int year, int month, int day) {
 
 
 /*
- * Display today's events.
+ * Display today's events.  Returns the number of items displayed.
  */
-void calendar_summary_view(void) {
+int calendar_summary_view(void) {
        long hklen;
        const char *HashKey;
        void *vCal;
@@ -1258,9 +1248,10 @@ void calendar_summary_view(void) {
        int all_day_event = 0;
        char timestring[SIZ];
        wcsession *WCC = WC;
+       int num_displayed = 0;
 
        if (GetCount(WC->disp_cal_items) == 0) {
-               return;
+               return(0);
        }
 
        now = time(NULL);
@@ -1304,7 +1295,7 @@ void calendar_summary_view(void) {
                                                        "?gotofirst=",
                                                        Cal->cal_msgnum
                                                );
-                                               escputs(WCC->wc_roomname);
+                                               escputs(ChrPtr(WCC->wc_roomname));
                                                wprintf("\">");
                                        }
                                        else {
@@ -1320,17 +1311,22 @@ void calendar_summary_view(void) {
                                                        today_tm.tm_mon + 1,
                                                        today_tm.tm_mday
                                                );
-                                               escputs(WCC->wc_roomname);
+                                               escputs(ChrPtr(WCC->wc_roomname));
                                                wprintf("\">");
                                        }
                                        escputs((char *) icalproperty_get_comment(p));
-                                       wprintf(" (%s)</a><br />\n", timestring);
+                                       if (!all_day_event) {
+                                               wprintf(" (%s)", timestring);
+                                       }
+                                       wprintf("</a><br />\n");
+                                       ++num_displayed;
                                }
                        }
                }
        }
        DeleteHashPos(&Pos);
        DeleteHash(&WC->disp_cal_items);
+       return(num_displayed);
 }
 
 /*
@@ -1552,7 +1548,7 @@ void do_tasks_view(void) {
                p = icalcomponent_get_first_property(Cal->cal,
                        ICAL_SUMMARY_PROPERTY);
                wprintf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
-               urlescputs(WC->wc_roomname);
+               urlescputs(ChrPtr(WC->wc_roomname));
                wprintf("\">");
                /* wprintf("<img align=middle "
                "src=\"static/taskmanag_16x.gif\" border=0>&nbsp;"); */