diff --git a/nodes/core/core/89-delay.js b/nodes/core/core/89-delay.js index 2132dccc0..3f0603603 100644 --- a/nodes/core/core/89-delay.js +++ b/nodes/core/core/89-delay.js @@ -78,30 +78,30 @@ module.exports = function(RED) { this.drop = n.drop; var node = this; - if (this.pauseType === "delay") { - this.on("input", function(msg) { + if (node.pauseType === "delay") { + node.on("input", function(msg) { var id; id = setTimeout(function() { node.idList.splice(node.idList.indexOf(id),1); if (node.idList.length === 0) { node.status({}); } node.send(msg); }, node.timeout); - this.idList.push(id); + node.idList.push(id); if ((node.timeout > 1000) && (node.idList.length !== 0)) { node.status({fill:"blue",shape:"dot",text:" "}); } }); - this.on("close", function() { - for (var i=0; i 1000) { - node.warn(this.name + " " + RED._("delay.error.buffer")); + node.warn(node.name + " " + RED._("delay.error.buffer")); } } else { node.send(msg); @@ -141,15 +141,15 @@ module.exports = function(RED) { } }); - this.on("close", function() { - clearInterval(this.intervalID); - this.buffer = []; + node.on("close", function() { + clearInterval(node.intervalID); + node.buffer = []; node.status({}); }); - } else if ((this.pauseType === "queue") || (this.pauseType === "timed")) { - this.intervalID = setInterval(function() { - if (this.pauseType === "queue") { + } else if ((node.pauseType === "queue") || (node.pauseType === "timed")) { + node.intervalID = setInterval(function() { + if (node.pauseType === "queue") { if (node.buffer.length > 0) { node.send(node.buffer.shift()); // send the first on the queue } @@ -162,7 +162,7 @@ module.exports = function(RED) { node.status({text:node.buffer.length}); },node.rate); - this.on("input", function(msg) { + node.on("input", function(msg) { if (!msg.hasOwnProperty("topic")) { msg.topic = "_none_"; } var hit = false; for (var b in node.buffer) { // check if already in queue @@ -175,27 +175,27 @@ module.exports = function(RED) { node.status({text:node.buffer.length}); }); - this.on("close", function() { - clearInterval(this.intervalID); - this.buffer = []; + node.on("close", function() { + clearInterval(node.intervalID); + node.buffer = []; node.status({}); }); - } else if (this.pauseType === "random") { - this.on("input", function(msg) { + } else if (node.pauseType === "random") { + node.on("input", function(msg) { var wait = node.randomFirst + (node.diff * Math.random()); var id = setTimeout(function() { node.idList.splice(node.idList.indexOf(id),1); node.send(msg); }, wait); - this.idList.push(id); + node.idList.push(id); }); - this.on("close", function() { - for (var i=0; i