-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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