raumstatus/node/notification.js

55 lines
1.8 KiB
JavaScript

var notifier = require('node-notifier');
var Notification = function (currentstate) {
this.notificate = function () {
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
});
if (currentstate == true && laststate != true) {
laststate == true;
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");
} else if (currentstate == false && laststate != false) {
laststate == false;
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");
}
};
};
module.exports = Notification;