rem: var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); var alarmsBranch = prefService.getBranch("calendar.alarms.");  if (alarmsBranch.getIntPref("onfortodos") == 1) {  if (!calendarToDo.entryDate) calendarToDo.entryDate = jsDateToDateTime( gCalendarWindow.currentView.getNewEventDate()); var alarmOffset = Components.classes["@mozilla.org/calendar/duration;1"] .createInstance(Components.interfaces.calIDuration); try { var units = alarmsBranch.getCharPref("todoalarmunit"); alarmOffset[units] = alarmsBranch.getIntPref("todoalarmlen"); } catch(ex) { alarmOffset.minutes = 15; } calendarToDo.alarmOffset = alarmOffset; calendarToDo.alarmRelated = calendarToDo.ALARM_RELATED_START; } 
add: setDefaultAlarmValues(calendarToDo); 
context: function newToDo ( startDate, dueDate ) {    var calendarToDo = createToDo();       // created todo has no start or due date unless user wants one    if (startDate)         calendarToDo.entryDate = jsDateToDateTime(startDate);    if (dueDate)        calendarToDo.dueDate = jsDateToDateTime(startDate);   var prefService = Components.classes["@mozilla.org/preferences-service;1"]                               .getService(Components.interfaces.nsIPrefService);   var alarmsBranch = prefService.getBranch("calendar.alarms.");   if (alarmsBranch.getIntPref("onfortodos") == 1) {       // You can't have an alarm if the entryDate doesn't exist.       if (!calendarToDo.entryDate)           calendarToDo.entryDate = jsDateToDateTime(                                    gCalendarWindow.currentView.getNewEventDate());       var alarmOffset = Components.classes["@mozilla.org/calendar/duration;1"]                                   .createInstance(Components.interfaces.calIDuration);       try {           var units = alarmsBranch.getCharPref("todoalarmunit");           alarmOffset[units] = alarmsBranch.getIntPref("todoalarmlen");       } catch(ex) {           alarmOffset.minutes = 15;       }       calendarToDo.alarmOffset = alarmOffset;       calendarToDo.alarmRelated = calendarToDo.ALARM_RELATED_START;   }    var calendar = getSelectedCalendarOrNull();        createTodoWithDialog(calendar, null, null, calendarToDo);}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/20ddf51dcf4127d7e432e56e796e520f3a5e035b/calendar.js/buggy/calendar/resources/content/calendar.js