* Boston, MA 02111-1307, USA.
*/
+#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import "SOGoAppointmentFolder.h"
return @"Personal calendar";
}
+// /* CalDAV support */
+// - (NSArray *) davComplianceClassesInContext: (WOContext *) localContext
+// {
+// NSMutableArray *newClasses;
+
+// newClasses
+// = [NSMutableArray arrayWithArray:
+// [super davComplianceClassesInContext: localContext]];
+// [newClasses addObject: @"calendar-access"];
+
+// return newClasses;
+// }
+
+// - (NSArray *) davCalendarHomeSet
+// {
+// /*
+// <C:calendar-home-set xmlns:D="DAV:"
+// xmlns:C="urn:ietf:params:xml:ns:caldav">
+// <D:href>http://cal.example.com/home/bernard/calendars/</D:href>
+// </C:calendar-home-set>
+
+// Note: this is the *container* for calendar collections, not the
+// collections itself. So for use its the home folder, the
+// public folder and the groups folder.
+// */
+// NSArray *tag;
+
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [self davURL], nil];
+
+// return [NSArray arrayWithObject: tag];
+// }
+
+// - (NSArray *) davCalendarUserAddressSet
+// {
+// NSArray *tag, *allEmails;
+// NSMutableArray *addresses;
+// NSEnumerator *emails;
+// NSString *currentEmail;
+
+// addresses = [NSMutableArray array];
+
+// allEmails = [[context activeUser] allEmails];
+// emails = [allEmails objectEnumerator];
+// while ((currentEmail = [emails nextObject]))
+// {
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [NSString stringWithFormat: @"mailto:%@", currentEmail],
+// nil];
+// [addresses addObject: tag];
+// }
+
+// return addresses;
+// }
+
+// - (NSArray *) davCalendarScheduleInboxURL
+// {
+// NSArray *tag;
+
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [NSString stringWithFormat: @"%@personal/", [self davURL]],
+// nil];
+
+// return [NSArray arrayWithObject: tag];
+// }
+
+// - (NSString *) davCalendarScheduleOutboxURL
+// {
+// NSArray *tag;
+
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [NSString stringWithFormat: @"%@personal/", [self davURL]],
+// nil];
+
+// return [NSArray arrayWithObject: tag];
+// }
+
+// - (NSString *) davDropboxHomeURL
+// {
+// NSArray *tag;
+
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [NSString stringWithFormat: @"%@personal/", [self davURL]],
+// nil];
+
+// return [NSArray arrayWithObject: tag];
+// }
+
+// - (NSString *) davNotificationsURL
+// {
+// NSArray *tag;
+
+// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
+// [NSString stringWithFormat: @"%@personal/", [self davURL]],
+// nil];
+
+// return [NSArray arrayWithObject: tag];
+// }
+
@end
currentRepeatType: 0
}
-function onRepeatTypeChange(event) {
- setRepeatType(parseInt(this.value));
-}
+ function onRepeatTypeChange(event) {
+ setRepeatType(parseInt(this.value));
+ }
function setRepeatType(type) {
var elements;
var elementsArray = $A(element.getElementsByTagName('DIV'));
var days = new Array();
elementsArray.each(function(item) {
- if (isNodeSelected(item))
+ if (isNodeSelected(item))
days.push(item.readAttribute("name"));
});
return days.join(",");
}
function initializeWindowButtons() {
- var okButton = $("okButton");
- var cancelButton = $("cancelButton");
+ var okButton = $("okButton");
+ var cancelButton = $("cancelButton");
- Event.observe(okButton, "click", onEditorOkClick, false);
- Event.observe(cancelButton, "click", onEditorCancelClick, false);
+ Event.observe(okButton, "click", onEditorOkClick, false);
+ Event.observe(cancelButton, "click", onEditorCancelClick, false);
- $("repeatType").observe("change", onRepeatTypeChange, false);
+ var repeatType = $("repeatType");
+ setRepeatType(parseInt(repeatType.value));
+ repeatType.observe("change", onRepeatTypeChange, false);
}
function initializeFormValues() {
$("range_of_recurrence").show();
}
+function handleDailyRecurrence() {
+ var validate = false;
+
+ var radioValue = $('recurrence_form').getRadioValue('dailyRadioButtonName');
+
+ // We check if the dailyDaysField really contains an integer
+ if (radioValue == 0) {
+ var v = "" + $('dailyDaysField').value;
+ if (v.length > 0) {
+ v = parseInt(v);
+ if (isNaN(v) || v <= 1)
+ window.alert("Please specify a numerical value in the Days field greater or equal to 1.");
+ else
+ validate = true;
+ }
+ }
+ else
+ validate = true;
+
+ if (validate) {
+ parent$("repeat1").value = radioValue;
+ parent$("repeat2").value = v;
+ }
+
+ return validate;
+}
+
+function handleWeeklyRecurrence() {
+ var validate = false;
+
+ var fieldValue = "" + $('weeklyWeeksField').value;
+
+ // We check if the weeklyWeeksField really contains an integer
+ var v = parseInt(fieldValue);
+ if (isNaN(v) || v <= 0)
+ window.alert("Please specify a numerical value in the Week(s) field greater or equal to 1.");
+ else {
+ validate = true;
+ parent$("repeat1").value = fieldValue;
+ parent$("repeat2").value = getSelectedDays($('week'));
+ }
+
+ return validate;
+}
+
+function handleMonthlyRecurrence() {
+ var validate = false;
+
+ var radioValue = $('recurrence_form').getRadioValue('monthlyRadioButtonName');
+
+ // FIXME - right now we do not support rules
+ // such as The Second Tuesday...
+ if (radioValue == 0)
+ window.alert("This type of recurrence is currently unsupported.");
+ else {
+ // We check if the monthlyMonthsField really contains an integer
+ var fieldValue = $('monthlyMonthsField').value;
+ var v = parseInt(fieldValue);
+ if (isNaN(v) || v <= 0)
+ window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1.");
+ else {
+ parent$("repeat1").value = fieldValue;
+ parent$("repeat2").value = radioValue;
+ parent$("repeat3").value = $('monthlyRepeat').value;
+ parent$("repeat4").value = $('monthlyDay').value;
+ parent$("repeat5").value = getSelectedDays($('month'));
+ }
+ }
+
+ return validate;
+}
+
+function handleYearlyRecurrence() {
+ var validate = true;
+
+ parent$("repeat1").value = $('yearlyYearsField').value;
+ parent$("repeat2").value = $('recurrence_form').getRadioValue('yearlyRadioButtonName');
+ parent$("repeat3").value = $('yearlyDayField').value;
+ parent$("repeat4").value = $('yearlyMonth1').value;
+ parent$("repeat5").value = $('yearlyRepeat').value;
+ parent$("repeat6").value = $('yearlyDay').value;
+ parent$("repeat7").value = $('yearlyMonth2').value;
+
+ // FIXME - right now we do not support rules
+ // such as Every Second Tuesday of February
+ if (parent$("repeat2").value == 1) {
+ window.alert("This type of recurrence is currently unsupported.");
+ validate = false;
+ }
+
+ // We check if the yearlyYearsField really contains an integer
+ var v = parseInt(parent$("repeat1").value);
+ if (isNaN(v) || v <= 0) {
+ window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1.");
+ validate = false;
+ }
+
+ return validate;
+}
+
+function validateRange() {
+ var validate = true;
+
+ var range = $('recurrence_form').getRadioValue('rangeRadioButtonName');
+ parent$("range1").value = range;
+
+ if (range == 1) {
+ parent$("range2").value = $('rangeAppointmentsField').value;
+
+ // We check if the rangeAppointmentsField really contains an integer
+ var v = parseInt(parent$("range2").value);
+ if (isNaN(v) || v <= 0) {
+ window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1.");
+ validate = false;
+ }
+ }
+ else if (range == 2)
+ parent$("range2").value = $('endDate_date').value;
+
+ return validate;
+}
+
function onEditorOkClick(event) {
- preventDefault(event);
- var repeatType = $("repeatType").value;
- var v;
-
- parent$("repeatType").value = repeatType;
-
- if (repeatType == 0) {
- // Repeat daily
- v = $('recurrence_form').getRadioValue('dailyRadioButtonName')
- parent$("repeat1").value = v;
-
- // We check if the dailyDaysField really contains an integer
- if (v == 0) {
- parent$("repeat2").value = $('dailyDaysField').value;
- v = parseInt(parent$("repeat2").value);
- if (isNaN(v) || v <= 0) {
- window.alert("Please specify a numerical value in the Days field greater or equal to 1.");
- return false;
- }
- }
- }
- else if (repeatType == 1) {
- // Repeat weekly
- v = $('weeklyWeeksField').value;
- parent$("repeat1").value = v;
- parent$("repeat2").value = getSelectedDays($('week'));
-
- // We check if the weeklyWeeksField really contains an integer
- v = parseInt(v);
- if (isNaN(v) || v <= 0) {
- window.alert("Please specify a numerical value in the Week(s) field greater or equal to 1.");
- return false;
- }
- }
- else if (repeatType == 2) {
- // Repeat monthly
- v = $('monthlyMonthsField').value;
- parent$("repeat1").value = v;
- parent$("repeat2").value = $('recurrence_form').getRadioValue('monthlyRadioButtonName');
- parent$("repeat3").value = $('monthlyRepeat').value;
- parent$("repeat4").value = $('monthlyDay').value;
- parent$("repeat5").value = getSelectedDays($('month'));
-
- // FIXME - right now we do not support rules
- // such as The Second Tuesday...
- if (parent$("repeat2").value == 0) {
- window.alert("This type of recurrence is currently unsupported.");
- return false;
- }
-
- // We check if the monthlyMonthsField really contains an integer
- v = parseInt(v);
- if (isNaN(v) || v <= 0) {
- window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1.");
- return false;
- }
- }
- else {
- // Repeat yearly
- parent$("repeat1").value = $('yearlyYearsField').value;
- parent$("repeat2").value = $('recurrence_form').getRadioValue('yearlyRadioButtonName');
- parent$("repeat3").value = $('yearlyDayField').value;
- parent$("repeat4").value = $('yearlyMonth1').value;
- parent$("repeat5").value = $('yearlyRepeat').value;
- parent$("repeat6").value = $('yearlyDay').value;
- parent$("repeat7").value = $('yearlyMonth2').value;
-
- // FIXME - right now we do not support rules
- // such as Every Second Tuesday of February
- if (parent$("repeat2").value == 1) {
- window.alert("This type of recurrence is currently unsupported.");
- return false;
- }
-
- // We check if the yearlyYearsField really contains an integer
- v = parseInt(parent$("repeat1").value);
- if (isNaN(v) || v <= 0) {
- window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1.");
- return false;
- }
- }
-
- var range = $('recurrence_form').getRadioValue('rangeRadioButtonName');
- parent$("range1").value = range;
-
- if (range == 1) {
- parent$("range2").value = $('rangeAppointmentsField').value;
-
- // We check if the rangeAppointmentsField really contains an integer
- v = parseInt(parent$("range2").value);
- if (isNaN(v) || v <= 0) {
- window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1.");
- return false;
- }
- }
- else if (range == 2) {
- parent$("range2").value = $('endDate_date').value;
- }
-
- window.close();
+ preventDefault(event);
+ var repeatType = $("repeatType").value;
+ parent$("repeatType").value = repeatType;
+
+ var validate;
+ if (repeatType == 0)
+ validate = handleDailyRecurrence();
+ else if (repeatType == 1)
+ validate = handleWeeklyRecurrence();
+ else if (repeatType == 2)
+ validate = handleMonthlyRecurrence();
+ else
+ validate = handleYearlyRecurrence();
+
+ if (validate
+ && validateRange())
+ window.close();
}
function onEditorCancelClick(event) {
- preventDefault(event);
- window.close();
+ preventDefault(event);
+ window.close();
}
function onRecurrenceLoadHandler() {