]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
Finished the trailing_javascript API and moved a few things to it
[citadel.git] / webcit / event.c
index dcce662e2cf2b3774984dc25a87b46d2a526b6f2..54cf9e1cc89cc9fa4a336a407510d4ba268c5624 100644 (file)
@@ -29,6 +29,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        int i, j = 0;
        int sequence = 0;
        char weekday_labels[7][32];
+       long weekstart = 0;
+
+       get_pref_long("weekstart", &weekstart, 17);
+       if (weekstart > 6) weekstart = 0;
 
        lprintf(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
                msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
@@ -191,7 +195,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                t_start.is_utc = 1;
 
        }
-       display_icaltimetype_as_webform(&t_start, "dtstart");
+       display_icaltimetype_as_webform(&t_start, "dtstart", 0);
 
        wprintf("<INPUT TYPE=\"checkbox\" id=\"alldayevent\" NAME=\"alldayevent\" "
                "VALUE=\"yes\" onclick=\"eventEditAllDay();\""
@@ -232,7 +236,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                        /* t_end = icaltime_from_timet(now, 0); */
                }
        }
-       display_icaltimetype_as_webform(&t_end, "dtend");
+       display_icaltimetype_as_webform(&t_end, "dtend", 0);
        wprintf("</TD></TR>\n");
 
        wprintf("<TR><TD><B>");
@@ -402,6 +406,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                /* blank recurrence with some sensible defaults */
                memset(&recur, 0, sizeof(struct icalrecurrencetype));
                recur.count = 3;
+               recur.until = icaltime_null_time();
                recur.interval = 1;
                recur.freq = ICAL_WEEKLY_RECURRENCE;
        }
@@ -411,10 +416,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                "onclick=\"RecurrenceShowHide();\""
                " %s >%s",
                (rrule ? "CHECKED=\"CHECKED\"" : "" ),
-               _("This is a repeating event")
+               _("This is a recurring event")
        );
 
-       wprintf("<div id=\"rrule\">\n");                /* begin 'rrule' div */
+       wprintf("<div id=\"rrule_div\">\n");            /* begin 'rrule_div' div */
 
        wprintf("<table border=0 width=100%%>\n");      /* same table style as the event tab */
 
@@ -439,31 +444,29 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        };
 
        wprintf("<tr><td><b>");
-       wprintf(_("Repeats"));
+       wprintf(_("Recurrence rule"));
        wprintf("</b></td><td>");
+
        if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
-       wprintf("%s ", _("every"));
+       wprintf("%s ", _("Repeats every"));
 
        wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
-       wprintf("value=\"%d\"> ", recur.interval);
+       wprintf("value=\"%d\">&nbsp;", recur.interval);
 
        wprintf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
                "onChange=\"RecurrenceShowHide();\">\n");
        for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
-               wprintf("<option %s value=\"%d\">%s</option>\n",
-                       ((i == recur.freq) ? "selected" : ""),
+               wprintf("<option %s%svalue=\"%d\">%s</option>\n",
+                       ((i == recur.freq) ? "selected " : ""),
+                       (((i == recur.freq) || ((i>=3)&&(i<=5))) ? "" : "disabled "),
                        i,
                        frequency_units[i]
                );
        }
+       wprintf("</select>\n");
 
-       wprintf("</td></tr>\n");
-
-
-       wprintf("<div id=\"weekday_selector\">\n");             /* begin 'weekday_selector' div */
-       wprintf("<tr><td><b>");
-       wprintf("%s", _("on these weekdays:"));
-       wprintf("</b></td><td>");
+       wprintf("<div id=\"weekday_selector\">");       /* begin 'weekday_selector' div */
+       wprintf("%s<br>", _("on these weekdays:"));
 
        char weekday_is_selected[7];
        memset(weekday_is_selected, 0, 7);
@@ -481,14 +484,56 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                }
        }
 
-       for (i=0; i<7; ++i) {
+       for (j=0; j<7; ++j) {
+               i = ((j + (int)weekstart) % 7);
                wprintf("<input type=\"checkbox\" name=\"weekday%d\" value=\"yes\"", i);
                if (weekday_is_selected[i]) wprintf(" checked");
                wprintf(">%s</input>\n", weekday_labels[i]);
        }
+       wprintf("</div>\n");                            /* end 'weekday_selector' div */
+
+       wprintf("</td></tr>\n");
+
+
+       int which_rrend_is_preselected = 0;
+       if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
+       if (recur.count > 0) which_rrend_is_preselected = 1;
+
+       wprintf("<tr><td><b>");
+       wprintf(_("Recurrence range"));
+       wprintf("</b></td><td>\n");
+
+       wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
+               "%s onChange=\"RecurrenceShowHide();\">",
+               ((which_rrend_is_preselected == 0) ? "checked" : "")
+       );
+       wprintf("%s</input><br />\n", _("No ending date"));
+
+       wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
+               "%s onChange=\"RecurrenceShowHide();\">",
+               ((which_rrend_is_preselected == 1) ? "checked" : "")
+       );
+       wprintf(_("Repeat this event"));
+       wprintf("</input> ");
+       wprintf("<input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
+       wprintf("value=\"%d\"> ", recur.count);
+       wprintf(_("times"));
+       wprintf("<br />\n");
+
+       wprintf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
+               "%s onChange=\"RecurrenceShowHide();\">",
+               ((which_rrend_is_preselected == 2) ? "checked" : "")
+       );
+       wprintf(_("Repeat this event until "));
+       wprintf("</input>");
+
+       if (icaltime_is_null_time(recur.until)) {
+               recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
+       }
+       display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
+       wprintf("<br />\n");
 
        wprintf("</td></tr>\n");
-       wprintf("</div>\n");                            /* end 'weekday_selector' div */
 
        wprintf("</table>\n");
        wprintf("</div>\n");                            /* end 'rrule' div */
@@ -517,10 +562,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wprintf("</div>\n");
 
-       wprintf("<script type=\"text/javascript\">      \n"
+       StrBufAppendPrintf(WC->trailing_javascript,
                "eventEditAllDay();     \n"
                "RecurrenceShowHide();  \n"
-               "</script>      \n"
        );
        address_book_popup();
        wDumpContent(1);