2 * FullCalendar v1.6.4 Google Calendar Plugin
3 * Docs & License: http://arshaw.com/fullcalendar/
10 var fc = $.fullCalendar;
11 var formatDate = fc.formatDate;
12 var parseISO8601 = fc.parseISO8601;
13 var addDays = fc.addDays;
14 var applyAll = fc.applyAll;
17 fc.sourceNormalizers.push(function(sourceOptions) {
18 if (sourceOptions.dataType == 'gcal' ||
19 sourceOptions.dataType === undefined &&
20 (sourceOptions.url || '').match(/^(http|https):\/\/www.google.com\/calendar\/feeds\//)) {
21 sourceOptions.dataType = 'gcal';
22 if (sourceOptions.editable === undefined) {
23 sourceOptions.editable = false;
29 fc.sourceFetchers.push(function(sourceOptions, start, end) {
30 if (sourceOptions.dataType == 'gcal') {
31 return transformOptions(sourceOptions, start, end);
36 function transformOptions(sourceOptions, start, end) {
38 var success = sourceOptions.success;
39 var data = $.extend({}, sourceOptions.data || {}, {
40 'start-min': formatDate(start, 'u'),
41 'start-max': formatDate(end, 'u'),
46 var ctz = sourceOptions.currentTimezone;
48 data.ctz = ctz = ctz.replace(' ', '_');
51 return $.extend({}, sourceOptions, {
52 url: sourceOptions.url.replace(/\/basic$/, '/full') + '?alt=json-in-script&callback=?',
57 success: function(data) {
59 if (data.feed.entry) {
60 $.each(data.feed.entry, function(i, entry) {
61 var startStr = entry['gd$when'][0]['startTime'];
62 var start = parseISO8601(startStr, true);
63 var end = parseISO8601(entry['gd$when'][0]['endTime'], true);
64 var allDay = startStr.indexOf('T') == -1;
66 $.each(entry.link, function(i, link) {
67 if (link.type == 'text/html') {
70 url += (url.indexOf('?') == -1 ? '?' : '&') + 'ctz=' + ctz;
75 addDays(end, -1); // make inclusive
78 id: entry['gCal$uid']['value'],
79 title: entry['title']['$t'],
84 location: entry['gd$where'][0]['valueString'],
85 description: entry['content']['$t']
89 var args = [events].concat(Array.prototype.slice.call(arguments, 1));
90 var res = applyAll(success, this, args);
102 fc.gcalFeed = function(url, sourceOptions) {
103 return $.extend({}, sourceOptions, { url: url, dataType: 'gcal' });