diff options
-rw-r--r-- | frontend.js | 3 | ||||
-rw-r--r-- | 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 + '<h4>'+date+'</h4><hr><ul>'; for(var ev in slides['events'][date]) { if(!slides['events'][date].hasOwnProperty(ev)) { continue; } - eventStr = eventStr + '<li>'+slides['events'][date][ev]['time']+' - '+slides['events'][date][ev]['text']+'</li>'; + eventStr = eventStr + '<li>'+slides['events'][date][ev]['time']+' - '+slides['events'][date][ev]['summary']+'</li>'; } eventStr = eventStr + '</ul>'; } 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) { |