|
19 | 19 |
|
20 | 20 | <!-- First, the content of the edit dialog is defined. -->
|
21 | 21 | <script type="text/x-red" data-template-name="humanizer">
|
22 |
| - <!-- data-template-name identifies the node type this is for --> |
| 22 | + <!-- data-template-name identifies the node type this is for --> |
23 | 23 |
|
24 |
| - <!-- INPUT --> |
25 |
| - <div class="form-row"> |
26 |
| - <label for="node-input-input"><i class="fa fa-arrow-left"></i> Input variable</label> |
27 |
| - <input type="text" id="node-input-input" style="width: 70%;" placeholder="varname in msg.payload or empty for all"> |
28 |
| - </div> |
29 |
| - <!-- NODE NAME - Should always be the last field --> |
30 |
| - <div class="form-row"> |
31 |
| - <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
32 |
| - <input type="text" id="node-input-name" placeholder="Name"> |
33 |
| - </div> |
| 24 | + <!-- INPUT --> |
| 25 | + <div class="form-row"> |
| 26 | + <label for="node-input-input"><i class="fa fa-arrow-left"></i> Input variable</label> |
| 27 | + <input type="text" id="node-input-input" style="width: 70%;" placeholder="varname in msg.payload or empty for all"> |
| 28 | + </div> |
| 29 | + <!-- NODE NAME - Should always be the last field --> |
| 30 | + <div class="form-row"> |
| 31 | + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
| 32 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 33 | + </div> |
34 | 34 |
|
35 |
| - <div class="form-tips" style="font-size:83%"> |
36 |
| - Specify which property on msg.payload to humanize or use msg.payload. <br /> |
37 |
| - The input is assumed to be in seconds since the event so +10 is 10 seconds ago. |
38 |
| - </div> |
| 35 | + <div class="form-tips" style="font-size:83%"> |
| 36 | + Specify which property on msg.payload to humanize or use msg.payload. <br /> |
| 37 | + The input must be in seconds since the event so +10 is 10 seconds ago.<br /> |
| 38 | + Only integer numbers are allowed. |
| 39 | + </div> |
39 | 40 | </script>
|
40 | 41 |
|
41 | 42 |
|
42 | 43 | <!-- Next, some simple help text is provided for the node. -->
|
43 | 44 | <!-- The first <p> is used as the pop-up tool tip when hovering over pallette -->
|
44 | 45 | <script type="text/x-red" data-help-name="humanizer">
|
45 |
| - <p> |
46 |
| - Humanize timespans in seconds. |
47 |
| - </p> |
48 |
| - <p> |
49 |
| - Uses the humanize functionality in the moment.js library. |
| 46 | + <p> |
| 47 | + Humanize timespans in seconds. |
| 48 | + </p> |
| 49 | + <p> |
| 50 | + Uses the humanize functionality in the moment.js library. |
| 51 | + </p> |
| 52 | + <p> |
| 53 | + Input must be in integer seconds. |
| 54 | + </p> |
| 55 | + <p> |
| 56 | + Contributed by <a href="https://github.com/Laro88">Laro88</a> |
| 57 | + </p> |
50 | 58 | </script>
|
51 | 59 |
|
52 | 60 | <!-- Finally, the node type is registered along with all of its properties -->
|
53 | 61 | <script type="text/javascript">
|
54 |
| - RED.nodes.registerType('humanizer',{ |
55 |
| - category: 'formats', // the palette category |
56 |
| - color: '#E6E0F8', |
57 |
| - defaults: { |
58 |
| - name: {value:''}, |
59 |
| - input: {value:''} |
60 |
| - |
61 |
| - }, |
62 |
| - inputs:1, // set the number of inputs - only 0 or 1 |
63 |
| - outputs:1, // set the number of outputs - 0 to n |
64 |
| - // set the icon (held in icons dir below where you save the node) |
65 |
| - icon: 'timer.png', // saved in icons/myicon.png |
66 |
| - label: function() { // sets the default label contents |
67 |
| - return this.name||'Humanizer'; |
68 |
| - }, |
69 |
| - labelStyle: function() { // sets the class to apply to the label |
70 |
| - return this.name?'node_label_italic':''; |
71 |
| - } |
72 |
| - }); // ---- end of RED.nodes.registerType ---- // |
| 62 | + RED.nodes.registerType('humanizer',{ |
| 63 | + category: 'formats', // the palette category |
| 64 | + color: '#E6E0F8', |
| 65 | + defaults: { |
| 66 | + name: {value:''}, |
| 67 | + input: {value:''} |
| 68 | + }, |
| 69 | + inputs:1, // set the number of inputs - only 0 or 1 |
| 70 | + outputs:1, // set the number of outputs - 0 to n |
| 71 | + // set the icon (held in icons dir below where you save the node) |
| 72 | + icon: 'timer.png', // saved in icons/myicon.png |
| 73 | + label: function() { // sets the default label contents |
| 74 | + return this.name||'Humanizer'; |
| 75 | + }, |
| 76 | + labelStyle: function() { // sets the class to apply to the label |
| 77 | + return this.name?'node_label_italic':''; |
| 78 | + } |
| 79 | + }); // ---- end of RED.nodes.registerType ---- // |
73 | 80 | </script>
|
0 commit comments