From 37ec6011f85b59d291c77d43a53898c4bb2f99dd Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Fri, 11 Sep 2015 00:19:47 -0400
Subject: [PATCH] more serial comm edits

---
 css/main.css                              | 10 ++++++++++
 js/menus/CommParentMenu.js                |  2 +-
 js/menus/SendMenuView.js                  |  4 ++++
 js/menus/SetupCommMenuView.js             |  4 ++++
 js/menus/templates/SendMenuView.html      |  2 +-
 js/menus/templates/SetupCommMenuView.html |  2 +-
 js/models/SerialComm.js                   |  3 ++-
 7 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/css/main.css b/css/main.css
index b878da64..87c0c8c3 100644
--- a/css/main.css
+++ b/css/main.css
@@ -498,4 +498,14 @@ label {
 .navbar-inverse .navbar-nav > .dropdown > a:hover .caret {
     border-top-color: #aaa;
     border-bottom-color: #aaa;
+}
+
+#incomingSerialMessage{
+    background-color: white;
+    white-space: nowrap;
+    max-width: 250px;
+    overflow: hidden;
+    display: inline-block;
+    text-overflow: ellipsis;
+    position: absolute;
 }
\ No newline at end of file
diff --git a/js/menus/CommParentMenu.js b/js/menus/CommParentMenu.js
index 34c7e90f..f71e66d9 100644
--- a/js/menus/CommParentMenu.js
+++ b/js/menus/CommParentMenu.js
@@ -41,10 +41,10 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'commPlist'
 
         _updateIncomingMessage: function(){
             var message = serialComm.get("lastMessageReceived");
-            console.log(message);
             var $message = $("#incomingSerialMessage");
             $message.html(message);
             $message.css("background", "#ffff99");
+            $message.css('display', 'inline-block');
             if (!this.inTimeout) {
                 this.inTimeout = true;
                 var self = this;
diff --git a/js/menus/SendMenuView.js b/js/menus/SendMenuView.js
index 57da9db0..f47b837b 100644
--- a/js/menus/SendMenuView.js
+++ b/js/menus/SendMenuView.js
@@ -54,6 +54,10 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'commPlist', 'te
             return _.extend(serialComm.toJSON(), commPlist, cam.toJSON(), camPlist, {streaming: this.isStreaming});
         },
 
+        _render: function(){
+            if (serialComm.get("lastMessageReceived") === null) $("#incomingSerialMessage").hide();
+        },
+
         template: _.template(template)
 
     });
diff --git a/js/menus/SetupCommMenuView.js b/js/menus/SetupCommMenuView.js
index 6c569e16..cd8531ae 100644
--- a/js/menus/SetupCommMenuView.js
+++ b/js/menus/SetupCommMenuView.js
@@ -56,6 +56,10 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!setupCommM
             return _.extend(serialComm.toJSON(), commPlist);
         },
 
+        _render: function(){
+            if (serialComm.get("lastMessageReceived") === null) $("#incomingSerialMessage").hide();
+        },
+
         template: _.template(template),
 
         helpFile: "" +
diff --git a/js/menus/templates/SendMenuView.html b/js/menus/templates/SendMenuView.html
index 7cbcb7ea..1ec28eb6 100644
--- a/js/menus/templates/SendMenuView.html
+++ b/js/menus/templates/SendMenuView.html
@@ -9,7 +9,7 @@
             <a href="#" id="streamCommands" class="btn btn-block btn-lg btn-success">Stream</a>
         <% } %>
         <br/>
-        Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"><br/></pre><br/>
+        Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"><%= lastMessageReceived %></pre><br/><br/>
         Out: &nbsp;&nbsp;<input id="sendSerialMessage" value="" placeholder="Send Message" class="seventyFiveWidth form-control unresponsiveInput" type="text"><br/><br/>
         Next Line: &nbsp;&nbsp;<input id="nextLine" value="" placeholder="##" class="intInput form-control unresponsiveInput" type="text">
         <a href="#" id="previousLineButton" class="btn btn-lg btn-default">Prev</a>
diff --git a/js/menus/templates/SetupCommMenuView.html b/js/menus/templates/SetupCommMenuView.html
index 6490b72f..713101f3 100644
--- a/js/menus/templates/SetupCommMenuView.html
+++ b/js/menus/templates/SetupCommMenuView.html
@@ -23,7 +23,7 @@
         </div>
         &nbsp;&nbsp;<a href="#" id="refreshPorts" class="btn btn-lg btn-default btn-icon"><img src="assets/imgs/refreshIcon.png"></a><br/><br/>
     <a href="#" id="openSerialMonitor" class="btn btn-block btn-lg btn-default">Open Serial Monitor</a><br/>
-    Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"><br/></pre><br/>
+    Incoming: &nbsp;&nbsp;<pre id="incomingSerialMessage"><%= lastMessageReceived %></pre><br/><br/>
     Out: &nbsp;&nbsp;<input id="sendSerialMessage" value="" placeholder="Send Message" class="seventyFiveWidth form-control unresponsiveInput" type="text"><br/><br/>
     <a href="#" id="serialFlushBuffer" class="btn btn-block btn-lg btn-danger">Flush Buffer</a><br/>
 <% }else{ %>
diff --git a/js/models/SerialComm.js b/js/models/SerialComm.js
index 86691d98..68c0ee4a 100644
--- a/js/models/SerialComm.js
+++ b/js/models/SerialComm.js
@@ -13,7 +13,7 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
             portName: "Select Port",
             baudRate: 200,
             error: null,
-            lastMessageReceived: "",
+            lastMessageReceived: null,
             lastMessageSent: ""
         },
 
@@ -73,6 +73,7 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
         });
 
         socket.on('dataIn', function(data){
+            if (data == "" || data == '\n' || data == "\r") return;
             serialComm.set("lastMessageReceived", data, {silent:true});
             serialComm.trigger("change:lastMessageReceived");
         });
-- 
GitLab