console.js: fix html without <br> (Forum #120914)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24406 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-05-10 07:55:41 +00:00
parent 9348100dc7
commit 52a11fd862

View File

@ -59,7 +59,11 @@ consUpdate(evt)
} }
if(new_content == undefined || new_content.length == 0) if(new_content == undefined || new_content.length == 0)
return; return;
log("Console Rcvd: "+new_content); if(new_content.length < 120)
log("console Rcvd: "+new_content);
else
log("console Rcvd: "+new_content.substr(0,120)+
"..., truncated, original length "+new_content.length);
// Extract the FHEM-Log, to avoid escaping its formatting (Forum #104842) // Extract the FHEM-Log, to avoid escaping its formatting (Forum #104842)
var logContent = ""; var logContent = "";
@ -70,12 +74,11 @@ consUpdate(evt)
return ""; return "";
}); });
// replace space with nbsp to preserve formatting
var isTa = $("#console").is("textarea"); // 102773 var isTa = $("#console").is("textarea"); // 102773
new_content = new_content.replace(/(.*)<br>[\r\n]/g, function(all,p1) { var ncA = new_content.split(/<br>[\r\n]/);
return p1.replace(/[<> ]/g, function(a){return rTab[a]})+(isTa?"\n":"<br>"); for(var i1=0; i1<ncA.length; i1++)
}); ncA[i1] = ncA[i1].replace(/[<> ]/g, function(a){return rTab[a]});
$("#console").append(logContent+new_content); $("#console").append(logContent+ncA.join(isTa?"\n":"<br>");
if(mustScroll) if(mustScroll)
$("#console").scrollTop($("#console")[0].scrollHeight); $("#console").scrollTop($("#console")[0].scrollHeight);