From 86e9e03925dcdc62024563c1906bb4700933b827 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Sun, 1 Jan 2012 22:24:03 +0100 Subject: Add complete ical support --- frontend.js | 3 ++- model_fs.js | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend.js b/frontend.js index a069966..ed093f4 100644 --- a/frontend.js +++ b/frontend.js @@ -28,10 +28,11 @@ exports.start = function(config) { } var eventStr = ''; for(var date in slides['events']) { + if(!slides['events'].hasOwnProperty(date)) { continue; } eventStr = eventStr + '

'+date+'


'; } 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) { -- cgit v1.2.1