From f4404dab04527494b26fbdea39d4102c520279b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Sun, 6 Jul 2014 01:24:49 +0200 Subject: [PATCH] try to add a image api --- node/statusbot.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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);