Skip to content

Instantly share code, notes, and snippets.

@sionide21
Last active August 29, 2015 14:19
Show Gist options
  • Save sionide21/dec7ecc0fa8d3f37dbec to your computer and use it in GitHub Desktop.
Save sionide21/dec7ecc0fa8d3f37dbec to your computer and use it in GitHub Desktop.
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