summaryrefslogtreecommitdiff
path: root/model_fs.js
diff options
context:
space:
mode:
authorBenjamin Kiessling <mittagessen@l.unchti.me>2012-01-01 22:24:03 +0100
committerBenjamin Kiessling <mittagessen@l.unchti.me>2012-01-01 22:24:03 +0100
commit86e9e03925dcdc62024563c1906bb4700933b827 (patch)
tree1e6539993a4da73e19760625147f6c984e904e90 /model_fs.js
parent9f699b4ed028796f37f2dc55218d432612354414 (diff)
Add complete ical support
Diffstat (limited to 'model_fs.js')
-rw-r--r--model_fs.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/model_fs.js b/model_fs.js
index 3e2af12..23d113f 100644
--- a/model_fs.js
+++ b/model_fs.js
@@ -97,19 +97,23 @@ exports.rebuildFiles = function() {
if(err) { throw err; }
});
} else if(events['type'] == 'ical') {
- ical.fromURL(events['url'], {}, function(err, data) {
+ ical.fromURL(events['url'], {}, function(err, bloat) {
if(err) { throw err; }
+ var bDate = new Date();
+ var fDate = new Date();
+ bDate.setMinutes(bDate.getMinutes() - events['before']);
+ fDate.setMinutes(bDate.getMinutes() + events['after']);
+ var data = ical.events_between(bDate, fDate);
var compEv = [];
for (var k in data) {
- if (data.hasOwnProperty(k)) {
- var ev = data[k];
- if(ev.start && ev.summary) {
- var curDate = new Date(ev.start);
- if(typeof compEv[curDate.toDateString()] == "undefined") {
- compEv[curDate.toDateString()] = [];
- }
- compEv[curDate.toDateString()].push({time: curDate.toTimeString(), text: ev.summary});
+ if (!data.hasOwnProperty(k)) { continue; }
+ var ev = data[k];
+ ev.time = ev.start.toTimeString();
+ if(ev.start && ev.summary) {
+ if(typeof compEv[ev.start.toDateString()] == "undefined") {
+ compEv[ev.start.toDateString()] = [];
}
+ compEv[ev.start.toDateString()].push(ev);
}
}
setEvents(slideset, compEv, function(err) {