Skip to content

Instantly share code, notes, and snippets.

@timdorr
Forked from sionide21/railsconf_schedule.rb
Last active August 29, 2015 14:19
Show Gist options
  • Save timdorr/44dbde4cbbea9ae41ca4 to your computer and use it in GitHub Desktop.
Save timdorr/44dbde4cbbea9ae41ca4 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
var authuser = 2; // Change if you have multiple Google accounts logged in. This is zero-indexed.
$("<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").format("YYYYMMDDTHHmmss");
},
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",
authuser: authuser
}));
}).css("cursor", "copy");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment