Fixed errors

This commit is contained in:
Tim Windelschmidt 2015-09-05 16:20:21 +02:00
parent 49eb0d9959
commit d24f1852bf
2 changed files with 11 additions and 18 deletions

View File

@ -1,8 +1,11 @@
var notifier = require('node-notifier');
var path = require('path');
var Notification = function (currentstate) {
var Notification = function () {
this.notificate = function () {
var laststate = false;
this.notificate = function (currentstate) {
notifier.on('click', function (notifierObject, options) {
// Happens if `wait: true` and user clicks notification
@ -12,8 +15,8 @@ var Notification = function (currentstate) {
// Happens if `wait: true` and notification closes
});
if (currentstate == true && laststate != true) {
laststate == true;
if (currentstate === true && laststate != true) {
laststate = true;
notifier.notify({
title: 'CTDO - Status',
message: 'Der Chaostreff Dortmund ist nun offen.',
@ -25,7 +28,7 @@ var Notification = function (currentstate) {
});
//console.log("State changed to Open");
} else if (currentstate == false && laststate != false) {
laststate == false;
laststate = false;
notifier.notify({
title: 'CTDO - Status',
message: 'Der Chaostreff Dortmund ist nun geschlossen.',
@ -37,18 +40,8 @@ var Notification = function (currentstate) {
});
//console.log("State changed to Close");
}
//console.log("Currentstate: " + currentstate + " Laststate: " + laststate);
};
};
module.exports = Notification;

View File

@ -59,7 +59,7 @@ var usercountanswer = {at: 0, current_value: 0, datapoints: [
var snmpMac = new SnmpMac("juni.ctdo.de", "ctdo23");
var ippoll = new IpPoll("switch2.raum.ctdo.de", "195.160.169.30-120");
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
var notification = new Notification(spaceanswer.state.open)
var notification = new Notification();
snmpMac.on('done', function (res) {
simpleanswer.names = res;
@ -93,7 +93,7 @@ io.configure(function () {
function work() {
snmpMac.poll();
ippoll.pollCount();
notification.notificate(spaceanswer.state.open);
notification.notificate(simpleanswer.state);
}
setInterval(work, 60000);