Calendar day view :
authorThierry Pasqualier <thierry@uncensored.citadel.org>
Sun, 14 Oct 2007 20:05:21 +0000 (20:05 +0000)
committerThierry Pasqualier <thierry@uncensored.citadel.org>
Sun, 14 Oct 2007 20:05:21 +0000 (20:05 +0000)
* first implementation of ongoing events
* without minutes

webcit/calendar_view.c
webcit/static/webcit.css

index ae1d7b1c2a14f5527f4a1af98bb30f5b5cbc218a..b9f212a765842b792a28399ae6826cada58a41e1 100644 (file)
@@ -634,6 +634,7 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
        struct tm event_tm;
        int show_event = 0;
        int all_day_event = 0;
+       int ongoing_event = 0;
        struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
        struct disp_cal *Cal;
        struct icaltimetype t;
@@ -642,8 +643,8 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
        struct icaltimetype today_end_t;
        struct tm starting_tm;
        struct tm ending_tm;
-       int top;
-       int height;
+       int top = 0;
+       int height = 0;
 
        if (WCC->num_cal == 0) {
                // \todo FIXME wprintf("<br /><br /><br />\n");
@@ -654,7 +655,7 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
        event_end = thetime + 60 * 60 * (hour + 1);
 
 
-       /* Create an imaginary event which spans the 24 hours of today.  Any events which
+       /* Create an imaginary event which spans the current hour.  Any events which
         * overlap with this one take place at least partially in this day.
         */
        memset(&starting_tm, 0, sizeof(struct tm));
@@ -673,7 +674,7 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
        ending_tm.tm_hour = hour;
        ending_tm.tm_min = 59;
        today_end_t = icaltime_from_timet_with_zone(mktime(&ending_tm), 0, icaltimezone_get_utc_timezone());
-/*     today_end_t.is_utc = 1;*/
+       today_end_t.is_utc = 1;
 
        /* Now loop through our list of events to see which ones occur today.
         */
@@ -681,10 +682,13 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
                Cal = &WCC->disp_cal[i];
 
                all_day_event = 0;
+               ongoing_event=0;
+
                q = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (q != NULL) {
                        t = icalproperty_get_dtstart(q);
                        event_tt = icaltime_as_timet(t);
+                       localtime_r(&event_tt, &event_te);
                }
                else {
                        memset(&t, 0, sizeof t);
@@ -692,6 +696,8 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
                q = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
                if (q != NULL) {
                        end_t = icalproperty_get_dtend(q);
+                       event_tte = icaltime_as_timet(end_t);
+                       localtime_r(&event_tte, &event_tm);
                }
                else {
                        memset(&end_t, 0, sizeof end_t);
@@ -705,25 +711,41 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
                else
                {
                        show_event = ical_ctdl_is_overlap(t, end_t, today_start_t, today_end_t);
-                       localtime_r(&event_tt, &event_te);
                }
 
                /* If we determined that this event occurs today, then display it.
                 */
                p = icalcomponent_get_first_property(Cal->cal,ICAL_SUMMARY_PROPERTY);
                if ((show_event) && (p != NULL)) {
-                       if (all_day_event)
+
+                       if ((t.day != today_start_t.day) && (end_t.day != today_start_t.day)) ongoing_event = 1; 
+
+                       if (all_day_event) 
                        {
-                               wprintf("<dd><a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d&hour=%d\">",
+                               wprintf("<li><a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d&hour=%d\">",
                                        Cal->cal_msgnum, year, month, day, hour);
                                escputs((char *) icalproperty_get_comment(p));
-                               wprintf("</a></dd>\n");
+                               wprintf("</a> (");
+                               wprintf(_("All day event"));
+                               wprintf(")</li>\n");
+                       }
+                       else if (ongoing_event && (hour == -1)) 
+                       {
+                               wprintf("<li><a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d&hour=%d\">",
+                                       Cal->cal_msgnum, year, month, day, hour);
+                               escputs((char *) icalproperty_get_comment(p));
+                               wprintf("</a> (");
+                               wprintf(_("Ongoing event"));
+                               wprintf(")</li>\n");
                        }
                        else 
                        {
-                               event_tte = icaltime_as_timet(end_t);
-                               localtime_r(&event_tte, &event_tm);
-                               if (hour == event_te.tm_hour) {
+                               if ((hour == event_te.tm_hour) && ! ongoing_event ) {
+
+                                       if (t.day != today_start_t.day) event_te.tm_hour = 0;
+                                       if (end_t.day != today_start_t.day) event_tm.tm_hour = 24;
+
                                        if ((event_te.tm_hour < dstart) && (event_tm.tm_hour <= dstart)) {
                                                top = (event_te.tm_hour * 11) -1;
                                                height= (event_tm.tm_hour - event_te.tm_hour) * 11;
@@ -851,13 +873,12 @@ void calendar_day_view(int year, int month, int day) {
        /** Extra events on the middle */
         wprintf("<td class=\"extra_events\">");
 
-        wprintf("<dl>");
+        wprintf("<ul>");
 
         /** Display all-day events) */
-       wprintf("<dt>All day events</dt>");
                 calendar_day_view_display_events(today_t, year, month, day, -1, daystart, dayend);
 
-        wprintf("</dl>");
+        wprintf("</ul>");
 
        wprintf("</td>");       /** end extra on the middle */
 
index 45e52b7558cc9c9c3cc2348048a26a29ca3c08bc..0621de557ddd8e47ffb426de207e03b2b2e80b26 100644 (file)
@@ -1161,6 +1161,13 @@ td.events_of_the_day {
        text-align: left;       
 }
 
+
+.extra_events ul, .extra_events ul li {
+       list-style: none;
+       margin: 0;
+       padding: 0;
+}
+
 .calday, .calout, .calweekend {
        width: 14%;
        height: 60px;