rem: var event = createEvent(); 
add:   var onNewEvent = function(event, calendar, originalEvent) { calendar.addItem(event, null); }  if (event) { openEventDialog(event, calendar, "new", onNewEvent); return; }  event = createEvent(); 
context: function createEventWithDialog(calendar, startDate, endDate, summary){    const kDefaultTimezone = calendarDefaultTimezone();    var event = createEvent();    if (!startDate) {        startDate = jsDateToDateTime(new Date());        startDate.second = 0;        startDate.normalize();    } else if (startDate.isDate) {        startDate = startDate.clone();        startDate.isDate = false;        event.startDate.isDate = false;        /* set the hour/minute of startDate to "right now"           if the day is the same */        var now = jsDateToDateTime(new Date()).getInTimezone(kDefaultTimezone).clone();        var nowDate = now.clone();        nowDate.isDate = true;        nowDate.normalize();        if (startDate.compare(nowDate) == 0) {            /* they're the same, so set now's seconds to 0,               normalize and change startDate to be now. */            now.second = 0;            now.normalize();            startDate = now;        }    }    event.startDate = startDate.clone();    event.startDate.isDate = false;    if (!endDate) {        endDate = startDate.clone();        endDate.hour = endDate.hour + 1; // XXX we should get a default duration from prefs        endDate.normalize();    }    event.endDate = endDate.clone();    if (calendar) {        event.calendar = calendar;    }    if (summary)        event.title = summary;    var onNewEvent = function(event, calendar, originalEvent) {        calendar.addItem(event, null);    }    openEventDialog(event, calendar, "new", onNewEvent);}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/edb75cb3aa7fe2a0098e7d7a97a91ce5dd7f6556/calendar-item-editing.js/clean/calendar/base/content/calendar-item-editing.js