Node Serial Connection
text {
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 14px;
border: 2px solid blue;
text-transform: none;
overflow: auto;
text-align: left;
margin-top:4px;
margin:6px;
width:97vw;
border: 2px solid blue;
height:75vh;
}
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px
97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px
97c4fe;
box-shadow:inset 0px 1px 0px 0px
97c4fe;
background:-webkit-gradient[linear, left top, left bottom, color-stop[0.05,
3d94f6], color-stop[1,
1e62d0]];
background:-moz-linear-gradient[top,
3d94f6 5%,
1e62d0 100%];
background:-webkit-linear-gradient[top,
3d94f6 5%,
1e62d0 100%];
background:-o-linear-gradient[top,
3d94f6 5%,
1e62d0 100%];
background:-ms-linear-gradient[top,
3d94f6 5%,
1e62d0 100%];
background:linear-gradient[to bottom,
3d94f6 5%,
1e62d0 100%];
filter:progid:DXImageTransform.Microsoft.gradient[startColorstr\='
3d94f6', endColorstr\='
1e62d0',GradientType=0];
background-color:
3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid
337fed;
display:inline-block;
cursor:pointer;
color:
ffffff;
font-family:Arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px
1570cd;
margin-left:15px;
}
.myButton:hover {
background:-webkit-gradient[linear, left top, left bottom, color-stop[0.05,
1e62d0], color-stop[1,
3d94f6]];
background:-moz-linear-gradient[top,
1e62d0 5%,
3d94f6 100%];
background:-webkit-linear-gradient[top,
1e62d0 5%,
3d94f6 100%];
background:-o-linear-gradient[top,
1e62d0 5%,
3d94f6 100%];
background:-ms-linear-gradient[top,
1e62d0 5%,
3d94f6 100%];
background:linear-gradient[to bottom,
1e62d0 5%,
3d94f6 100%];
filter:progid:DXImageTransform.Microsoft.gradient[startColorstr\='
1e62d0', endColorstr\='
3d94f6',GradientType=0];
background-color:
1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}
function send_msg[data] {
var txt \= document.getElementById["msg"].value;
txt \= txt + data;
socket.emit['send', { Data: txt} ];
document.getElementById["msg"].value \= "";
document.sendform.msg.focus[];
}
function zeroFill[i] { return [i < 10 ? '0' : ''] + i }
function now[] {
var d \= new Date[]
return d.getFullYear[] + '-'
- zeroFill[[d.getMonth[] + 1]] + '-'
- zeroFill[d.getDate[]] + ' '
- zeroFill[d.getHours[]] + ':'
- zeroFill[d.getMinutes[]] + ':'
- zeroFill[d.getSeconds[]]
}
var text \= document.getElementById['text'];
var socket \= io.connect['//localhost:8888'];
socket.on['data', function[data] {
//console.log[JSON.stringify[data]];
var msgs \= document.getElementById["text"];
var txt \= msgs.innerHTML;
var rep \= data.data.replace[/\x0D\x0A/g,"
"];
txt \= txt + "
" + now[] + " " + rep;
msgs.innerHTML \= txt;
msgs.scrollTop \= msgs.scrollHeight;
}];
document.getElementById['msg'].addEventListener['keypress', function[event] {
if [event.keyCode \== 13] { send_msg["\n"]; event.preventDefault[]; }
}];
document.sendform.msg.focus[];