text: function ISODateString(e){function t(e){return 10>e?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"Z"}function adjustDate(e){return MM={Jan:"January",Feb:"February",Mar:"March",Apr:"April",May:"May",Jun:"June",Jul:"July",Aug:"August",Sep:"September",Oct:"October",Nov:"November",Dec:"December"},DD={Sun:"Sunday",Mon:"Monday",Tue:"Tuesday",Wed:"Wednesday",Thu:"Thursday",Fri:"Friday",Sat:"Saturday"},proper_date=String(new Date(e)).split(" "),correct_formatting=DD[proper_date[0]]+" "+MM[proper_date[1]]+" "+proper_date[2]+", "+proper_date[3]+" - ",clock_time=proper_date[4].substring(0,proper_date[4].length-3),"00"==clock_time.substring(0,2)?clock_time="12"+clock_time.substring(2,clock_time.length)+" AM":"0"==clock_time.substring(0,1)?clock_time=clock_time.substring(1,clock_time.length)+" AM":Number(clock_time.substring(0,2))<12?clock_time+=" AM":12==Number(clock_time.substring(0,2))?clock_time+=" PM":Number(clock_time.substring(0,2))>12&&(new_number=String(Number(clock_time.substring(0,2))-12),clock_time=new_number+clock_time.substring(2,clock_time.length)+" PM"),correct_formatting+=clock_time,correct_formatting}!function(e){e.grabCalendar=function(t){var r,n=encodeURI("https://www.googleapis.com/calendar/v3/calendars/"+calendarid+"/events?singleEvents=true&orderBy=startTime&key="+mykey);if("undefined"!=typeof t&&(t.hasOwnProperty("maxEvents")&&t.maxEvents<2501&&(n=n+"&maxResults="+t.maxEvents),t.hasOwnProperty("upcoming")&&t.upcoming)){var i=new Date;n=n+"&timeMin="+ISODateString(i)}return e.ajax({type:"GET",url:n,dataType:"json",async:!1,success:function(e){var n={};if("undefined"==typeof t)return void(r=e);if(t.hasOwnProperty("clean_date")&&t.clean_date)for(var i=0;i<e.items.length;i++)e.items[i].end.dateTime=adjustDate(e.items[i].end.dateTime),e.items[i].start.dateTime=adjustDate(e.items[i].start.dateTime);if(t.hasOwnProperty("metadata")){for(var i=0;i<t.metadata.length;i++)n[t.metadata[i]]=!0;for(var i=0;i<e.items.length;i++)if("undefined"!=typeof e.items[i].description)for(var a=e.items[i].description.split("\n"),o=0;o<a.length;o++){var s=a[o].split(": ");s[0]in n&&(e.items[i][s[0]]=s[1])}}if("undefined"!=typeof t&&!t.hasOwnProperty("type")||"full"==t.type)r=e;else if("events"===t.type){r=[];for(var i=0;i<e.items.length;i++){var c={};if(c.start=e.items[i].start.dateTime,c.end=e.items[i].end.dateTime,c.summary=e.items[i].summary,"undefined"!=typeof e.items[i].description&&(c.description=e.items[i].description),"undefined"!=typeof e.items[i].location&&(c.location=e.items[i].location),t.hasOwnProperty("metadata"))for(var m in n)c[m]=e.items[i][m];r.push(c)}}else"detailedEvents"===t.type?r=e.items:console.log("The request of type: "+type+" wasn't valid. Please check for possible syntax errors.")},error:function(e){console.log("The Google Calender API failed to connect.")}}),r}}(jQuery);