rem: if (calendarItemArray.length == 0) { 
add: if (!calendarItemArray.length) { 
context: function copyToClipboard( calendarItemArray ){      if(!calendarItemArray)    {        calendarItemArray = new Array();        calendarItemArray = gCalendarWindow.EventSelection.selectedEvents;    }    if (calendarItemArray.length == 0) {        dump("Tried to cut/copy 0 events");        return false;    }    var icssrv = Components.classes["@mozilla.org/calendar/ics-service;1"]                       .getService(Components.interfaces.calIICSService);    var calComp = icssrv.createIcalComponent("VCALENDAR");    calComp.version = "2.0";    calComp.prodid = "-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN";    for each (item in calendarItemArray) {        // If we copy an item and paste it again, it will have the same ID as        // the original.  Therefore, give every item a new ID.        var dummyItem = Components.classes["@mozilla.org/calendar/event;1"]                                  .createInstance(Components.interfaces.calIEvent);        var newItem = item.clone();        newItem.id = dummyItem.id;        calComp.addSubcomponent(newItem.icalComponent);    }    // XXX This might not be enough to be Outlook compatible    var sTextiCalendar = calComp.serializeToICS();    // 1. get the clipboard service    var clipboard = getClipboard();    // 2. create the transferable    var trans = new Transferable;    if ( trans && clipboard) {        // 3. register the data flavors        trans.addDataFlavor("text/calendar");        trans.addDataFlavor("text/unicode");        // 4. create the data objects        var icalWrapper = new SupportsString;        // get the data        icalWrapper.data = sTextiCalendar;        // 5. add data objects to transferable        // Both Outlook 2000 client and Lotus Organizer use text/unicode         // when pasting iCalendar data        trans.setTransferData("text/calendar", icalWrapper,                              icalWrapper.data.length*2 ); // double byte data        trans.setTransferData("text/unicode", icalWrapper,                               icalWrapper.data.length*2 );        clipboard.setData(trans, null,                          Components.interfaces.nsIClipboard.kGlobalClipboard );        return true;             }    return true;}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/daf762c7fca63c377d255ff7e70b1b7a4b4cb141/clipboard.js/clean/calendar/resources/content/clipboard.js