aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2012-06-27 12:39:28 +0200
committerJames Lal <james@lightsofapollo.com>2012-06-27 12:39:28 +0200
commit24932d09294ab7a80b9c00ff505bc2823f1a65d1 (patch)
treeef9d38d2cb2827a3e710770d673d14e8c36fd881 /lib
parentd74007aca2c501ac2fe56f8c440f01f6f6ceaa1f (diff)
downloadjsCalDAV-24932d09294ab7a80b9c00ff505bc2823f1a65d1.tar.gz
Simple calendar filter (with no actual filtering) based on calendar data
Diffstat (limited to 'lib')
-rw-r--r--lib/webcals/templates/calendar_data.js20
-rw-r--r--lib/webcals/templates/calendar_filter.js27
2 files changed, 41 insertions, 6 deletions
diff --git a/lib/webcals/templates/calendar_data.js b/lib/webcals/templates/calendar_data.js
index 9ff2a1e..a0c0938 100644
--- a/lib/webcals/templates/calendar_data.js
+++ b/lib/webcals/templates/calendar_data.js
@@ -6,6 +6,10 @@
CalendarData.prototype = {
+ rootName: 'calendar-data',
+ compName: 'comp',
+ propName: 'prop',
+
/**
* Appends a list of fields
* to a given iCalendar field set.
@@ -19,7 +23,11 @@
struct[type] = [];
}
- struct[type] = struct[type].concat(list);
+ if (list instanceof Array) {
+ struct[type] = struct[type].concat(list);
+ } else {
+ struct[type] = list;
+ }
return this;
},
@@ -45,15 +53,15 @@
);
} else {
elementOutput += template.tag(
- ['caldav', 'prop'],
+ ['caldav', this.propName],
{ name: value[i] }
);
}
}
output += template.tag(
- ['caldav', 'comp'],
+ ['caldav', this.compName],
{ name: tag },
- elementOutput
+ elementOutput || null
);
elementOutput = '';
}
@@ -70,9 +78,9 @@
render: function(template) {
var struct = this.struct;
var output = template.tag(
- ['caldav', 'calendar-data'],
+ ['caldav', this.rootName],
template.tag(
- ['caldav', 'comp'],
+ ['caldav', this.compName],
{ name: 'VCALENDAR' },
this._renderFieldset(template, struct)
)
diff --git a/lib/webcals/templates/calendar_filter.js b/lib/webcals/templates/calendar_filter.js
new file mode 100644
index 0000000..15cfc8c
--- /dev/null
+++ b/lib/webcals/templates/calendar_filter.js
@@ -0,0 +1,27 @@
+(function(module, ns) {
+
+ var CalendarData = ns.require('templates/calendar_data');
+
+ function CalendarFilter() {
+ CalendarData.call(this);
+ }
+
+ CalendarFilter.prototype = {
+
+ __proto__: CalendarData.prototype,
+
+ filter: CalendarData.prototype.select,
+
+ compName: 'comp-filter',
+ rootName: 'filter'
+ };
+
+ module.exports = CalendarFilter;
+
+}.apply(
+ this,
+ (this.Webcals) ?
+ [Webcals('templates/calendar_data'), Webcals] :
+ [module, require('../webcals')]
+));
+