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

27 lines
784 B
JavaScript
Raw Normal View History

2013-10-30 21:38:23 +01:00
module.exports = function(RED) {
"use strict";
var growl = require('growl');
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
2013-10-30 21:38:23 +01:00
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 });
}
});
}
2013-10-30 21:38:23 +01:00
RED.nodes.registerType("notify",NotifyNode);
}