Improve inject node payload options

This commit is contained in:
Nick O'Leary
2014-02-02 15:37:34 +00:00
parent d52cd1ce00
commit c47c72cf48
2 changed files with 39 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ function InjectNode(n) {
RED.nodes.createNode(this,n);
this.topic = n.topic;
this.payload = n.payload;
this.payloadType = n.payloadType;
this.repeat = n.repeat;
this.crontab = n.crontab;
this.once = n.once;
@@ -56,8 +57,16 @@ function InjectNode(n) {
}
this.on("input",function(msg) {
var msg = {topic:this.topic,payload:this.payload};
if (msg.payload == "") { msg.payload = Date.now(); }
var msg = {topic:this.topic};
console.log(this.payloadType);
console.log(this.payload);
if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") {
msg.payload = Date.now();
} else if (this.payloadType == null || this.payloadType == "string") {
msg.payload = this.payload;
} else {
msg.payload = "";
}
this.send(msg);
msg = null;
});