Skip to content

Commit

Permalink
Updated DOM render / faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsiever committed Sep 18, 2023
1 parent 46261d8 commit 114ced7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@
// Append a line to the console frame
function consolePrintln(message) {
var con = document.getElementById("console")
con.innerHTML += "<br/>"+message
con.appendChild(document.createTextNode(message))
con.appendChild(document.createElement("br"))
con.scrollTop = con.scrollHeight
}
function consolePrintlnBold(message) {
var con = document.getElementById("console")
let boldItem = document.createElement("b")
boldItem.innerHTML = message
con.appendChild(boldItem)
con.appendChild(document.createElement("br"))
con.scrollTop = con.scrollHeight
}

Expand All @@ -46,18 +55,18 @@
function uBitEventHandler(reason, device, data) {
switch(reason) {
case "connected":
consolePrintln("<b>Connected!</b>")
consolePrintlnBold("Connected!")
connectedDevices.push(device)
break
case "disconnected":
consolePrintln("<b>Disconnected</b>")
consolePrintlnBold("Disconnected")
connectedDevices = connectedDevices.filter( v => v != device)
break
case "connection failure":
consolePrintln("<b>Connection Failure</b>")
consolePrintlnBold("Connection Failure")
break
case "error":
consolePrintln("<b>Error</b>")
consolePrintlnBold("Error")
break
case "console":
consolePrintln("Console Data: " + data.data)
Expand Down

0 comments on commit 114ced7

Please sign in to comment.