summaryrefslogtreecommitdiff
path: root/model_fs.js
diff options
context:
space:
mode:
authorBenjamin Kiessling <mittagessen@l.unchti.me>2011-11-29 15:47:48 +0100
committerBenjamin Kiessling <mittagessen@l.unchti.me>2011-11-29 15:47:48 +0100
commitc6ee6f7af1dbe3b7f58ac5075a93cf61643aebc6 (patch)
treeb66e3c2f7f14b94dc5562986d3b130dbc4c1315b /model_fs.js
parent204c62821517e1cdfe1da69afd3b19b669683b91 (diff)
Beautify code
Diffstat (limited to 'model_fs.js')
-rw-r--r--model_fs.js63
1 files changed, 35 insertions, 28 deletions
diff --git a/model_fs.js b/model_fs.js
index 8a4aa13..6c64211 100644
--- a/model_fs.js
+++ b/model_fs.js
@@ -64,6 +64,7 @@ exports.rebuildFiles = function() {
next();
}).on("end", function() {
for(var slideset in newSlides) {
+ /* collects descriptions and adds them to the slideset */
var collectDescs = function(slideset) {
fs.readFile(path.join(__dirname, configuration.dir, slideset, configuration.description), function(err, data) {
if(err) { throw err; }
@@ -80,52 +81,56 @@ exports.rebuildFiles = function() {
}
}
}
- exports.addSlides(slideset, newSlides[slideset], function(err) { if(err) { throw err; }});
- fs.readFile(path.join(__dirname, configuration.dir, 'default', configuration.events), function(err, data) {
- var events = JSON.parse(data.toString());
- if(events['type'] == 'text') {
- files[slideset]['events'] = events['events'];
- } else if(events['type'] == 'ical') {
- var compEv = [];
- ical.fromURL(events['url'], {}, function(err, data) {
- for (var k in data) {
- if (data.hasOwnProperty(k)) {
- var ev = data[k];
- if(ev.start && ev.summary) {
- compEv.push({
- date:
- ev.start,
- text:
- ev.summary
- });
- }
+ setSlides(slideset, newSlides[slideset], function(err) { if(err) { throw err; }});
+ });
+ }
+ /* collect events and adds them to the slideset */
+ var collectEvents = function(slideset) {
+ fs.readFile(path.join(__dirname, configuration.dir, 'default', configuration.events), function(err, data) {
+ if(err) { throw err; }
+ var events = JSON.parse(data.toString());
+ if(events['type'] == 'text') {
+ files[slideset]['events'] = events['events'];
+ } else if(events['type'] == 'ical') {
+ var compEv = [];
+ ical.fromURL(events['url'], {}, function(err, data) {
+ for (var k in data) {
+ if (data.hasOwnProperty(k)) {
+ var ev = data[k];
+ if(ev.start && ev.summary) {
+ compEv.push({
+ date:
+ ev.start,
+ text:
+ ev.summary
+ });
}
}
- });
- }
- });
+ }
+ });
+ }
});
}
collectDescs(slideset);
+ collectEvents(slideset);
}
});
};
-exports.setEvents = function(slideset, events, cb) {
+var setEvents = function(slideset, events, cb) {
- var found = 0;
for (var searchset in files) {
if(!files.hasOwnProperty(searchset)) { continue; }
if(files[searchset].name == slideset) {
files[searchset]['events'] = events;
- found = 1;
+ cb(null);
+ return;
}
}
- if(found) { cb('Couldn\'t find slideset'); }
- else { cb(null); }
+ cb('Couldn\'t find slideset');
};
-exports.addSlides = function(slideName, newSlides, cb) {
+var setSlides = function(slideName, newSlides, cb) {
files[slideName] = newSlides;
cb(null);
};
@@ -136,8 +141,10 @@ exports.getSlides = function(slideset, cb) {
if(!files.hasOwnProperty(searchset)) { continue; }
if(files[searchset].name == slideset) {
cb(null, files[searchset]);
+ return;
}
}
+ cb('Couldn\'t find slideset');
};
exports.getAllSlides = function(cb) {