fullcalendar/fullcalendar/gcal.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2009-05-31 22:56:02 +02:00
/*!
* FullCalendar Google Calendar Extension
2009-04-27 05:46:02 +02:00
*
2009-05-31 22:56:02 +02:00
* Visit http://arshaw.com/fullcalendar/docs/#google-calendar
* for docs and examples.
2009-04-27 05:46:02 +02:00
*
* 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
2009-05-31 22:56:02 +02:00
*
* Date:
* Revision:
2009-04-27 05:46:02 +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 || {};
var draggable = options.draggable || false;
2009-04-26 06:43:27 +02:00
2009-05-30 07:54:53 +02:00
return function(start, end, callback) {
$.getJSON(feedUrl + "?alt=json-in-script&callback=?",
{
'start-min': $.fullCalendar.formatDate(start, 'c'),
'start-max': $.fullCalendar.formatDate(end, 'c'),
'singleevents': true
},
function(data) {
var events = [];
if (data.feed.entry)
$.each(data.feed.entry, function(i, entry) {
var url;
$.each(entry['link'], function(j, link) {
if (link.type == 'text/html') url = link.href;
2009-04-26 06:43:27 +02:00
});
2009-05-30 07:54:53 +02:00
var showTime = entry['gd$when'][0]['startTime'].indexOf('T') != -1;
events.push({
id: entry['gCal$uid']['value'],
url: url,
title: entry['title']['$t'],
start: $.fullCalendar.parseDate(entry['gd$when'][0]['startTime']),
end: $.fullCalendar.parseDate(entry['gd$when'][0]['endTime']),
location: entry['gd$where'][0]['valueString'],
description: entry['content']['$t'],
showTime: showTime,
className: [showTime ? 'nobg' : null, options.className],
draggable: draggable
});
});
callback(events);
});
}
2009-04-26 06:43:27 +02:00
2009-05-30 07:54:53 +02:00
}
2009-04-26 06:43:27 +02:00
})(jQuery);