diff --git a/node/statusbot.js b/node/statusbot.js index f16da23..e12f160 100644 --- a/node/statusbot.js +++ b/node/statusbot.js @@ -12,9 +12,9 @@ var spaceanswer = { api: "0.13", space: "Chaostreff Dortmund", logo: "http://www.chaostreff-dortmund.de/logo/logo_ctdo.svg", - "icon":{ - "open":"http://status.ctdo.de/img/green.png", - "closed":"http://status.ctdo.de/img/red.png" + icon: { + open:"http://status.ctdo.de/img/green.png", + closed:"http://status.ctdo.de/img/red.png" }, url: "http://www.chaostreff-dortmund.de/", location: { @@ -43,18 +43,18 @@ var ippoll = new IpPoll("switch2.raum.ctdo.de", "195.160.169.20-62 195.160.169.7 snmpMac.on('done', function (res) { simpleanswer.names = res; - simpleanswer.lastchange = moment().format("X"); + simpleanswer.lastchange = new Date().getTime(); }); ippoll.on('doneCount', function (num) { simpleanswer.count = num; - simpleanswer.lastchange = moment().format("X"); + simpleanswer.lastchange = new Date().getTime(); ippoll.pollState(); }); ippoll.on('doneState', function (state) { spaceanswer.state.open = state; - spaceanswer.state.lastchange = moment().format("X"); + spaceanswer.state.lastchange = new Date().getTime(); simpleanswer.state = state; simpleanswer.lastchange = spaceanswer.state.lastchange; io.sockets.emit('sdata', { data: simpleanswer }); @@ -114,6 +114,15 @@ app.get('/api/usercount', function (req, res) { }); }); +app.get('/api/simple/image', function (req, res) { + if(spaceanswer.state.open == true) { + res.sendfile('img/green.png'); + } else if(spaceanswer.state.open == false) { + res.sendfile('img/red.png'); + } else { + res.sendfile('img/yellow.png'); + } +}); app.get('/db', routes.db); app.post('/form', routes.form);