diff --git a/home.html b/home.html
index 8021c83f4..7551a48dc 100644
--- a/home.html
+++ b/home.html
@@ -1,5 +1,6 @@
+
-
+
Arduino Create Agent Debug Console
@@ -17,19 +18,38 @@
var MESSAGES_MAX_COUNT = 2000;
function appendLog(msg) {
- var startsWithBracked = msg.indexOf('{') == 0;
+ let jsonMsg = {};
+ let portListing = false;
+ try {
+ jsonMsg = JSON.parse(msg);
+ portsListing = jsonMsg.Ports;
+ } catch {
+ // no valid json
+ }
+
var startsWithList = msg.indexOf('list') == 0;
- if (listenabled.checked || (typeof msg === 'string' && !startsWithBracked && !startsWithList)) {
- messages.push(msg);
- if (messages.length > MESSAGES_MAX_COUNT) {
- messages.shift();
- }
- log.innerHTML = messages.join(' ');
- if (autoscroll.checked) {
- log.scrollTop = log.scrollHeight - log.clientHeight;
- }
- }
+ if (listenabled.checked || (!portsListing && !startsWithList)) {
+ let printMsg = msg;
+ if (jsonMsg.Ports) {
+ const validKeys = ['Name', 'SerialNumber', 'IsOpen', 'VendorID', 'ProductID'];
+ if (jsonMsg.Network) {
+ printMsg = "Network Ports : "+JSON.stringify(jsonMsg.Ports, validKeys, 2);
+ } else {
+ printMsg = "Serial Ports : "+JSON.stringify(jsonMsg.Ports, validKeys, 2);
+ }
+ } else if (Object.keys(jsonMsg).length !== 0) {
+ printMsg = JSON.stringify(jsonMsg, undefined, 2);
+ }
+ messages.push(printMsg);
+ if (messages.length > MESSAGES_MAX_COUNT) {
+ messages.shift();
+ }
+ log.innerHTML = messages.join(' ');
+ if (autoscroll.checked) {
+ log.scrollTop = log.scrollHeight - log.clientHeight;
+ }
+ }
}
$('#form').submit(function(e) {
@@ -47,6 +67,7 @@
var link = document.createElement('a');
link.setAttribute('download', 'agent-log.txt');
var text = log.innerHTML.replace(/ /g, '\n');
+ text = text.replace(/|<\/b>/g, '');
link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
link.click();
});
@@ -92,7 +113,7 @@
#container {
display: flex;
flex-direction: column;
- height: 100%;
+ height: 100vh;
width: 100%;
}
@@ -100,6 +121,7 @@
flex-grow: 1;
font-family: "Roboto Mono", "Courier", "Lucida Grande", Verdana, sans-serif;
background-color: #DAE3E3;
+ height: calc(100vh - 61px);
margin: 15px 15px 10px;
padding: 8px 10px;
overflow-y: auto;
@@ -182,16 +204,15 @@
font-size: 1em;
outline: none;
}
-
-
This is some random text This is some random textThis is some random textThis is some random textThis is some random textThis is some random textThis is some random text This is some random text This is some random text
+