Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(8000);
app.use(express.static(__dirname + '/public'));
io.on('connection', function (socket) {
//socket.emit('meta', 'reload');
});
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
// for reasons
DOW = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
pad = function (n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
var normalizedPath = require("path").join(__dirname, "modules");
require("fs").readdirSync(normalizedPath).forEach(function(file) {
if (endsWith(file,'.js')) {
try {
require("./modules/" + file)(io);
console.log(file+" loaded");
} catch (e) {
console.log("Error loading "+file);
console.log(e);
}
}
});