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

View File

@ -1,18 +1,18 @@
/** /**
* Copyright 2013 IBM Corp. * Copyright 2013 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
**/ **/
var RED = require(process.env.NODE_RED_HOME+"/red/red"); var RED = require(process.env.NODE_RED_HOME+"/red/red");
var settings = RED.settings; var settings = RED.settings;
@ -28,30 +28,13 @@ function SerialPortNode(n) {
this.newline = n.newline; this.newline = n.newline;
this.addchar = n.addchar || "false"; this.addchar = n.addchar || "false";
if (typeof n.serialbaud === 'undefined') { this.serialbaud = parseInt(n.serialbaud) || 57600;
this.serialbaud = 57600; this.databits = parseInt(n.databits) || 8;
} else { this.parity = n.parity || "none";
this.serialbaud = parseInt(n.serialbaud); this.stopbits = parseInt(n.stopbits) || 1;
}
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);
}
} }
RED.nodes.registerType("serial-port",SerialPortNode); RED.nodes.registerType("serial-port",SerialPortNode);
function SerialOutNode(n) { function SerialOutNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.serial = n.serial; this.serial = n.serial;
@ -99,7 +82,6 @@ function SerialOutNode(n) {
} }
RED.nodes.registerType("serial out",SerialOutNode); RED.nodes.registerType("serial out",SerialOutNode);
function SerialInNode(n) { function SerialInNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.serial = n.serial; this.serial = n.serial;