See also:
http://clientside.cnet.com/wiki/cnet-libraries/06-request/00-jsonp

On Mon, Oct 6, 2008 at 9:01 PM, Sean Mehra <
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:

>
> In case people need a handy script to load their Google Calendar data
> onto their site using AJAX:
>
> var GCalendar = new Class({
>
>     Implements: [Options, Events],
>
>     options: {
>         uri: "",
>         orderby: "starttime",
>         singleEvents: true,
>         futureEvents: true,
>         sortOrder: "ascending",
>         maxResults: 5
>         /*onSuccess: $empty*/
>     },
>
>     entries: {},
>
>     initialize: function(options) {
>         this.setOptions(options);
>         options = this.options;
>
>         window.activeCalendar = this;
>         var script = new Asset.javascript(
>             "http://www.google.com/calendar/feeds/"; +
>             options.uri +
>             "/public/full-noattendees?orderby=" +
>             options.orderby +
>             "&alt=json-in-
> script&callback=window.activeCalendar.parseFeed&" +
>             "&max-results=" + options.maxResults +
>             "&singleevents=" + options.singleEvents +
>             "&sortorder=" + options.sortOrder +
>             "&futureevents=" + options.futureEvents
>         );
>         return this;
>     },
>
>         parseFeed: function(json){
>         var cal = this;
>         $A(json.feed.entry).each(function(e, i){
>             cal.entries[i] = (function(entry){
>                 return $H({
>                     title: entry.title.$t,
>                     content: entry.content.$t,
>                     startDate: cal.rfc3339toDate(entry.gd
> $when[0].startTime),
>                     endDate: cal.rfc3339toDate(entry.gd
> $when[0].endTime),
>                     location: entry.gd$where[0].valueString
>                 });
>             })(e)
>         });
>                 this.fireEvent('success');
>         },
>
>     rfc3339toDate: function(t){
>                 t = t.substr(0,19).replace(/-/g,"/").replace("T"," ");
>                 var dt = new Date();
>                 dt.setTime(Date.parse(t));
>                 return dt;
>         }
> });
>
>
>
> When you instantiate the class, pass an onSuccess function that
> references "this.entries" and uses those Hashes to generate whatever
> HTML they may need.
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/Google-Calendar-JSON-Data-AJAX-Class-tp1302629p1302629.html
> To start a new topic under MooTools Users, email
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>


-----
The MooTools Tutorial:  http://www.mootorial.com www.mootorial.com 
CNET Clientside:  http://clientside.cnet.com clientside.cnet.com 
-- 
View this message in context: 
http://n2.nabble.com/Google-Calendar-JSON-Data-AJAX-Class-tp1302629p1302646.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to