Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make the Schedule Items at http://railsconf.com/schedule clickable to add to your Google Calendar
$("<script/>", {type: "text/javascript", src: "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"}).appendTo(document.body);
$(".session-content a").on("click", function() { event.stopPropagation(); });
$(".session-content").on("click", function() {
var session = $(this),
title = session.find(".session-title"),
details = title.find("a")[0].href,
speaker = session.find(".speaker-name"),
room = $("th").eq(session.parent().index()),
text = function(el) { return el.text().trim(); },
day = $(".schedule-tab.active").text().trim().split(", ")[1],
timeSlot = session.parents("tr").find(".schedule-time-slot").text().trim().split(" - "),
date = function(time) {
return moment(day + " " + time, "MMMM D H:mm:A").utc().format("YYYYMMDDTHHmmss\\Z");
},
parsedTimeSlot = date(timeSlot[0]) + "/" + date(timeSlot[1]);
window.open("https://www.google.com/calendar/render?" + $.param({
action: "TEMPLATE",
text: text(title),
dates: parsedTimeSlot,
details: text(speaker) + " - " + details,
location: text(room),
sf: true,
output: "xml"
}));
}).css("cursor", "copy");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment