2 * FullCalendar v1.5.2 Google Calendar Plugin
4 * Copyright (c) 2011 Adam Shaw
5 * Dual licensed under the MIT and GPL licenses, located in
6 * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
8 * Date: Sun Aug 21 22:06:09 2011 -0700
15 var fc
= $.fullCalendar
;
16 var formatDate
= fc
.formatDate
;
17 var parseISO8601
= fc
.parseISO8601
;
18 var addDays
= fc
.addDays
;
19 var applyAll
= fc
.applyAll
;
22 fc
.sourceNormalizers
.push(function(sourceOptions
) {
23 if (sourceOptions
.dataType
== 'gcal' ||
24 sourceOptions
.dataType
=== undefined &&
25 (sourceOptions
.url
|| '').match(/^(http|https):\/\/www.google.com\/calendar\/feeds\//)) {
26 sourceOptions
.dataType
= 'gcal';
27 if (sourceOptions
.editable
=== undefined) {
28 sourceOptions
.editable
= false;
34 fc
.sourceFetchers
.push(function(sourceOptions
, start
, end
) {
35 if (sourceOptions
.dataType
== 'gcal') {
36 return transformOptions(sourceOptions
, start
, end
);
41 function transformOptions(sourceOptions
, start
, end
) {
43 var success
= sourceOptions
.success
;
44 var data
= $.extend({}, sourceOptions
.data
|| {}, {
45 'start-min': formatDate(start
, 'u'),
46 'start-max': formatDate(end
, 'u'),
51 var ctz
= sourceOptions
.currentTimezone
;
53 data
.ctz
= ctz
= ctz
.replace(' ', '_');
56 return $.extend({}, sourceOptions
, {
57 url
: sourceOptions
.url
.replace(/\/basic$/, '/full') + '?alt=json-in-script&callback=?',
62 success: function(data
) {
64 if (data
.feed
.entry
) {
65 $.each(data
.feed
.entry
, function(i
, entry
) {
66 var startStr
= entry
['gd$when'][0]['startTime'];
67 var start
= parseISO8601(startStr
, true);
68 var end
= parseISO8601(entry
['gd$when'][0]['endTime'], true);
69 var allDay
= startStr
.indexOf('T') == -1;
71 $.each(entry
.link
, function(i
, link
) {
72 if (link
.type
== 'text/html') {
75 url
+= (url
.indexOf('?') == -1 ? '?' : '&') + 'ctz=' + ctz
;
80 addDays(end
, -1); // make inclusive
83 id
: entry
['gCal$uid']['value'],
84 title
: entry
['title']['$t'],
89 location
: entry
['gd$where'][0]['valueString'],
90 description
: entry
['content']['$t']
94 var args
= [events
].concat(Array
.prototype.slice
.call(arguments
, 1));
95 var res
= applyAll(success
, this, args
);
107 fc
.gcalFeed = function(url
, sourceOptions
) {
108 return $.extend({}, sourceOptions
, { url
: url
, dataType
: 'gcal' });