mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
fixed tabs
This commit is contained in:
parent
d7d305ff60
commit
292a54e045
@ -19,39 +19,41 @@ var util = require("util");
|
|||||||
var events = require("events");
|
var events = require("events");
|
||||||
|
|
||||||
function LibnotifyNode(n) {
|
function LibnotifyNode(n) {
|
||||||
RED.nodes.createNode(this, n);
|
RED.nodes.createNode(this, n);
|
||||||
this.name = n.name;
|
this.name = n.name;
|
||||||
this.title = n.title;
|
this.title = n.title;
|
||||||
this.active = (n.active == null)||n.active;
|
this.active = (n.active == null)||n.active;
|
||||||
this.maxlength = parseInt(n.maxlength) || 200;
|
this.maxlength = parseInt(n.maxlength) || 200;
|
||||||
|
|
||||||
this.on("input",function(msg) {
|
this.on("input",function(msg) {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
if (msg.payload instanceof Buffer) {
|
if (msg.payload instanceof Buffer) {
|
||||||
msg.payload = "(Buffer) "+msg.payload.toString();
|
msg.payload = "(Buffer) "+msg.payload.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof msg.payload !== "undefined") {
|
if (typeof msg.payload !== "undefined") {
|
||||||
LibnotifyNode.send(this, msg.payload);
|
LibnotifyNode.send(this, msg.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("libnotify",LibnotifyNode);
|
RED.nodes.registerType("libnotify",LibnotifyNode);
|
||||||
|
|
||||||
LibnotifyNode.send = function(self, msg) {
|
LibnotifyNode.send = function(self, msg) {
|
||||||
var title = self.title;
|
var title = self.title;
|
||||||
if (msg instanceof Error) {
|
|
||||||
title += " [ERROR]: ";
|
|
||||||
} else if (typeof msg === 'object') {
|
|
||||||
title += " [OBJECT]: ";
|
|
||||||
}
|
|
||||||
msg = msg.toString();
|
|
||||||
|
|
||||||
if (msg.length > self.maxlength) {
|
if (msg instanceof Error) {
|
||||||
msg = msg.substr(0,self.maxlength) +"...";
|
title += " [ERROR]: ";
|
||||||
}
|
} else if (typeof msg === 'object') {
|
||||||
|
title += " [OBJECT]: ";
|
||||||
ln.notify(msg, { title: title });
|
}
|
||||||
|
|
||||||
|
msg = msg.toString();
|
||||||
|
|
||||||
|
if (msg.length > self.maxlength) {
|
||||||
|
msg = msg.substr(0,self.maxlength) +"...";
|
||||||
|
}
|
||||||
|
|
||||||
|
ln.notify(msg, { title: title });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user