From 25036a2a2b7c514adc1b821b71efc99c7449d33c Mon Sep 17 00:00:00 2001 From: Andrzej Popowski Date: Thu, 28 Jan 2016 11:30:02 +0100 Subject: [PATCH] [Calendar] - improving examples Change-Id: I4f03438f3c91eaf3838e0ee6ac244d7a9bf007ee Signed-off-by: Andrzej Popowski --- .../html/device_api/mobile/tizen/calendar.html | 193 +++++++++++++++++++-- 1 file changed, 181 insertions(+), 12 deletions(-) diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html index 2263768..d1e53cb 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/calendar.html @@ -2936,11 +2936,11 @@ The default value is 0, implies that the task has not been started.

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);
  
@@ -3657,13 +3657,11 @@ By default, this attribute is set to null. 1.0

-

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");
  
@@ -3780,6 +3778,31 @@ The default value is an empty string.
+
+

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);
+  }
+ 
+
@@ -3822,6 +3845,29 @@ The default value is an empty string. +
+

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);
+ 
+
@@ -3864,6 +3910,47 @@ The default value is an empty string. +
+

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);
+ 
+
@@ -3909,6 +3996,32 @@ 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) {
+      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'});
+ 
+
-- 2.7.4