aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webcals/templates
diff options
context:
space:
mode:
Diffstat (limited to 'lib/webcals/templates')
-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')]
+));
+