Skip to content

Instantly share code, notes, and snippets.

@lambdabaa
Created May 1, 2013 21:16
Show Gist options
  • Save lambdabaa/5498443 to your computer and use it in GitHub Desktop.
Save lambdabaa/5498443 to your computer and use it in GitHub Desktop.
/**
* @param {MouseEvent} evt A click event on an hour element.
*/
_onHourClick: function(evt) {
/** @type {Element} */
var el = evt.target;
/** @type {DOMTokenList} */
var tokens = el.classList;
// Start at the event target and walk up the tree
// until we get to an element with the hour class
while (!tokens.contains('hour')) {
el = el.parentNode;
tokens = el.classList;
}
// TODO(gareth): I don't like storing this information in the
// HTML, so let's make these things components at some point.
/** @type {string} */
var hour;
// Loop through the classes and find the one that represents the hour
for (var i = 0; i < tokens.length; i++) {
var token = tokens.item(i);
var match = /hour-\d+/.exec(token);
if (match && match.length > 0) {
hour = match[0].split('-')[1];
}
}
var calendar = Calendar.Provider.Local.defaultCalendar;
calendar.createEvent({
calendarId: Calendar.Provider.Local.calendarId,
remote: {
isRecurring: false,
alarms: [
{ action: 'DISPLAY', trigger: 60000 }
]
}
}, function(err, busytime, evt) {
// Is here where I'm supposed to set start and end on busytime?
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment