diff --git a/nodes/core/core/89-trigger.html b/nodes/core/core/89-trigger.html index d74eb60ab..13964abb9 100644 --- a/nodes/core/core/89-trigger.html +++ b/nodes/core/core/89-trigger.html @@ -19,6 +19,7 @@ @@ -44,13 +45,17 @@
- + +
+
+

@@ -88,7 +93,8 @@ op2type: {value:"val"}, duration: {value:"250",required:true,validate:RED.validators.number()}, extend: {value:"false"}, - units: {value: "ms"}, + units: {value:"ms"}, + reset: {value:""}, name: {value:""} }, inputs:1, @@ -116,14 +122,14 @@ } }); $("#node-input-op1type").change(function() { - if ($(this).val() == "val") { + if (($(this).val() == "val")||($(this).val() == "num")) { $("#node-input-op1").show(); } else { $("#node-input-op1").hide(); } }); $("#node-input-op2type").change(function() { - if ($(this).val() == "val") { + if (($(this).val() == "val")||($(this).val() == "num")) { $("#node-input-op2").show(); } else { $("#node-input-op2").hide(); diff --git a/nodes/core/core/89-trigger.js b/nodes/core/core/89-trigger.js index 1299c6bc7..9e813f373 100644 --- a/nodes/core/core/89-trigger.js +++ b/nodes/core/core/89-trigger.js @@ -25,6 +25,7 @@ module.exports = function(RED) { this.op2type = n.op2type || "val"; this.extend = n.extend || "false"; this.units = n.units || "ms"; + this.reset = n.reset || ''; this.duration = n.duration || 250; if (this.duration <= 0) { this.duration = 0; } else { @@ -34,24 +35,24 @@ module.exports = function(RED) { } this.op1Templated = this.op1.indexOf("{{") != -1; this.op2Templated = this.op2.indexOf("{{") != -1; - if (!isNaN(this.op1)) { this.op1 = Number(this.op1); } - if (!isNaN(this.op2)) { this.op2 = Number(this.op2); } + if ((this.op1type === "num") && (!isNaN(this.op1))) { this.op1 = Number(this.op1); } + if ((this.op2type === "num") && (!isNaN(this.op2))) { this.op2 = Number(this.op2); } if (this.op1 == "true") { this.op1 = true; } if (this.op2 == "true") { this.op2 = true; } if (this.op1 == "false") { this.op1 = false; } if (this.op2 == "false") { this.op2 = false; } if (this.op1 == "null") { this.op1 = null; } if (this.op2 == "null") { this.op2 = null; } - try { this.op1 = JSON.parse(this.op1); } - catch(e) { this.op1 = this.op1; } - try { this.op2 = JSON.parse(this.op2); } - catch(e) { this.op2 = this.op2; } + //try { this.op1 = JSON.parse(this.op1); } + //catch(e) { this.op1 = this.op1; } + //try { this.op2 = JSON.parse(this.op2); } + //catch(e) { this.op2 = this.op2; } var node = this; var tout = null; var m2; this.on("input", function(msg) { - if (msg.hasOwnProperty("reset")) { + if (msg.hasOwnProperty("reset") || ((node.reset !== '')&&(msg.payload == node.reset)) ) { clearTimeout(tout); tout = null; node.status({}); diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index 1dae5d2e5..523ec6023 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -177,8 +177,9 @@ "then": "then", "then-send": "then send", "output": { - "string": "the string payload", - "existing": "the existing message", + "string": "the string", + "number": "the number", + "existing": "the existing msg.payload", "nothing": "nothing" }, "wait-reset": "wait to be reset", @@ -189,11 +190,13 @@ "m": "Minutes", "h": "Hours" }, - "extend": "extend delay if new message arrives", - "tip": "The node can be reset by sending a message with the msg.reset property set", + "extend": " extend delay if new message arrives", + "tip": "The node can also be reset by sending a message with the msg.reset property set to any value.", "label": { "trigger": "trigger", - "trigger-block": "trigger & block" + "trigger-block": "trigger & block", + "reset": "and reset if msg.payload == ", + "resetprompt": "(optional reset value)" } }, "comment": {