raumstatus/node/notification.js

48 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-09-05 10:18:35 +00:00
var notifier = require('node-notifier');
2015-09-05 14:20:21 +00:00
var path = require('path');
2015-09-05 10:18:35 +00:00
2015-09-05 14:20:21 +00:00
var Notification = function () {
2015-09-05 10:18:35 +00:00
2015-09-05 14:20:21 +00:00
var laststate = false;
this.notificate = function (currentstate) {
2015-09-05 10:18:35 +00:00
notifier.on('click', function (notifierObject, options) {
// Happens if `wait: true` and user clicks notification
});
notifier.on('timeout', function (notifierObject, options) {
// Happens if `wait: true` and notification closes
});
2015-09-05 14:20:21 +00:00
if (currentstate === true && laststate != true) {
laststate = true;
2015-09-05 10:18:35 +00:00
notifier.notify({
title: 'CTDO - Status',
message: 'Der Chaostreff Dortmund ist nun offen.',
icon: path.join('public/img/green.png'), // absolute path (not balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // wait with callback until user action is taken on notification
}, function (err, response) {
// response is response from notification
});
//console.log("State changed to Open");
2015-09-05 10:18:35 +00:00
} else if (currentstate == false && laststate != false) {
2015-09-05 14:20:21 +00:00
laststate = false;
2015-09-05 10:18:35 +00:00
notifier.notify({
title: 'CTDO - Status',
message: 'Der Chaostreff Dortmund ist nun geschlossen.',
icon: path.join('public/img/red.png'), // absolute path (not balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // wait with callback until user action is taken on notification
}, function (err, response) {
// response is response from notification
});
//console.log("State changed to Close");
2015-09-05 10:18:35 +00:00
}
2015-09-05 14:20:21 +00:00
//console.log("Currentstate: " + currentstate + " Laststate: " + laststate);
2015-09-05 10:18:35 +00:00
};
};
module.exports = Notification;