1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Remove : from inject node label - people didn't like it.

Claim they can tell the difference between topic and payload as they wrote
the flow...
This commit is contained in:
Dave C-J 2014-12-15 17:03:18 +00:00
parent 41552625e0
commit 1261bf97ea
2 changed files with 12 additions and 12 deletions

View File

@ -138,15 +138,15 @@
icon: "inject.png", icon: "inject.png",
label: function() { label: function() {
if (this.payloadType === "string") { if (this.payloadType === "string") {
if ((this.topic.length + this.payload.length) <= 32) { if ((this.topic !== "") && ((this.topic.length + this.payload.length) <= 32)) {
return this.name||this.topic + ":" + this.payload; return this.name||this.topic + ":" + this.payload;
} }
else if (this.payload.length < 24) { else if (this.payload.length < 24) {
return this.name||":"+this.payload; return this.name||this.payload;
} }
} }
if ((this.topic.length < 24) && (this.topic.length > 0)) { if ((this.topic.length < 24) && (this.topic.length > 0)) {
return this.name||this.topic+":"; return this.name||this.topic;
} }
else { return this.name||(this.payloadType==="date"?"timestamp":null)||"inject"; } else { return this.name||(this.payloadType==="date"?"timestamp":null)||"inject"; }
}, },
@ -334,7 +334,7 @@
$("#node-input-payloadType").change(function() { $("#node-input-payloadType").change(function() {
var id = $("#node-input-payloadType option:selected").val(); var id = $("#node-input-payloadType option:selected").val();
if (id == "string") { if (id === "string") {
$("#node-input-row-payload").show(); $("#node-input-row-payload").show();
} else { } else {
$("#node-input-row-payload").hide(); $("#node-input-row-payload").hide();

View File

@ -16,7 +16,7 @@
module.exports = function(RED) { module.exports = function(RED) {
var cron = require("cron"); var cron = require("cron");
function InjectNode(n) { function InjectNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.topic = n.topic; this.topic = n.topic;
@ -28,7 +28,7 @@ module.exports = function(RED) {
var node = this; var node = this;
this.interval_id = null; this.interval_id = null;
this.cronjob = null; this.cronjob = null;
if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) { if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) {
this.repeat = this.repeat * 1000; this.repeat = this.repeat * 1000;
this.log("repeat = "+this.repeat); this.log("repeat = "+this.repeat);
@ -47,16 +47,16 @@ module.exports = function(RED) {
this.error("'cron' module not found"); this.error("'cron' module not found");
} }
} }
if (this.once) { if (this.once) {
setTimeout( function(){ node.emit("input",{}); }, 100); setTimeout( function(){ node.emit("input",{}); }, 100);
} }
this.on("input",function(msg) { this.on("input",function(msg) {
var msg = {topic:this.topic}; var msg = {topic:this.topic};
if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") { if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") {
msg.payload = Date.now(); msg.payload = Date.now();
} else if (this.payloadType == null || this.payloadType == "string") { } else if (this.payloadType == null || this.payloadType === "string") {
msg.payload = this.payload; msg.payload = this.payload;
} else { } else {
msg.payload = ""; msg.payload = "";
@ -65,9 +65,9 @@ module.exports = function(RED) {
msg = null; msg = null;
}); });
} }
RED.nodes.registerType("inject",InjectNode); RED.nodes.registerType("inject",InjectNode);
InjectNode.prototype.close = function() { InjectNode.prototype.close = function() {
if (this.interval_id != null) { if (this.interval_id != null) {
clearInterval(this.interval_id); clearInterval(this.interval_id);
@ -78,7 +78,7 @@ module.exports = function(RED) {
delete this.cronjob; delete this.cronjob;
} }
} }
RED.httpAdmin.post("/inject/:id", function(req,res) { RED.httpAdmin.post("/inject/:id", function(req,res) {
var node = RED.nodes.getNode(req.params.id); var node = RED.nodes.getNode(req.params.id);
if (node != null) { if (node != null) {