Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 1 | <!-- |
| 2 | Copyright 2014 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, update the copyright 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 Twitter Bootstrap glyphicons --> |
| 32 | <div class="form-row"> |
| 33 | <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label> |
| 34 | <input type="text" id="node-input-topic" placeholder="Topic"> |
| 35 | </div> |
| 36 | |
| 37 | <br/> |
| 38 | <!-- By convention, most nodes have a 'name' property. The following div --> |
| 39 | <!-- provides the necessary field. Should always be the last option --> |
| 40 | <div class="form-row"> |
| 41 | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
| 42 | <input type="text" id="node-input-name" placeholder="Name"> |
| 43 | </div> |
| 44 | </script> |
| 45 | |
| 46 | |
| 47 | <!-- Next, some simple help text is provided for the node. --> |
| 48 | <script type="text/x-red" data-help-name="sample"> |
| 49 | <!-- data-help-name identifies the node type this help is for --> |
| 50 | <!-- This content appears in the Info sidebar when a node is selected --> |
| 51 | <!-- The first <p> is used as the pop-up tool tip when hovering over a --> |
| 52 | <!-- node in the palette. --> |
| 53 | <p>Simple sample input node. Just sends a single message when it starts up. |
| 54 | This is not very useful.</p> |
| 55 | <p>Outputs an object called <b>msg</b> containing <b>msg.topic</b> and |
| 56 | <b>msg.payload</b>. msg.payload is a String.</p> |
| 57 | </script> |
| 58 | |
| 59 | <!-- Finally, the node type is registered along with all of its properties --> |
| 60 | <!-- The example below shows a small subset of the properties that can be set--> |
| 61 | <script type="text/javascript"> |
| 62 | RED.nodes.registerType('sample',{ |
| 63 | category: 'input', // the palette category |
| 64 | defaults: { // defines the editable properties of the node |
| 65 | name: {value:""}, // along with default values. |
| 66 | topic: {value:"", required:true} |
| 67 | }, |
| 68 | inputs:1, // set the number of inputs - only 0 or 1 |
| 69 | outputs:1, // set the number of outputs - 0 to n |
| 70 | // set the icon (held in icons dir below where you save the node) |
| 71 | icon: "myicon.png", // saved in icons/myicon.png |
| 72 | label: function() { // sets the default label contents |
| 73 | return this.name||this.topic||"sample"; |
| 74 | }, |
| 75 | labelStyle: function() { // sets the class to apply to the label |
| 76 | return this.name?"node_label_italic":""; |
| 77 | } |
| 78 | }); |
| 79 | </script> |