Wrote a few more lines of the recurrence editor.
authorArt Cancro <ajc@citadel.org>
Tue, 23 Sep 2008 02:20:43 +0000 (02:20 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 23 Sep 2008 02:20:43 +0000 (02:20 +0000)
webcit/event.c
webcit/static/wclib.js

index 8fc91175034f3ef7f5fa76d1c36899fdbd3d459b..9c90b8332bf63b2c81394956548020f82af303a0 100644 (file)
@@ -381,77 +381,84 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        struct icalrecurrencetype recur;
 
        rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
+       if (rrule) {
+               recur = icalproperty_get_rrule(rrule);
+       }
+       else {
+               memset(&recur, 0, sizeof(struct icalrecurrencetype));
+               // FIXME create a sane blank recurrence here
+       }
 
        wprintf("<INPUT TYPE=\"checkbox\" id=\"is_recur\" NAME=\"is_recur\" "
                "VALUE=\"yes\" "
-               /* "onclick=\"GreyOrUnGrayStuffFIXME();\"" */
+               "onclick=\"RecurrenceShowHide();\""
                " %s >%s",
                (rrule ? "CHECKED=\"CHECKED\"" : "" ),
                _("This is a repeating event")
        );
 
-       if (rrule) {
-               recur = icalproperty_get_rrule(rrule);
+       wprintf("<div id=\"rrule\">\n");                /* begin 'rrule' div */
 
-               wprintf("<table border=0 width=100%%>\n");      /* same table style as the event tab */
-
-               /* Table row displaying raw RRULE data, FIXME remove when finished */
-               wprintf("<tr><td><b>");
-               wprintf("Raw data");
-               wprintf("</b></td><td>");
-               wprintf("<tt>%s</tt>", icalrecurrencetype_as_string(&recur));
-               wprintf("</td></tr>\n");
-
-               char *frequency_units[] = {
-                       _("seconds"),
-                       _("minutes"),
-                       _("hours"),
-                       _("days"),
-                       _("weeks"),
-                       _("months"),
-                       _("years"),
-                       _("never")
-               };
-
-               wprintf("<tr><td><b>");
-               wprintf(_("Repeats"));
-               wprintf("</b></td><td>");
-               if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
-               wprintf("%s ", _("every"));
-
-               wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
-               wprintf("value=\"%d\"> ", recur.interval);
-
-               wprintf("<select name=\"freq\" size=\"1\">\n");
-               for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
-                       wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((i == recur.freq) ? "selected" : ""),
-                               i,
-                               frequency_units[i]
-                       );
-               }
 
-               wprintf("</td></tr>\n");
+       wprintf("<table border=0 width=100%%>\n");      /* same table style as the event tab */
 
-               wprintf("<tr><td><b>");
-               wprintf("byday");                                                       //FIXME
-               wprintf("</b></td><td>");
-               for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
-                       if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
-                               i = ICAL_RECURRENCE_ARRAY_MAX;                  /* all done */
-                       }
-                       else {
-                               for (j=1; j<=ICAL_SATURDAY_WEEKDAY; ++j) {
-                                       if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j) {
-                                               wprintf("day%d, ", j);
-                                       }
+       /* Table row displaying raw RRULE data, FIXME remove when finished */
+       wprintf("<tr><td><b>");
+       wprintf("Raw data");
+       wprintf("</b></td><td>");
+       wprintf("<tt>%s</tt>", icalrecurrencetype_as_string(&recur));
+       wprintf("</td></tr>\n");
+
+       char *frequency_units[] = {
+               _("seconds"),
+               _("minutes"),
+               _("hours"),
+               _("days"),
+               _("weeks"),
+       _("months"),
+       _("years"),
+       _("never")
+       };
+
+       wprintf("<tr><td><b>");
+       wprintf(_("Repeats"));
+       wprintf("</b></td><td>");
+       if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
+       wprintf("%s ", _("every"));
+
+       wprintf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
+       wprintf("value=\"%d\"> ", recur.interval);
+
+       wprintf("<select name=\"freq\" size=\"1\">\n");
+       for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
+               wprintf("<option %s value=\"%d\">%s</option>\n",
+                       ((i == recur.freq) ? "selected" : ""),
+                       i,
+                       frequency_units[i]
+               );
+       }
+
+       wprintf("</td></tr>\n");
+
+       wprintf("<tr><td><b>");
+       wprintf("byday");                                                       //FIXME
+       wprintf("</b></td><td>");
+       for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
+               if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
+                       i = ICAL_RECURRENCE_ARRAY_MAX;                  /* all done */
+               }
+               else {
+                       for (j=1; j<=ICAL_SATURDAY_WEEKDAY; ++j) {
+                               if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j) {
+                                       wprintf("day%d, ", j);
                                }
                        }
                }
-               wprintf("</td></tr>\n");
-
-               wprintf("</table>\n");
        }
+       wprintf("</td></tr>\n");
+       wprintf("</table>\n");
+       wprintf("</div>\n");                            /* end 'rrule' div */
+
        end_tab(2, 3);
 
        /* submit buttons (common area beneath the tabs) */
@@ -476,9 +483,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wprintf("</div>\n");
 
-       wprintf("<script type=\"text/javascript\">"
-               "eventEditAllDay();"
-               "</script>\n"
+       wprintf("<script type=\"text/javascript\">      \n"
+               "eventEditAllDay();     \n"
+               "RecurrenceShowHide();  \n"
+               "</script>      \n"
        );
        address_book_popup();
        wDumpContent(1);
index 8ef0d63e00871e88c72d93f01dde19a32db60a84..1b3b8f78c65eea6d4dd2e2c457841d67033ebf5f 100644 (file)
@@ -979,3 +979,17 @@ function eventEditAllDay() {
                dtend.style.textDecoration = "";
        }
 }
+
+
+
+
+// Functions which handle show/hide of various elements in the recurrence editor
+
+function RecurrenceShowHide() {
+       if ($('is_recur').checked) {
+               $('rrule').style.display = 'block';
+       }
+       else {
+               $('rrule').style.display = 'none';
+       }
+}