From dd293da6fbc61357ac81785bb035c7f58b1909de Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Tue, 1 Oct 2013 12:42:31 +0100 Subject: [PATCH] Fix some scope issues in delay node and add rate limiting node --- nodes/core/89-delay.js | 15 +++++----- nodes/core/{89-pause.html => 89-rate.html} | 18 ++++++------ nodes/core/{89-pause.js => 89-rate.js} | 34 ++++++++++++---------- 3 files changed, 35 insertions(+), 32 deletions(-) rename nodes/core/{89-pause.html => 89-rate.html} (82%) rename nodes/core/{89-pause.js => 89-rate.js} (65%) diff --git a/nodes/core/89-delay.js b/nodes/core/89-delay.js index 3a534c6c0..1a3bfbd43 100644 --- a/nodes/core/89-delay.js +++ b/nodes/core/89-delay.js @@ -18,31 +18,32 @@ // Require main module var RED = require("../../red/red"); -var idList = []; // main node definition function DelayNode(n) { RED.nodes.createNode(this,n); this.timeout = n.timeout * 1000; - this.name = n.name + this.name = n.name; + this.idList = []; this.on("input", function(msg) { var node= this; var id; id = setTimeout(function(){ - idList.splice(idList.indexOf(id),1); + node.idList.splice(node.idList.indexOf(id),1); node.send(msg); }, node.timeout); - idList.push(id); + this.idList.push(id); }); } // register node -RED.nodes.registerType("pause",DelayNode); +RED.nodes.registerType("delay",DelayNode); DelayNode.prototype.close = function() { - for (var i=0; i - -