1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
window.addEventListener("load", function(e) {timeline.setupCalendar(e)}, true);
var timeline = {
setupCalendar: function setupCalendar() {
//setting up listeners etc
if (this.calendar == null) {
this.calendar = getCompositeCalendar();
}
if (this.calendar) {
this.calendar.removeObserver(this.calendarObserver);
}
this.calendar.addObserver(this.calendarObserver);
if (this.mListener) {
this.mListener.updatePeriod();
}
},
calendarOpListener: {
onOperationComplete: function timeline_onOC(calendarObserver, status, optype, id, detail) {
},
onGetResult: function timeline__onGR(calendarObserver, status, itemtype, detail, count, items) {
if (!Components.isSuccessCode(status)) {
return;
}
items.forEach(this.timeline.addItem, this.timeline);
}
},
calendarObserver: {
QueryInterface: function timeline_QI(aIID) {
if (!aIID.equals(Components.interfaces.calIObserver) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
onAddItem: function timeline_onAddItem(item) {
refresh();
},
onDeleteItem: function timeline_onDeleteItem(item, rebuildFlag) {
refresh();
},
onModifyItem: function timeline_onModifyItem(newItem, oldItem) {
refresh();
},
onCalendarAdded: function timeline_calAdd(aCalendar) {
refresh();
},
onCalendarRemoved: function timeline_calRemove(aCalendar) {
refresh();
},
onError: function(cal, errno, msg) {
},
onStartBatch: function timeline_onStartBatch() {
this.mBatchCount++;
},
onEndBatch: function() {
this.mBatchCount--;
if (this.mBatchCount == 0) {
this.timeline.refreshCalendarQuery();
}
},
onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
},
onPropertyDeleting: function(aCalendar, aName) {
},
onDefaultCalendarChanged: function(aCalendar) {
},
onLoad: function() {
refresh();
}
}
};
|