Home

Awesome

Calendarth

Fetch a Public Google Calendar with AJAX

A helper library that fetches and parses a public Google Calendar using the Google API v3.

This package requires jQuery to exist in the global namespace as $, hopefully future versions will decouple this dependency, pull requests welcome.

Install

bower install calendarth --save

Documentation

You can access Calendarth using the globally available variable calendarth or as a browserify module. Here's how you can get a new Calendarth instance by invoking the global:

var calendarth = window.calendarth({
  calendarId: 'xxx',
  appId: 'xxx',
});

Look into the build/ folder for available modular and global exposing builds.

Calendarth Options

When initializing a new Calendarth Object you may pass the following options:

Calendarth Methods

calendarth.fetch(cb)

Fetches the entries of the calendar. Accepts a node style callback:

var cal = calendarth();

cal.fetch(function(err, calendarObj) {
  err === null; // true
  typeof calendarObj === 'object'; // true
});

The returned Object is the raw Data Object as passed from the Google Calendar Api v3, you can view a beautified object in this wiki page.

calendarth.getEventUrl(eventItem)

Will return a url that can be used to add the event to a user's Google Calendar.

cal.fetch(function(err, calendarObj) {
  err === null; // true

  // get the first event item
  var eventItem = calendarObj.item.shift();

  var addEventToCal = cal.getEventUrl(eventItem);
  console.log(addEventToCal);
});

Release History

License

Copyright 2013 Thanasis Polychronakis

Licensed under the MIT License