123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 'use strict';
- var title = 'My Event Title';
- var loc = 'My Event Location';
- var notes = 'My interesting Event notes.';
- var startDate = new Date();
- var endDate = new Date();
- var calendarName = 'MyCal';
- var options = {
- url: 'https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin',
- calendarName: calendarName, // iOS specific
- calendarId: 1 // Android specific
- };
- // clean up the dates a bit
- startDate.setMinutes(0);
- endDate.setMinutes(0);
- startDate.setSeconds(0);
- endDate.setSeconds(0);
- // add a few hours to the dates, JS will automatically update the date (+1 day) if necessary
- startDate.setHours(startDate.getHours() + 2);
- endDate.setHours(endDate.getHours() + 3);
- function onSuccess(msg) {
- alert('Calendar success: ' + JSON.stringify(msg));
- }
- function onError(msg) {
- alert('Calendar error: ' + JSON.stringify(msg));
- }
- function hasReadPermission() {
- window.plugins.calendar.hasReadPermission(onSuccess);
- }
- function requestReadPermission() {
- window.plugins.calendar.requestReadPermission(onSuccess);
- }
- function hasWritePermission() {
- window.plugins.calendar.hasWritePermission(onSuccess);
- }
- function requestWritePermission() {
- window.plugins.calendar.requestWritePermission(onSuccess);
- }
- function hasReadWritePermission() {
- window.plugins.calendar.hasReadWritePermission(onSuccess);
- }
- function requestReadWritePermission() {
- window.plugins.calendar.requestReadWritePermission(onSuccess);
- }
- function openCalendar() {
- // today + 3 days
- var d = new Date(new Date().getTime() + 3 * 24 * 60 * 60 * 1000);
- window.plugins.calendar.openCalendar(d, onSuccess, onError);
- }
- function listCalendars() {
- window.plugins.calendar.listCalendars(onSuccess, onError);
- }
- function createCalendar() {
- var options = window.plugins.calendar.getCreateCalendarOptions();
- options.calendarName = "MyCordovaCalendar";
- options.calendarColor = "#FF0000"; // red
- window.plugins.calendar.createCalendar(options, onSuccess, onError);
- }
- function deleteCalendar() {
- window.plugins.calendar.deleteCalendar("MyCordovaCalendar", onSuccess, onError);
- }
- function deleteEvent() {
- window.plugins.calendar.deleteEvent(title, loc, notes, startDate, endDate, onSuccess, onError);
- }
- function createCalendarEvent() {
- window.plugins.calendar.createEvent(title, loc, notes, startDate, endDate, onSuccess, onError);
- }
- function createCalendarEventInteractively() {
- window.plugins.calendar.createEventInteractively(title, loc, notes, startDate, endDate, onSuccess, onError);
- }
- function createCalendarEventInteractivelyWithOptions() {
- window.plugins.calendar.createEventInteractivelyWithOptions(title, loc, notes, startDate, endDate, options, onSuccess, onError);
- }
- function createCalendarEventWithOptions() {
- window.plugins.calendar.createEventWithOptions(title, loc, notes, startDate, endDate, options, onSuccess, onError);
- }
- function findEventWithFilter() {
- window.plugins.calendar.findEvent(title, loc, notes, startDate, endDate, onSuccess, onError);
- }
- function findEventNoFilter() {
- window.plugins.calendar.findEvent(null, null, null, startDate, endDate, onSuccess, onError);
- }
- function listEventsInRange() {
- startDate.setHours(startDate.getHours() - 12);
- window.plugins.calendar.listEventsInRange(startDate, endDate, onSuccess, onError);
- }
- window.onerror = function(msg, file, line) {
- alert(msg + '; ' + file + '; ' + line);
- };
|