From: Andrzej Popowski Code example: var eventInit = { description: "HTML5 Introduction",
- summary: "HTML5 Webinar",
- startDate: new tizen.TZDate(2011, 3, 30, 10, 0),
- duration: new tizen.TimeDuration(1, "HOURS"),
- location: "Huesca" };
-
+ summary: "HTML5 Webinar",
+ startDate: new tizen.TZDate(2011, 3, 30, 10, 0),
+ duration: new tizen.TimeDuration(1, "HOURS"),
+ location: "Huesca" };
+
var ev = new tizen.CalendarEvent(eventInit);
Code example:
// Creates a sound alarm at the specified time - var alarm = new tizen.CalendarAlarm(new tizen.TZDate(2011, 3, 30, 10, 0), "SOUND"); --
Code example:
// Creates a sound alarm 30 minutes before the event's start time. - var alarm = new tizen.CalendarAlarm(new tizen.TimeDuration(30, "MINS"), "SOUND"); +Code example:
// Creates a sound alarm at the specified time + var alarm1 = new tizen.CalendarAlarm(new tizen.TZDate(2011, 3, 30, 10, 0), "SOUND"); + + // Creates a sound alarm before an event starts + var alarm2 = new tizen.CalendarAlarm(new tizen.TimeDuration(1, "MINS"), "SOUND");
Code example:
// eventId should be set to ID of event obtained with the find function. + var eventId; + // Defines the error callback. + function errorCallback(response) { + console.log( 'The following error occurred: ' + response.name); + } + + // CalendarEventArraySuccessCallback instance + function calendarEventArraySuccessCB(events) { + console.log(events.length + ' event instances were returned.'); + } + + var calendar = tizen.calendar.getDefaultCalendar(); + var event = calendar.get(eventId); + + if (event.recurrenceRule != null) { + // This is a recurring event. Expands all the instances during August 2011. + event.expandRecurrence(new tizen.TZDate(2011, 7, 1), + new tizen.TZDate(2011, 7, 31), + calendarEventArraySuccessCB, + errorCallback); + } ++
Code example:
// Defines the error callback. + function errorCallback(response) { + console.log( 'The following error occurred: ' + response.name); + } + + // CalendarItemArraySuccessCallback instance + function calendarItemArraySuccessCB(events) { + console.log("Successfully added " + events.length + " events!"); + } + + // Gets the default calendar. + var calendar = tizen.calendar.getDefaultCalendar("EVENT"); + + var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca'}); + + calendar.addBatch([ev], calendarItemArraySuccessCB, errorCallback); ++
Code example:
var calendar; + + function eventFoundCallback(events) { + // The event has been successfully found. + // Changes the summary. + events[0].summary = 'HTML6 Webinar'; + calendar.update(events[0]); + console.log('First event was updated!'); + } + + // Defines the error callback for all the asynchronous calls. + function errorCallback(response) { + console.log( 'The following error occurred: ' + response.name); + } + + // CalendarArraySuccessCallback instance + function calendarArraySuccessCB(calendars) { + if(calendars.length > 0) { + calendar = calendars[0]; + console.log('The calendar id is ' + calendar.id + ' and name ' + calendar.name); + + var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', + summary:'HTML5 Webinar', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca'}); + calendar.add(ev); + + // The event has been successfully added. + // Checks whether the added event can be retrieved from the calendar. + // If the calendar was empty, only the item added through add() should be returned. + var filter = new tizen.AttributeFilter('summary', 'CONTAINS', 'HTML5'); + calendar.find(eventFoundCallback, errorCallback, filter); + } + } + + // Gets a list of available calendars. + tizen.calendar.getCalendars("EVENT", calendarArraySuccessCB, errorCallback); ++
Code example:
var watcherId = 0; // watcher identifier + var calendar; // This example assumes calendar is initialized + + var watcher = { + onitemsadded: function(items) { + console.log('New item ' + items[0].id + ' added'); + }, + onitemsupdated: function(items) { + // ... + }, + onitemsremoved: function(ids) { + // ... + } + }; + + // Registers to be notified when the calendar changes. + watcherId = calendar.addChangeListener(watcher); + + var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca'}); ++
onitemsupdated
@@ -3932,6 +4045,34 @@ The default value is an empty string.
+Code example:
var watcherId = 0; // watcher identifier + var calendar; // This example assumes calendar is initialized + + var watcher = { + onitemsadded: function(items) { + if (calendar.update) { + items[0].location = 'New York'; + calendar.update(items[0]); + } + }, + onitemsupdated: function(items) { + console.log('Item updated'); + }, + onitemsremoved: function(ids) { + // ... + } + }; + + // Registers to be notified when the calendar changes. + watcherId = calendar.addChangeListener(watcher); + var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca'}); ++
onitemsremoved
@@ -3955,6 +4096,34 @@ The default value is an empty string.
+Code example:
var watcherId = 0; // watcher identifier + var calendar; // This example assumes calendar is initialized + + var watcher = { + onitemsadded: function(items) { + if (calendar.remove) { + calendar.remove(items[0].id); + } + }, + onitemsupdated: function(items) { + // ... + }, + onitemsremoved: function(ids) { + console.log('Item removed'); + } + }; + + // Registers to be notified when the calendar changes. + watcherId = calendar.addChangeListener(watcher); + + var ev = new tizen.CalendarEvent({description:'HTML5 Introduction', + summary:'HTML5 Webinar ', + startDate: new tizen.TZDate(2011, 3, 30, 10, 0), + duration: new tizen.TimeDuration(1, "HOURS"), + location:'Huesca'}); ++