Skip to content

Instantly share code, notes, and snippets.

@sirdlx
Created February 19, 2014 00:45
Show Gist options
  • Save sirdlx/9083988 to your computer and use it in GitHub Desktop.
Save sirdlx/9083988 to your computer and use it in GitHub Desktop.
Custom Google calendar using jquery
<div class="post">
</div>
<script type="text/javascript">
$.ajax({
url: "https://www.google.com/calendar/feeds/****CALENDAR ID****/public/full?alt=json"
}).done(function(data) {
var html="";
$.each( data.feed.entry, function( i, eventData ) {
html +="<div class='entry'>";
html +="<strong>" + eventData.title.$t +"</strong>";
html +="<p>" + eventData.content.$t +"</p>";
var d = new Date(eventData.gd$when[0].startTime);
var ampm = d.getHours() >= 12 ? 'pm' : 'am';
var time = d.getHours() >= 12 ? d.getHours()-12 : d.getHours();
time = time == 0 ? 12 : time;
html +="<div class='post-info'>"
html +="<div class='date'>" + (d.getMonth()+1) + "/" + d.getDate()+ " @" + time + ampm + "</div>";
html +="<div class='location'>" + eventData.gd$where[0].valueString+
" <a href='http://maps.google.com/maps?q="+eventData.gd$where[0].valueString+"'>map"+"</a></div></div>";
html +="</div>";
});
$(".post").append(html);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment