From 59b34c2b3ff061787b829686600e12c6571375ca Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 18 Apr 2016 14:38:32 +0100 Subject: [PATCH] Add timestamp as a default typedInput and update Inject and change nodes to match, and add some tests. --- editor/js/ui/typedInput.js | 3 ++- nodes/core/core/20-inject.html | 2 +- nodes/core/core/20-inject.js | 2 +- nodes/core/core/80-function.js | 4 +-- nodes/core/logic/15-change.html | 36 ++++++++++++------------- nodes/core/logic/15-change.js | 2 ++ red/api/locales/en-US/editor.json | 3 ++- red/api/theme.js | 1 - red/runtime/util.js | 2 ++ test/nodes/core/logic/15-change_spec.js | 20 +++++++++++++- test/red/runtime/util_spec.js | 4 +++ 11 files changed, 53 insertions(+), 26 deletions(-) diff --git a/editor/js/ui/typedInput.js b/editor/js/ui/typedInput.js index 3be1c3de1..720cc80e0 100644 --- a/editor/js/ui/typedInput.js +++ b/editor/js/ui/typedInput.js @@ -22,7 +22,8 @@ num: {value:"num",label:"number",icon:"red/images/typedInput/09.png",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/}, bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.png",options:["true","false"]}, json: {value:"json",label:"JSON",icon:"red/images/typedInput/json.png", validate: function(v) { try{JSON.parse(v);return true;}catch(e){return false;}}}, - re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.png"} + re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.png"}, + date: {value:"date",label:"timestamp",hasValue:false} }; var nlsd = false; diff --git a/nodes/core/core/20-inject.html b/nodes/core/core/20-inject.html index 5fb5187e7..98ffd6d5c 100644 --- a/nodes/core/core/20-inject.html +++ b/nodes/core/core/20-inject.html @@ -242,7 +242,7 @@ $("#node-input-payload").typedInput({ default: 'str', typeField: $("#node-input-payloadType"), - types:['flow','global','str','num','bool','json',{value:"date",label:this._("inject.timestamp"),hasValue:false}] + types:['flow','global','str','num','bool','json','date'] }); $("#inject-time-type-select").change(function() { diff --git a/nodes/core/core/20-inject.js b/nodes/core/core/20-inject.js index 1e1744dbb..2b55203f4 100644 --- a/nodes/core/core/20-inject.js +++ b/nodes/core/core/20-inject.js @@ -46,7 +46,7 @@ module.exports = function(RED) { } if (this.once) { - setTimeout( function(){ node.emit("input",{}); }, 100); + setTimeout( function() { node.emit("input",{}); }, 100 ); } this.on("input",function(msg) { diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index 9ddcbdbe1..5eb96b1bf 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -206,10 +206,10 @@ module.exports = function(RED) { } }); this.on("close", function() { - while(node.outstandingTimers.length > 0) { + while (node.outstandingTimers.length > 0) { clearTimeout(node.outstandingTimers.pop()) } - while(node.outstandingIntervals.length > 0) { + while (node.outstandingIntervals.length > 0) { clearInterval(node.outstandingIntervals.pop()) } }) diff --git a/nodes/core/logic/15-change.html b/nodes/core/logic/15-change.html index 5b53e2027..07495fffa 100644 --- a/nodes/core/logic/15-change.html +++ b/nodes/core/logic/15-change.html @@ -17,14 +17,14 @@