else if (repeatType == 1) {
// Repeat weekly
$('weeklyWeeksField').value = parent$("repeat1").value;
- var weekDiv = $("week").firstChild;
- var daysArray = parent$("repeat2").value.split(",");
- daysArray.each(function(index) {
- $(weekDiv).down('div', index).addClassName("_selected");
+ var weekDiv = $($("week").firstChild);
+// log ("div: " + weekDiv);
+// log ("days: " + parent$("repeat2").value);
+ var days = "" + parent$("repeat2").value;
+ if (days.length > 0) {
+ var daysArray = days.split(",");
+ var divs = weekDiv.childNodesWithTag("div");
+ daysArray.each(function(index) {
+ divs[index-1].addClassName("_selected");
});
+ }
}
else if (repeatType == 2) {
// Repeat monthly
$('monthlyRepeat').value = parent$("repeat3").value;
$('monthlyDay').value = parent$("repeat4").value;
var monthDiv = $("month");
- var daysArray = parent$("repeat5").value.split(",");
- daysArray.each(function(index) {
- $(monthDiv).down('DIV[name="'+index+'"]').addClassName("_selected");
- });
+ var days = "" + parent$("repeat5").value;
+ if (days.length > 0) {
+ var daysArray = days.split(",");
+ daysArray.each(function(index) {
+ $(monthDiv).down('DIV[name="'+index+'"]').addClassName("_selected");
+ });
+ }
}
else if (repeatType == 3) {
// Repeat yearly
// We check if the dailyDaysField really contains an integer
if (radioValue == 0) {
+ var showError = true;
+
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
+// log("v: " + v);
+ if (!isNaN(v) && v > 0) {
validate = true;
+ showError = false;
+ parent$("repeat1").value = radioValue;
+ parent$("repeat2").value = v;
+ }
}
+
+ if (showError)
+ window.alert("Please specify a numerical value in the Days field greater or equal to 1.");
}
- else
+ else {
validate = true;
-
- if (validate) {
parent$("repeat1").value = radioValue;
- parent$("repeat2").value = v;
}
return validate;
function handleWeeklyRecurrence() {
var validate = false;
+ var showError = true;
var fieldValue = "" + $('weeklyWeeksField').value;
+ if (fieldValue.length > 0) {
+ // We check if the weeklyWeeksField really contains an integer
+ var v = parseInt(fieldValue);
+ if (!isNaN(v) && v > 0) {
+ validate = true;
+ showError = false;
+ parent$("repeat1").value = fieldValue;
+ parent$("repeat2").value = getSelectedDays($('week'));
+ }
+ }
- // We check if the weeklyWeeksField really contains an integer
- var v = parseInt(fieldValue);
- if (isNaN(v) || v <= 0)
+ if (showError)
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;
}
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'));
+ var showError = true;
+
+ var fieldValue = "" + $('monthlyMonthsField').value;
+ if (fieldValue.length > 0) {
+ var v = parseInt(fieldValue);
+ if (!isNaN(v) && v > 0) {
+ validate = true;
+ showError = false;
+ parent$("repeat1").value = fieldValue;
+ parent$("repeat2").value = radioValue;
+ parent$("repeat3").value = $('monthlyRepeat').value;
+ parent$("repeat4").value = $('monthlyDay').value;
+ parent$("repeat5").value = getSelectedDays($('month'));
+ }
}
+
+ if (showError)
+ window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1.");
}
return validate;
}
function handleYearlyRecurrence() {
- var validate = true;
+ var validate = false;
- 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;
+ var radioValue = $('recurrence_form').getRadioValue('yearlyRadioButtonName');
// FIXME - right now we do not support rules
// such as Every Second Tuesday of February
- if (parent$("repeat2").value == 1) {
+ if (radioValue == 1)
window.alert("This type of recurrence is currently unsupported.");
- validate = false;
- }
+ else {
+ var showError = true;
- // 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;
+ var fieldValue = "" + $('yearlyYearsField').value;
+ if (fieldValue.length > 0) {
+ // We check if the yearlyYearsField really contains an integer
+ var v = parseInt(fieldValue);
+ if (!isNaN(v) && v > 0) {
+ validate = true;
+ showError = false;
+ parent$("repeat1").value = fieldValue;
+ parent$("repeat2").value = radioValue;
+ 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;
+ }
+ }
+
+ if (showError)
+ window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1.");
}
return validate;
}
-function validateRange() {
- var validate = true;
-
- var range = $('recurrence_form').getRadioValue('rangeRadioButtonName');
- parent$("range1").value = range;
+function handleRange() {
+ var validate = false;
- if (range == 1) {
- parent$("range2").value = $('rangeAppointmentsField').value;
+ var radioValue = $('recurrence_form').getRadioValue('rangeRadioButtonName');
+ if (radioValue == 0)
+ validate = true;
+ else if (radioValue == 1) {
+ var showError = true;
+
+ var fieldValue = "" + $('rangeAppointmentsField').value;
+ if (fieldValue.length > 0) {
+ // We check if the rangeAppointmentsField really contains an integer
+ var v = parseInt(fieldValue);
+ if (!isNaN(v) && v > 0) {
+ validate = true;
+ showError = false;
+ parent$("range2").value = fieldValue;
+ }
+ }
- // We check if the rangeAppointmentsField really contains an integer
- var v = parseInt(parent$("range2").value);
- if (isNaN(v) || v <= 0) {
+ if (showError)
window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1.");
- validate = false;
- }
}
- else if (range == 2)
+ else if (radioValue == 2) {
+ validate = true;
parent$("range2").value = $('endDate_date').value;
+ }
+
+ if (validate)
+ parent$("range1").value = radioValue;
return validate;
}
else
validate = handleYearlyRecurrence();
- if (validate
- && validateRange())
+ if (validate && handleRange())
window.close();
}