1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
node-red-nodes/social/notify/57-notify.js
2016-11-06 20:26:19 +00:00

27 lines
784 B
JavaScript

module.exports = function(RED) {
"use strict";
var growl = require('growl');
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
function NotifyNode(n) {
RED.nodes.createNode(this,n);
this.title = n.title;
var node = this;
node.on("input",function(msg) {
var titl = node.title || msg.topic;
if (typeof(msg.payload) == 'object') {
msg.payload = JSON.stringify(msg.payload);
}
if (typeof(titl) != 'undefined') {
growl(msg.payload, { title: titl, image: imagefile });
}
else {
growl(msg.payload, { image: imagefile });
}
});
}
RED.nodes.registerType("notify",NotifyNode);
}