inject node - Remove couple of lines of excess console.log

This commit is contained in:
Dave C-J 2014-02-03 19:06:49 +00:00
parent 45cb1016cc
commit bdd9d901ec
1 changed files with 43 additions and 45 deletions

View File

@ -22,54 +22,52 @@ try {
} }
function InjectNode(n) { function InjectNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.topic = n.topic; this.topic = n.topic;
this.payload = n.payload; this.payload = n.payload;
this.payloadType = n.payloadType; this.payloadType = n.payloadType;
this.repeat = n.repeat; this.repeat = n.repeat;
this.crontab = n.crontab; this.crontab = n.crontab;
this.once = n.once; this.once = n.once;
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);
this.interval_id = setInterval( function() { this.interval_id = setInterval( function() {
node.emit("input",{}); node.emit("input",{});
}, this.repeat ); }, this.repeat );
} else if (this.crontab) { } else if (this.crontab) {
if (cron) { if (cron) {
this.log("crontab = "+this.crontab); this.log("crontab = "+this.crontab);
this.cronjob = new cron.CronJob(this.crontab, this.cronjob = new cron.CronJob(this.crontab,
function() { function() {
node.emit("input",{}); node.emit("input",{});
}, },
null,true); null,true);
} else { } else {
this.error("'cron' module not found"); this.error("'cron' module not found");
} }
} }
if (this.once) { if (this.once) {
setTimeout( function(){ node.emit("input",{}); }, 50); setTimeout( function(){ node.emit("input",{}); }, 50);
} }
this.on("input",function(msg) { this.on("input",function(msg) {
var msg = {topic:this.topic}; var msg = {topic:this.topic};
console.log(this.payloadType); if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") {
console.log(this.payload); msg.payload = Date.now();
if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") { } else if (this.payloadType == null || this.payloadType == "string") {
msg.payload = Date.now(); msg.payload = this.payload;
} else if (this.payloadType == null || this.payloadType == "string") { } else {
msg.payload = this.payload; msg.payload = "";
} else { }
msg.payload = ""; this.send(msg);
} msg = null;
this.send(msg); });
msg = null;
});
} }
RED.nodes.registerType("inject",InjectNode); RED.nodes.registerType("inject",InjectNode);