|
| 1 | +<!-- |
| 2 | + Copyright 2013 IBM Corp. |
| 3 | + |
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | + |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + |
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +--> |
| 16 | + |
| 17 | +<!-- Sample html file that corresponds to the 99-sample.js file --> |
| 18 | +<!-- This creates and configures the onscreen elements of the node --> |
| 19 | + |
| 20 | +<!-- If you use this as a template, replace IBM Corp. with your own name. --> |
| 21 | + |
| 22 | +<!-- First, the content of the edit dialog is defined. --> |
| 23 | + |
| 24 | +<script type="text/x-red" data-template-name="sample"> |
| 25 | + <!-- data-template-name identifies the node type this is for --> |
| 26 | + |
| 27 | + <!-- Each of the following divs creates a field in the edit dialog. --> |
| 28 | + <!-- Generally, there should be an input for each property of the node. --> |
| 29 | + <!-- The for and id attributes identify the corresponding property --> |
| 30 | + <!-- (with the 'node-input-' prefix). --> |
| 31 | + <!-- The available icon classes are defined in Twitter Bootstrap --> |
| 32 | + <div class="form-row"> |
| 33 | + <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label> |
| 34 | + <input type="text" id="node-input-topic" placeholder="Topic"> |
| 35 | + </div> |
| 36 | + |
| 37 | + <!-- By convention, most nodes have a 'name' property. The following div --> |
| 38 | + <!-- provides the necessary field. --> |
| 39 | + <div class="form-row"> |
| 40 | + <label for="node-input-name"><i class="icon-tag"></i> Name</label> |
| 41 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 42 | + </div> |
| 43 | +</script> |
| 44 | + |
| 45 | + |
| 46 | +<!-- Next, some simple help text is provided for the node. --> |
| 47 | +<script type="text/x-red" data-help-name="sample"> |
| 48 | + <!-- data-help-name identifies the node type this help is for --> |
| 49 | + <!-- This content appears in the Info sidebar when a node is selected --> |
| 50 | + <!-- The first <p> is used as the pop-up tool tip when hovering over a --> |
| 51 | + <!-- node in the palette. --> |
| 52 | + <p>Simple sample input node. Just sends a single message when it starts up. |
| 53 | + This is not very useful.</p> |
| 54 | + <p>Outputs an object called <b>msg</b> containing <b>msg.topic</b> and |
| 55 | + <b>msg.payload</b>. msg.payload is a String.</p> |
| 56 | +</script> |
| 57 | + |
| 58 | +<!-- Finally, the node type is registered along with all of its properties --> |
| 59 | +<!-- The example below shows a small subset of the properties that can be set--> |
| 60 | +<script type="text/javascript"> |
| 61 | + RED.nodes.registerType('sample',{ |
| 62 | + category: 'input', // the palette category |
| 63 | + defaults: { // defines the editable properties of the node |
| 64 | + name: {value:""}, // along with default values. |
| 65 | + topic: {value:"", required:true} |
| 66 | + }, |
| 67 | + inputs:0, // set the number of inputs - only 0 or 1 |
| 68 | + outputs:1, // set the number of outputs - 0 to n |
| 69 | + icon: "arrow-in.png", // set the icon (held in public/icons) |
| 70 | + label: function() { // sets the default label contents |
| 71 | + return this.name||this.topic||"sample"; |
| 72 | + }, |
| 73 | + labelStyle: function() { // sets the class to apply to the label |
| 74 | + return this.name?"node_label_italic":""; |
| 75 | + } |
| 76 | + }); |
| 77 | +</script> |
0 commit comments