summaryrefslogtreecommitdiff
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
parent9f699b4ed028796f37f2dc55218d432612354414 (diff)
Add complete ical support
-rw-r--r--frontend.js3
-rw-r--r--model_fs.js22
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) {