Skip to content

Instantly share code, notes, and snippets.

@listenrightmeow
Created August 17, 2015 22:32
Show Gist options
  • Save listenrightmeow/35062a334f3555692ebb to your computer and use it in GitHub Desktop.
Save listenrightmeow/35062a334f3555692ebb to your computer and use it in GitHub Desktop.
Dynamic ICS
$(target, this.$el).on('click', function() {
var now = new Date(),
dtstamp = now.toISOString(),
dtend = function() { now.setHours(19,0,0,0); return now; },
dtstart = function() { now.setHours(18,0,0,0); return now; },
meow = 'location',
summary = 'summary',
icsMSG = 'BEGIN:VCALENDAR\nVERSION:2.0\n' +
'PRODID:-//Take Back The Table//NONSGML v1.0//EN\n' +
'CALSCALE:GREGORIAN\n' +
'BEGIN:VEVENT\n' +
'UID:info@takebackthetable.org\n' +
'DTSTAMP:' + dtstamp + '\n' +
'ATTENDEE;CN=me;\n' +
'ORGANIZER;CN=Me\n' +
'DTSTART:' + dtstart +'\n' +
'DTEND:' + dtend +'\n' +
'LOCATION:' + meow + '\n' +
'SUMMARY:' + summary + '\n' +
'END:VEVENT\n' +
'END:VCALENDAR';
window.open('data:text/calendar;charset=utf8,' + escape(icsMSG));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment