diff --git a/editor/icons/bridge-dash.png b/editor/icons/bridge-dash.png index beaf8e65e..3914cb7a5 100644 Binary files a/editor/icons/bridge-dash.png and b/editor/icons/bridge-dash.png differ diff --git a/editor/icons/link-out.png b/editor/icons/link-out.png new file mode 100644 index 000000000..f39ba0453 Binary files /dev/null and b/editor/icons/link-out.png differ 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, }