fullcalendar/src/gcal.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

2009-09-21 06:57:20 +02:00
/*
* FullCalendar Google Calendar Extension
*
* Copyright (c) 2009 Adam Shaw
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Date:
*
2009-09-21 06:57:20 +02:00
*/
2009-04-26 06:43:27 +02:00
(function($) {
2009-05-30 07:54:53 +02:00
$.fullCalendar.gcalFeed = function(feedUrl, options) {
2009-04-26 06:43:27 +02:00
2009-05-30 07:54:53 +02:00
feedUrl = feedUrl.replace(/\/basic$/, '/full');
options = options || {};
2009-04-26 06:43:27 +02:00
2009-05-30 07:54:53 +02:00
return function(start, end, callback) {
2009-11-01 00:51:30 +01:00
var params = {
'start-min': $.fullCalendar.formatDate(start, 'u'),
'start-max': $.fullCalendar.formatDate(end, 'u'),
'singleevents': true,
'max-results': 9999
};
if (options.currentTimezone) {
params.ctz = options.currentTimezone.replace(' ', '_');
}
$.getJSON(feedUrl + "?alt=json-in-script&callback=?", params, function(data) {
var events = [];
if (data.feed.entry) {
$.each(data.feed.entry, function(i, entry) {
var startStr = entry['gd$when'][0]['startTime'],
start = $.fullCalendar.parseISO8601(startStr, true),
end = $.fullCalendar.parseISO8601(entry['gd$when'][0]['endTime'], true),
allDay = startStr.indexOf('T') == -1,
url;
$.each(entry.link, function() {
if (this.type == 'text/html') {
url = this.href;
2009-06-29 07:36:29 +02:00
}
2009-05-30 07:54:53 +02:00
});
2009-11-01 00:51:30 +01:00
if (allDay) {
$.fullCalendar.addDays(end, -1); // make inclusive
}
events.push({
id: entry['gCal$uid']['value'],
title: entry['title']['$t'],
url: url,
start: start,
end: end,
allDay: allDay,
location: entry['gd$where'][0]['valueString'],
description: entry['content']['$t'],
className: options.className,
editable: options.editable || false
});
});
}
callback(events);
});
2009-05-30 07:54:53 +02:00
}
2009-09-21 06:57:20 +02:00
2009-05-30 07:54:53 +02:00
}
2009-04-26 06:43:27 +02:00
2009-11-01 00:51:30 +01:00
})(jQuery);