1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/nodes/99-sample.html.demo

80 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

2013-09-05 16:02:48 +02:00
<!--
2014-04-11 11:55:14 +02:00
Copyright 2014 IBM Corp.
2013-09-05 16:02:48 +02:00
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.
-->
<!-- Sample html file that corresponds to the 99-sample.js file -->
<!-- This creates and configures the onscreen elements of the node -->
2014-05-04 00:32:04 +02:00
<!-- If you use this as a template, update the copyright with your own name. -->
2013-09-05 16:02:48 +02:00
<!-- First, the content of the edit dialog is defined. -->
<script type="text/x-red" data-template-name="sample">
<!-- data-template-name identifies the node type this is for -->
<!-- Each of the following divs creates a field in the edit dialog. -->
<!-- Generally, there should be an input for each property of the node. -->
<!-- The for and id attributes identify the corresponding property -->
2013-09-05 16:02:48 +02:00
<!-- (with the 'node-input-' prefix). -->
2015-10-20 20:30:42 +02:00
<!-- The available icon classes are defined Font Awesome Icons (FA Icons) -->
2013-09-05 16:02:48 +02:00
<div class="form-row">
2014-09-03 16:11:10 +02:00
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
2013-09-05 16:02:48 +02:00
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
2014-04-11 11:55:14 +02:00
<br/>
2013-09-05 16:02:48 +02:00
<!-- By convention, most nodes have a 'name' property. The following div -->
2014-04-11 11:55:14 +02:00
<!-- provides the necessary field. Should always be the last option -->
2013-09-05 16:02:48 +02:00
<div class="form-row">
2014-09-03 16:11:10 +02:00
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
2013-09-05 16:02:48 +02:00
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="sample">
<!-- data-help-name identifies the node type this help is for -->
<!-- This content appears in the Info sidebar when a node is selected -->
<!-- The first <p> is used as the pop-up tool tip when hovering over a -->
<!-- node in the palette. -->
<p>Simple sample input node. Just sends a single message when it starts up.
This is not very useful.</p>
<p>Outputs an object called <code>msg</code> containing <code>msg.topic</code> and
<code>msg.payload</code>. msg.payload is a String.</p>
2013-09-05 16:02:48 +02:00
</script>
<!-- Finally, the node type is registered along with all of its properties -->
<!-- The example below shows a small subset of the properties that can be set-->
<script type="text/javascript">
RED.nodes.registerType('sample',{
category: 'input', // the palette category
defaults: { // defines the editable properties of the node
name: {value:""}, // along with default values.
topic: {value:"", required:true}
},
inputs:1, // set the number of inputs - only 0 or 1
2014-04-11 11:55:14 +02:00
outputs:1, // set the number of outputs - 0 to n
// set the icon (held in icons dir below where you save the node)
icon: "myicon.png", // saved in icons/myicon.png
label: function() { // sets the default label contents
2013-09-05 16:02:48 +02:00
return this.name||this.topic||"sample";
},
labelStyle: function() { // sets the class to apply to the label
return this.name?"node_label_italic":"";
}
});
</script>