fix odl patches
[ccsdk/distribution.git] / dgbuilder / core_nodes / logic / 16-range.html
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 <script type="text/x-red" data-template-name="range">
18     <div class="form-row">
19         <label for="node-input-action"><i class="fa fa-dot-circle-o"></i> Action</label>
20         <select id="node-input-action" style="width:70%; margin-right:5px;">
21             <option value="scale">Scale msg.payload</option>
22             <option value="clamp">Scale and limit to the target range</option>
23             <option value="roll">Scale and wrap within the target range</option>
24         </select>
25     </div>
26     <br/>
27     <div class="form-row"><i class="fa fa-sign-in"></i> Map the input range:</div>
28     <div class="form-row"><label></label>
29         from: <input type="text" id="node-input-minin" placeholder="e.g. 0" style="width:100px;"/>
30         &nbsp;&nbsp;to: <input type="text" id="node-input-maxin" placeholder="e.g. 99" style="width:100px;"/>
31     </div>
32     <div class="form-row"><i class="fa fa-sign-out"></i> to the result range:</div>
33     <div class="form-row"><label></label>
34         from: <input type="text" id="node-input-minout" placeholder="e.g. 0" style="width:100px;"/>
35         &nbsp;&nbsp;to: <input type="text" id="node-input-maxout" placeholder="e.g. 255" style="width:100px;"/>
36     </div>
37     <br/>
38     <div class="form-row"><label></label>
39         <input type="checkbox" id="node-input-round" style="display: inline-block; width: auto; vertical-align: top;">
40         <label style="width: auto;" for="node-input-round">Round result to the nearest integer?</label></input>
41     </div>
42     <br/>
43     <div class="form-row">
44         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
45         <input type="text" id="node-input-name" placeholder="Name">
46     </div>
47     <div class="form-tips" id="node-tip">Tip: This node ONLY works with numbers.</div>
48 </script>
49
50 <script type="text/x-red" data-help-name="range">
51     <p>A simple function node to remap numeric input values to another scale.</p>
52     <p>Currently only does a linear scaling.</p>
53     <p><b>Note:</b> This only operates on <b>numbers</b>. Anything else will try to be made into a number and rejected if that fails.</p>
54     <p><i>Scale and limit to target range</i> means that the result will never be outside the range specified within the result range.</p>
55     <p><i>Scale and wrap within the target range</i> means that the result will essentially be a "modulo-style" wrap-around within the result range.</p>
56 </script>
57
58 <script type="text/javascript">
59     RED.nodes.registerType('range', {
60         color: "#E2D96E",
61         category: 'function',
62         defaults: {
63             minin: {value:"",required:true,validate:RED.validators.number()},
64             maxin: {value:"",required:true,validate:RED.validators.number()},
65             minout: {value:"",required:true,validate:RED.validators.number()},
66             maxout: {value:"",required:true,validate:RED.validators.number()},
67             action: {value:"scale"},
68             round: {value:false},
69             name: {value:""}
70         },
71         inputs: 1,
72         outputs: 1,
73         icon: "range.png",
74         label: function() {
75             return this.name || "range";
76         },
77         labelStyle: function() {
78             return this.name ? "node_label_italic" : "";
79         }
80     });
81 </script>