1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Add polyfill junction node

This commit is contained in:
Dave Conway-Jones 2022-03-01 11:40:56 +00:00
parent bc73218905
commit 14cff61d49
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
5 changed files with 114 additions and 0 deletions

14
utility/junction/LICENSE Normal file
View File

@ -0,0 +1,14 @@
Copyright 2016-2022 JS Foundation and other contributors, https://js.foundation/
Copyright 2013-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.

View File

@ -0,0 +1,22 @@
node-red-node-junction
======================
A Node-RED node to allow flows containing junctions to be imported into older versions
of Node-RED.
The ability to create junctions was introduced in Node-RED 3.0.0, adding a new core
node type called `junction`.
This module provides its own `junction` node type that can be installed into older
versions of Node-RED to allow them to run flows containing that type.
The module will only register the type if it detects it is being loaded into
Node-RED version 2 or older, otherwise it does nothing.
Install
-------
Run the following command in your Node-RED user directory - typically `~/.node-red`
npm i node-red-node-junction

View File

@ -0,0 +1,36 @@
<script type="text/html" data-template-name="junction">
<div class="form-row">
<div class="form-tips">
<p>The current flow was created in a newer version of Node-RED and contains
<code>junctions</code>.</p>
<p>This version of Node-RED does not support <code>junctions</code> and
they have been replaced by this placeholder node by the
<code>node-red-node-junction</code> module.</p>
<p>To use <code>junctions</code>, upgrade to Node-RED 3.0.0 or later.</p>
</div>
</div>
</script>
<script type="text/html" data-help-name="junction">
<p>A placeholder node for the junction feature added in Node-RED 3.0.0.</p>
<p>This version of Node-RED does not support <code>junctions</code> and
they have been replaced by this placeholder node by the
<code>node-red-node-junction</code> module.</p>
<p>To use <code>junctions</code>, upgrade to Node-RED 3.0.0 or later.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('junction',{
category: 'common',
inputs: 1,
outputs: 1,
icon: 'font-awesome/fa-circle-o',
defaults: {
l: {value: false}
},
label: function() {
return "junction";
},
labelStyle: "node_label_italic"
});
</script>

View File

@ -0,0 +1,20 @@
module.exports = function(RED) {
var version = RED.version();
var parts = /^(\d)+\.(\d)+\.(\d)+/.exec(version);
if (parts) {
var major = parseInt(parts[1]);
if (major > 2) {
throw new Error("This module is not required for Node-RED 3 or later")
}
}
function JunctionNode(n) {
RED.nodes.createNode(this,n);
this.on("input",function(msg, send, done) {
send(msg);
done();
});
}
console.log("HERE!!!!!!",major)
RED.nodes.registerType("junction",JunctionNode);
}

View File

@ -0,0 +1,22 @@
{
"name": "node-red-node-junction",
"version": "1.0.0",
"description": "A Node-RED node to allow flows containing junctions to be imported into Node-RED 2 or earlier.",
"dependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/node-red/node-red-nodes.git",
"directory": "tree/master/utility/junction"
},
"license": "Apache-2.0",
"keywords": [
"node-red"
],
"node-red": {
"version": "<3.0.0",
"nodes": {
"junction": "junction.js"
}
},
"author": "Dave Conway-Jones <dceejay@gmail.com>"
}