rem: if (calendar) { todo.calendar = calendar; } else if ("getSelectedCalendarOrNull" in window) {  todo.calendar = getSelectedCalendarOrNull(); } 
add: todo.calendar = calendar || getSelectedCalendar(); 
context: function createTodoWithDialog(calendar, dueDate, summary, todo){    const kDefaultTimezone = calendarDefaultTimezone();    var onNewItem = function(item, calendar, originalItem) {        doTransaction('add', item, calendar, null,                      new OpCompleteListener(                          function respFunc(savedItem) {                              if (savedItem) {                                  checkForAttendees(savedItem, originalItem);                              }                          }));    }    if (todo) {        openEventDialog(todo, calendar, "new", onNewItem, null);        return;    }    todo = createTodo();    if (calendar) {        todo.calendar = calendar;    } else if ("getSelectedCalendarOrNull" in window) {        // Sunbird specific code        todo.calendar = getSelectedCalendarOrNull();    }    if (summary)        todo.title = summary;    if (dueDate)        todo.dueDate = dueDate;    var onNewItem = function(item, calendar, originalItem) {        calendar.addItem(item,                         new OpCompleteListener(                             function respFunc(savedItem) {                                 if (savedItem) {                                     checkForAttendees(savedItem, originalItem);                                 }                             }));    }    setDefaultAlarmValues(todo);    openEventDialog(todo, calendar, "new", onNewItem, null);}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/9421/b8864004460ce22942cdc33e51e57d6af6e2fce2/calendar-item-editing.js/clean/calendar/base/content/calendar-item-editing.js