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

Fix serial config node edit layout

This commit is contained in:
Nick O'Leary 2014-11-13 20:53:15 +00:00
parent 3cb423a0b4
commit a477c0b827

View File

@ -153,34 +153,61 @@
</tr></table><br/> </tr></table><br/>
<div class="form-row"> <div class="form-row">
<label for="node-config-input-out"><i class="fa fa-cut"></i> Split input</label> <label><i class="fa fa-sign-in"></i> Input</label>
<select type="text" id="node-config-input-out" style="width:52%;"> </div>
<option value="char">when character received is</option> <div class="form-row" style="padding-left: 10px;">
<option value="time">after a fixed timeout of</option> Split input
<option value="count">a fixed number of characters</option> <select type="text" id="node-config-input-out" style="margin-left: 5px; width:200px;">
<option value="char">on the character</option>
<option value="time">after a timeout of</option>
<option value="count">into fixed lengths of</option>
</select> </select>
<input type="text" id="node-config-input-newline" style="width:50px;"> <input type="text" id="node-config-input-newline" style="width:50px;">
<span id="node-units"></span> <span id="node-units"></span>
</div> </div>
<div class="form-row" style="padding-left: 10px;">
<div class="form-row"> and deliver
<label for="node-config-input-bin"><i class="fa fa-sign-in"></i> and deliver</label> <select type="text" id="node-config-input-bin" style="margin-left: 5px; width: 150px;">
<select type="text" id="node-config-input-bin" style="width: 77%;">
<option value="false">ascii strings</option> <option value="false">ascii strings</option>
<option value="bin">binary buffers</option> <option value="bin">binary buffers</option>
</select> </select>
</div> </div>
<br/> <br/>
<div class="form-row" id="node-config-addchar"> <div id="node-config-addchar">
<label for="node-config-input-addchar"><i class="fa fa-sign-out"></i> On output</label> <div class="form-row">
<select type="text" id="node-config-input-addchar" style="width: 77%;"> <label><i class="fa fa-sign-out"></i> Output</label>
<option value="false">don't add 'split' character to output messages</option> </div>
<option value="true">add 'split' character to output messages</option> <div class="form-row">
</select> <input style="width: 30px;margin-left: 10px; vertical-align: top;" type="checkbox" id="node-config-input-addchar"><label style="width: auto;" for="node-config-input-addchar">add split character to output messages</label>
</div>
</div> </div>
<div class="form-tips" id="tip-split">Tip: the "Split on" character is used to split the input into separate messages. It can also be added to every message sent out to the serial port.</div> <div class="form-tips" id="tip-split">Tip: the "Split on" character is used to split the input into separate messages. It can also be added to every message sent out to the serial port.</div>
<div class="form-tips" id="tip-bin" hidden>Tip: In timeout mode timeout starts from arrival of first character.</div> <div class="form-tips" id="tip-bin" hidden>Tip: In timeout mode timeout starts from arrival of first character.</div>
<script> </script>
<script type="text/javascript">
RED.nodes.registerType('serial-port',{
category: 'config',
defaults: {
//name: {value:""},
serialport: {value:"",required:true},
serialbaud: {value:57600,required:true},
databits: {value:8,required:true},
parity: {value:"none",required:true},
stopbits: {value:1,required:true},
newline: {value:"\\n"},
bin: {value:"false"},
out: {value:"char"},
addchar: {value:false}
},
label: function() {
this.serialbaud = this.serialbaud || 57600;
this.databits = this.databits || 8;
this.parity = this.parity || 'none';
this.stopbits = this.stopbits || 1;
return this.serialport+":"+this.serialbaud+"-"+this.databits+this.parity.charAt(0).toUpperCase()+this.stopbits;
},
oneditprepare: function() {
var previous = null; var previous = null;
$("#node-config-input-out").on('focus', function () { previous = this.value; }).change(function() { $("#node-config-input-out").on('focus', function () { previous = this.value; }).change(function() {
if (previous == null) { previous = $("#node-config-input-out").val(); } if (previous == null) { previous = $("#node-config-input-out").val(); }
@ -200,7 +227,7 @@
$("#tip-bin").show(); $("#tip-bin").show();
} }
else { else {
if (previous != "count") { $("#node-config-input-newline").val("12"); } if (previous != "count") { $("#node-config-input-newline").val(""); }
$("#node-units").text("chars"); $("#node-units").text("chars");
$("#node-config-addchar").hide(); $("#node-config-addchar").hide();
$("#node-config-input-addchar").val("false"); $("#node-config-input-addchar").val("false");
@ -209,32 +236,6 @@
} }
}); });
</script>
</script>
<script type="text/javascript">
RED.nodes.registerType('serial-port',{
category: 'config',
defaults: {
//name: {value:""},
serialport: {value:"",required:true},
serialbaud: {value:57600,required:true},
databits: {value:8,required:true},
parity: {value:"none",required:true},
stopbits: {value:1,required:true},
newline: {value:"\\n"},
bin: {value:""},
out: {value:""},
addchar: {value:false}
},
label: function() {
this.serialbaud = this.serialbaud || 57600;
this.databits = this.databits || 8;
this.parity = this.parity || 'none';
this.stopbits = this.stopbits || 1;
return this.serialport+":"+this.serialbaud+"-"+this.databits+this.parity.charAt(0).toUpperCase()+this.stopbits;
},
oneditprepare: function() {
try { try {
$("#node-config-input-serialport").autocomplete( "destroy" ); $("#node-config-input-serialport").autocomplete( "destroy" );
} catch(err) { } catch(err) {