diff --git a/main.go b/main.go index 6b1019ee4..411a07a98 100755 --- a/main.go +++ b/main.go @@ -301,14 +301,18 @@ const homeTemplateHtml = ` var socket; var msg = $("#msg"); - var log = $("#log"); + var log = document.getElementById('log'); + var messages = []; function appendLog(msg) { - var d = log[0] - var doScroll = d.scrollTop == d.scrollHeight - d.clientHeight; - msg.appendTo(log) + messages.push(msg); + if (messages.length > 100) { + messages.shift(); + } + var doScroll = log.scrollTop == log.scrollHeight - log.clientHeight; + log.innerHTML = messages.join("
"); if (doScroll) { - d.scrollTop = d.scrollHeight - d.clientHeight; + log.scrollTop = log.scrollHeight - log.clientHeight; } } @@ -334,7 +338,7 @@ const homeTemplateHtml = ` appendLog($("
Connection closed.
")) }); socket.on("message", function(evt) { - appendLog($("
").text(evt)) + appendLog(evt); }); } else { appendLog($("
Your browser does not support WebSockets.
")) diff --git a/serial.go b/serial.go index 3773e572f..6fb94fd4f 100755 --- a/serial.go +++ b/serial.go @@ -472,24 +472,26 @@ func spListDual(network bool) { // happen on windows in a fallback scenario where an // open port can't be identified because it is locked, // so just solve that by manually inserting - for port := range sh.ports { - - isFound := false - for _, item := range list { - if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) { - isFound = true - } - } - - if !isFound { - // artificially push to front of port list - log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name)) - var ossp OsSerialPort - ossp.Name = port.portConf.Name - ossp.FriendlyName = port.portConf.Name - list = append([]OsSerialPort{ossp}, list...) - } - } + // if network { + // for port := range sh.ports { + + // isFound := false + // for _, item := range list { + // if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) { + // isFound = true + // } + // } + + // if !isFound { + // // artificially push to front of port list + // log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name)) + // var ossp OsSerialPort + // ossp.Name = port.portConf.Name + // ossp.FriendlyName = port.portConf.Name + // list = append([]OsSerialPort{ossp}, list...) + // } + // } + // } // we have a full clean list of ports now. iterate thru them // to append the open/close state, baud rates, etc to make