From e1d09349ff29e8fab16818cc029c39c951b4e0a7 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 12 Feb 2016 23:18:08 +0000 Subject: [PATCH] Add link nodes --- editor/icons/bridge-dash.png | Bin 609 -> 508 bytes editor/icons/link-out.png | Bin 0 -> 402 bytes nodes/core/core/60-link.html | 74 +++++++++++++++++++++++++ nodes/core/core/60-link.js | 52 +++++++++++++++++ nodes/core/locales/en-US/messages.json | 7 +++ red/runtime/nodes/registry/loader.js | 3 +- 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 editor/icons/link-out.png create mode 100644 nodes/core/core/60-link.html create mode 100644 nodes/core/core/60-link.js diff --git a/editor/icons/bridge-dash.png b/editor/icons/bridge-dash.png index beaf8e65e34cf40e169589832c82115d9ecaded9..3914cb7a5ea3708dbea472cb48f7c47c0c83cbef 100644 GIT binary patch delta 408 zcmV;J0cZZ<1pEV#Zhv`6L_t(YiQSdID@9=#$GK3^YW%MI%%3!A~B&7^uvB{u} zW-%Es8w_G2gOWjHQ{oS}WwQEJVvy@&xZktf?vK-PCeQMmZ|8kJ=lj0Td)`<2Hvu%K z37ZF=fc{!z>tZtBC1oY;0dZ@p2XIU=X43-p0YAX?Um!EUNq;m=;KD9*Nr8t3%vsM` zuO$U`1K+@{bsKO6EF=ONa%xvYamJV30>B8cWx4M>?RVqucu!nM0l0HV`+-)V5Oo*W zu;bBK4nqh?+Lja~O@$C%B;_RyddRbLwj8jbg3){DZs!R}uW^8texoMmFXw`!toI`o zYN`UGj^>?rC4W8mLy@!R(xPg>MM>Y1&aC@XobqQaVA%lLfh9k8x~u2b!@x4o5gS+n zUo~*Wx;_!e#Tnoc_yAh`>%9Y;m1=4omg|zbB<+L{-Xx7l%BZ-Oi5%vD1EA45I=%)H z0ZZV$e?DMKfJdoa0l=hTH>q4wzyNTW%G&+E_yzj0MG>){e*3ln0000lSd$MMhjvrrR*6=O6@7E>q-i&@-2N)3xItGl0op>1$D>?$iB&M*uBY(im9LE5jMnp?!outgi zGhF&-U_|VSi1S6|7u>}CxhUL>+wdVXCnDmuM%YU-^LvGeU#m5< zKHS1tOyHo#UW$kT4C8X0kl$huBV{~*MMd2@97At2$131%JkQKmWjvyhD7c1YMfqP= z74jH1;9eQ;$8>q#0-1TIZD3}8{0WPQAw0~?cjfbGjdnfmtD{hXEyk$E$rvoJhq1EC zXSSpF2}3wh7FerMIuELRn$}?p#n&}1h2G4ZY&NH@#xujt;BFO+dR^}jrZe+Ot9k8q zy?$KqyB6mL%*@x=grl>~t(BB^?En3Wv}->AS8<$!9zm^w00000NkvXXu0mjfTD$X& diff --git a/editor/icons/link-out.png b/editor/icons/link-out.png new file mode 100644 index 0000000000000000000000000000000000000000..f39ba045300c13791083f87bc1e6bb0bc97e70be GIT binary patch literal 402 zcmV;D0d4+?P)H`P?A=dg1K7g+fyR>Nn3Vt>dSeKodUG{?DfrXjjo^Q?$^CSHW0sG#-2XEjPaN-FB zc=ZMXoO=V`f!$Q?pk|y%I!n}_O1hNv*fzEKTRUA1eSja5o}_-iTmU!W z8-=mh-duE!pMY(EgC9(P+thA?Qw$7%@B;P7~ weRT!8Ua&7NumJo7jy-|*Zm literal 0 HcmV?d00001 diff --git a/nodes/core/core/60-link.html b/nodes/core/core/60-link.html new file mode 100644 index 000000000..5f934fe6f --- /dev/null +++ b/nodes/core/core/60-link.html @@ -0,0 +1,74 @@ + + + + + + + + + + + diff --git a/nodes/core/core/60-link.js b/nodes/core/core/60-link.js new file mode 100644 index 000000000..b98d28570 --- /dev/null +++ b/nodes/core/core/60-link.js @@ -0,0 +1,52 @@ +/** + * Copyright 2016 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + + function LinkInNode(n) { + RED.nodes.createNode(this,n); + var node = this; + + if (n.event) { + var handler = function(msg) { + msg._event = n.event; + node.receive(msg); + } + RED.events.on("node:"+n.event,handler); + this.on("input", function(msg) { + this.send(msg); + }); + this.on("close",function() { + RED.events.removeListener("node:"+n.event,handler); + }) + } + } + + RED.nodes.registerType("link in",LinkInNode); + + function LinkOutNode(n) { + RED.nodes.createNode(this,n); + var node = this; + if (n.event) { + this.on("input", function(msg) { + msg._event = n.event; + RED.events.emit("node:"+n.event,msg) + }); + } + } + RED.nodes.registerType("link out",LinkOutNode); +} diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index 09c93bf9f..7e596fa4b 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -114,6 +114,13 @@ "name": "Debug messages" } }, + "link": { + "linkIn": "link in", + "linkOut": "link out", + "label": { + "event": "Event name" + } + }, "exec": { "spawnerr": "Spawn command must be just the command - no spaces or extra parameters", "badstdout": "Bad STDOUT", diff --git a/red/runtime/nodes/registry/loader.js b/red/runtime/nodes/registry/loader.js index c09716705..3e0648c09 100644 --- a/red/runtime/nodes/registry/loader.js +++ b/red/runtime/nodes/registry/loader.js @@ -1,5 +1,5 @@ /** - * Copyright 2015 IBM Corp. + * Copyright 2015, 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,7 @@ function createNodeApi(node) { nodes: {}, log: {}, settings: {}, + events: runtime.events, util: runtime.util, version: runtime.version, }