aboutsummaryrefslogtreecommitdiffstats
path: root/lib/caldav/sax
diff options
context:
space:
mode:
Diffstat (limited to 'lib/caldav/sax')
-rw-r--r--lib/caldav/sax/calendar_data_handler.js39
-rw-r--r--lib/caldav/sax/dav_response.js23
-rw-r--r--lib/caldav/sax/index.js5
3 files changed, 43 insertions, 24 deletions
diff --git a/lib/caldav/sax/calendar_data_handler.js b/lib/caldav/sax/calendar_data_handler.js
new file mode 100644
index 0000000..d24bfb0
--- /dev/null
+++ b/lib/caldav/sax/calendar_data_handler.js
@@ -0,0 +1,39 @@
+(function(module, ns) {
+
+ var Base = ns.require('sax/base');
+
+ var CalendarDataHandler = Base.create({
+ name: 'calendar data',
+
+ //don't add text only elements
+ //to the stack as objects
+ onopentag: null,
+ onclosetag: null,
+
+ //add the value to the parent
+ //value where key is local tag name
+ //and value is the text.
+ ontext: function(data) {
+ var handler = this.handler;
+ this.current[this.currentTag[handler.tagField]] =
+ CalendarDataHandler.parseICAL(data);
+ }
+ });
+
+ /**
+ * Default ical parser handler.
+ *
+ * XXX: Feels a little hacky but works...
+ */
+ CalendarDataHandler.parseICAL = function(input) {
+ return input;
+ };
+
+ module.exports = CalendarDataHandler;
+
+}.apply(
+ this,
+ (this.Caldav) ?
+ [Caldav('sax/calendar_data_handler'), Caldav] :
+ [module, require('../caldav')]
+));
diff --git a/lib/caldav/sax/dav_response.js b/lib/caldav/sax/dav_response.js
index 0957376..e257027 100644
--- a/lib/caldav/sax/dav_response.js
+++ b/lib/caldav/sax/dav_response.js
@@ -1,12 +1,9 @@
(function(module, ns) {
- if (typeof(ICAL) === 'undefined') {
- require('../../ical.js');
- }
-
var HTTP_STATUS = /([0-9]{3,3})/;
var Base = ns.require('sax/base');
+ var CalendarDataHandler = ns.require('sax/calendar_data_handler');
var TextHandler = Base.create({
name: 'text',
@@ -25,24 +22,6 @@
}
});
- var CalendarDataHandler = Base.create({
- name: 'calendar data',
-
- //don't add text only elements
- //to the stack as objects
- onopentag: null,
- onclosetag: null,
-
- //add the value to the parent
- //value where key is local tag name
- //and value is the text.
- ontext: function(data) {
- var handler = this.handler;
- this.current[this.currentTag[handler.tagField]] = ICAL.parse(data);
- }
- });
-
-
var HrefHandler = Base.create({
name: 'href',
diff --git a/lib/caldav/sax/index.js b/lib/caldav/sax/index.js
index 2ba2f16..3e5ea99 100644
--- a/lib/caldav/sax/index.js
+++ b/lib/caldav/sax/index.js
@@ -1,8 +1,9 @@
(function(module, ns) {
module.exports = {
- Abstract: ns.require('sax/abstract'),
- CalendarQuery: ns.require('sax/dav_response')
+ Base: ns.require('sax/base'),
+ CalendarDataHandler: ns.require('sax/calendar_data_handler'),
+ DavResponse: ns.require('sax/dav_response')
};
}.apply(