Commit cf9077b5 authored by Lisa Övermyr's avatar Lisa Övermyr
Browse files

Add method and status parameter to event

parent e5550634
......@@ -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,8 +100,17 @@ var a = {
};
}
// Cancel event status
_event.cancel = e.cancel || false;
// 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;
......@@ -192,9 +203,11 @@ var a = {
if(e.url) {
g += 'URL;VALUE=URI:' + e.url + '\n';
}
if(e.cancel) {
g += 'METHOD:CANCEL\n'
g += 'STATUS:CANCELLED\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