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

Tweak layout of serial port config (Thanks Frank)

This commit is contained in:
Dave C-J 2014-04-30 14:09:08 +01:00
parent f60430305e
commit e49eb3c685
2 changed files with 41 additions and 65 deletions

View File

@ -99,8 +99,15 @@
</select>
</div>
<div class="form-row">
<label for="node-config-input-serialbaud"><i class="icon-wrench"></i> Baud Rate</label>
<select type="text" id="node-config-input-serialbaud" style="width: 150px;">
<table><tr>
<td width = "102px"><i class="icon-wrench"></i> Settings</td>
<td width = "100px">Baud Rate</td>
<td width = "80px">Data Bits</td>
<td width = "80px">Parity</td>
<td width = "80px">Stop Bits</td>
</tr><tr><td>&nbsp;</td>
<td>
<select type="text" id="node-config-input-serialbaud" style="width: 100px;">
<option value="115200">115200</option>
<option value="57600">57600</option>
<option value="38400">38400</option>
@ -119,33 +126,28 @@
<option value="75">75</option>
<option value="50">50</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-databits"><i class="icon-wrench"></i> Data Bits</label>
<select type="text" id="node-config-input-databits" style="width: 100px;">
</td><td>
<select type="text" id="node-config-input-databits" style="width: 80px;">
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-parity"><i class="icon-wrench"></i> Parity</label>
<select type="text" id="node-config-input-parity" style="width: 100px;">
</td><td>
<select type="text" id="node-config-input-parity" style="width: 80px;">
<option value="none">None</option>
<option value="even">Even</option>
<option value="mark">Mark</option>
<option value="odd">Odd</option>
<option value="space">Space</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-stopbits"><i class="icon-wrench"></i> Stop Bits</label>
<select type="text" id="node-config-input-stopbits" style="width: 100px;">
</td><td>
<select type="text" id="node-config-input-stopbits" style="width: 80px;">
<option value="2">2</option>
<option value="1">1</option>
</select>
</div>
</td>
</tr></table>
<div class="form-row">
<label for="node-config-input-newline"><i class="icon-text-width"></i> New line</label>
<input type="text" id="node-config-input-newline" style="width: 50px;">
@ -173,22 +175,14 @@
newline: {value:"\\n"},
addchar: {value:false}
},
label: function() {
if (typeof this.serialbaud === 'undefined') {
this.serialbaud = 57600;
}
if (typeof this.databits === 'undefined') {
this.databits = 8;
}
if (typeof this.parity === 'undefined') {
this.parity = 'none';
}
if (typeof this.stopbits == 'undefined') {
this.stopbits = 1;
}
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() {
oneditprepare: function() {
var p = this.serialport;
var s = $("#node-config-input-serialport");
$.getJSON('serialports',function(data) {

View File

@ -1,18 +1,18 @@
/**
* Copyright 2013 IBM Corp.
*
* 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.
**/
* Copyright 2013 IBM Corp.
*
* 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.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
var settings = RED.settings;
@ -28,30 +28,13 @@ function SerialPortNode(n) {
this.newline = n.newline;
this.addchar = n.addchar || "false";
if (typeof n.serialbaud === 'undefined') {
this.serialbaud = 57600;
} else {
this.serialbaud = parseInt(n.serialbaud);
}
if (typeof n.databits === 'undefined') {
this.databits = 8;
} else {
this.databits = parseInt(n.databits);
}
if (typeof n.parity === 'undefined') {
this.parity = 'none';
} else {
this.parity = n.parity;
}
if (typeof n.stopbits == 'undefined') {
this.stopbits = 1;
} else {
this.stopbits = parseInt(n.stopbits);
}
this.serialbaud = parseInt(n.serialbaud) || 57600;
this.databits = parseInt(n.databits) || 8;
this.parity = n.parity || "none";
this.stopbits = parseInt(n.stopbits) || 1;
}
RED.nodes.registerType("serial-port",SerialPortNode);
function SerialOutNode(n) {
RED.nodes.createNode(this,n);
this.serial = n.serial;
@ -99,7 +82,6 @@ function SerialOutNode(n) {
}
RED.nodes.registerType("serial out",SerialOutNode);
function SerialInNode(n) {
RED.nodes.createNode(this,n);
this.serial = n.serial;