var notifier = require('node-notifier');
var path = require('path');

var Notification = function () {

     var laststate = false;

     this.notificate = function (currentstate) {

        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");
        }
	//console.log("Currentstate: " + currentstate + " Laststate: " + laststate);
    };
};

module.exports = Notification;
