Commit 9e67a68c authored by Sebastian Pekarek's avatar Sebastian Pekarek
Browse files

Merge branch 'ellell-cancelled-event'

parents 43baa002 f3959125
......@@ -110,6 +110,12 @@ cal.addEvent({
#### options.url (String)
Appointment Website
#### options.method (String)
Appointment method. May be any of the following: publish, request, reply, add, cancel, refresh, counter, declinecounter.
#### options.status (String)
Appointment status. May be any of the following: confirmed, tenative, cancelled.
### save(file[, cb])
Save Calendar to disk asynchronously using [fs.writeFile](http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback)
......
......@@ -34,7 +34,9 @@ var a = {
return cal.methods;
},
addEvent: function(e) {
var _event = {};
var _event = {},
allowedMethods = ['PUBLISH', 'REQUEST', 'REPLY', 'ADD', 'CANCEL', 'REFRESH', 'COUNTER', 'DECLINECOUNTER'],
allowedStatuses = ['CONFIRMED', 'TENATIVE', 'CANCELLED'];
if(!e || typeof e !== 'object') {
throw 'event is not an object.';
......@@ -98,6 +100,18 @@ var a = {
};
}
// Method
if(e.method && allowedMethods.indexOf(e.method.toUpperCase()) === -1) {
throw 'event.method must be one of the following: ' + allowedMethods.join(', ');
}
_event.method = e.method;
// Status
if(e.status && allowedStatuses.indexOf(e.status.toUpperCase()) === -1) {
throw 'event.status must be one of the following: ' + allowedStatuses.join(', ');
}
_event.status = e.status;
// URL
_event.url = e.url || null;
......@@ -189,6 +203,12 @@ var a = {
if(e.url) {
g += 'URL;VALUE=URI:' + e.url + '\n';
}
if(e.method) {
g += 'METHOD:' + e.method.toUpperCase() + '\n'
}
if(e.status) {
g += 'STATUS:' + e.status.toUpperCase() + '\n'
}
g += 'END:VEVENT\n';
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment