2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

console.js: separate escaping for the FHEM-log (Forum #104842)

git-svn-id: https://svn.fhem.de/fhem/trunk@20489 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-11-10 15:09:48 +00:00
parent 8ef48368f6
commit e02cc613bf

View File

@ -60,13 +60,22 @@ consUpdate(evt)
if(new_content == undefined || new_content.length == 0)
return;
log("Console Rcvd: "+new_content);
// replace space with nbsp to preserve formatting
// Extract the FHEM-Log, to avoid escaping its formatting (Forum #104842)
var logContent = "";
var rTab = {'<':'&lt;', '>':'&gt;',' ':'&nbsp;'};
new_content = new_content.replace(/(<div class='fhemlog'>)(.*?)(<\/div>)/g,
function(all, div1, msg, div2) {
logContent += div1+msg.replace(/[<> ]/g, function(a){return rTab[a]})+div2;
return "";
});
// replace space with nbsp to preserve formatting
var isTa = $("#console").is("textarea"); // 102773
new_content = new_content.replace(/(.*)<br>[\r\n]/g, function(all,p1) {
return p1.replace(/[<> ]/g, function(a){return rTab[a]})+(isTa?"\n":"<br>");
});
$("#console").append(new_content);
$("#console").append(logContent+new_content);
if(mustScroll)
$("#console").scrollTop($("#console")[0].scrollHeight);