try to add a image api

This commit is contained in:
Lucas Pleß 2014-07-06 01:24:49 +02:00
parent 5e8249d0e4
commit f4404dab04
1 changed files with 15 additions and 6 deletions

View File

@ -12,9 +12,9 @@ var spaceanswer = {
api: "0.13", api: "0.13",
space: "Chaostreff Dortmund", space: "Chaostreff Dortmund",
logo: "http://www.chaostreff-dortmund.de/logo/logo_ctdo.svg", logo: "http://www.chaostreff-dortmund.de/logo/logo_ctdo.svg",
"icon":{ icon: {
"open":"http://status.ctdo.de/img/green.png", open:"http://status.ctdo.de/img/green.png",
"closed":"http://status.ctdo.de/img/red.png" closed:"http://status.ctdo.de/img/red.png"
}, },
url: "http://www.chaostreff-dortmund.de/", url: "http://www.chaostreff-dortmund.de/",
location: { 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) { snmpMac.on('done', function (res) {
simpleanswer.names = res; simpleanswer.names = res;
simpleanswer.lastchange = moment().format("X"); simpleanswer.lastchange = new Date().getTime();
}); });
ippoll.on('doneCount', function (num) { ippoll.on('doneCount', function (num) {
simpleanswer.count = num; simpleanswer.count = num;
simpleanswer.lastchange = moment().format("X"); simpleanswer.lastchange = new Date().getTime();
ippoll.pollState(); ippoll.pollState();
}); });
ippoll.on('doneState', function (state) { ippoll.on('doneState', function (state) {
spaceanswer.state.open = state; spaceanswer.state.open = state;
spaceanswer.state.lastchange = moment().format("X"); spaceanswer.state.lastchange = new Date().getTime();
simpleanswer.state = state; simpleanswer.state = state;
simpleanswer.lastchange = spaceanswer.state.lastchange; simpleanswer.lastchange = spaceanswer.state.lastchange;
io.sockets.emit('sdata', { data: simpleanswer }); 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.get('/db', routes.db);
app.post('/form', routes.form); app.post('/form', routes.form);