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

01_FHEMWEB.pm/console.js: add htmlInEventMonitor attribute (Forum #139453)

git-svn-id: https://svn.fhem.de/fhem/trunk@29254 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2024-10-17 17:26:47 +00:00
parent 93c11129d1
commit 1b63fdf0c6
2 changed files with 38 additions and 10 deletions

View File

@ -177,6 +177,7 @@ FHEMWEB_Initialize($)
hiddengroupRegexp hiddengroupRegexp
hiddenroom hiddenroom
hiddenroomRegexp hiddenroomRegexp
htmlInEventMonitor:1,0
httpHeader httpHeader
iconPath iconPath
jsLog:1,0 jsLog:1,0
@ -1256,6 +1257,7 @@ FW_dataAttr()
addParam($FW_wname, "addHtmlTitle", 1). addParam($FW_wname, "addHtmlTitle", 1).
addParam($FW_wname, "styleData", ""). addParam($FW_wname, "styleData", "").
addParam($FW_wname, "hiddenroom", ""). addParam($FW_wname, "hiddenroom", "").
addParam($FW_wname, "htmlInEventMonitor", 0). #139453
addParam("global", "language", "EN"). addParam("global", "language", "EN").
"data-availableJs='$FW_fhemwebjs' ". "data-availableJs='$FW_fhemwebjs' ".
"data-webName='$FW_wname' "; "data-webName='$FW_wname' ";
@ -4126,6 +4128,12 @@ FW_log($$)
</li> </li>
<br> <br>
<a id="FHEMWEB-attr-htmlInEventMonitor"></a>
<li>htmlInEventMonitor<br>
if set to 1, text enclosed in &lt;html&gt;...&lt;/html&gt; will not be
escaped in the event monitor.
</li>
<br>
<a id="FHEMWEB-attr-HTTPS"></a> <a id="FHEMWEB-attr-HTTPS"></a>
<li>HTTPS<br> <li>HTTPS<br>
@ -4988,6 +4996,13 @@ FW_log($$)
</li> </li>
<br> <br>
<a id="FHEMWEB-attr-htmlInEventMonitor"></a>
<li>htmlInEventMonitor<br>
falls 1, Text in &lt;html&gt;...&lt;/html&gt; wird im Event Monitor als
HTML interpretiert.
</li>
<br>
<a id="FHEMWEB-attr-HTTPS"></a> <a id="FHEMWEB-attr-HTTPS"></a>
<li>HTTPS<br> <li>HTTPS<br>
Erm&ouml;glicht HTTPS Verbindungen. Es werden die Perl Module Erm&ouml;glicht HTTPS Verbindungen. Es werden die Perl Module

View File

@ -3,13 +3,14 @@ FW_version["console.js"] = "$Id$";
var consConn; var consConn;
var consName="#console"; var consName="#console";
var htmlInEventMonitor;
var consFilter, oldFilter, consFType=""; var consFilter, oldFilter, consFType="";
var consLastIndex = 0; var consLastIndex = 0;
var withLog = 0; var withLog = 0;
var mustScroll = 1; var mustScroll = 1;
log("Event monitor is starting!"); log("Event monitor is starting");
function function
cons_closeConn() cons_closeConn()
@ -26,22 +27,32 @@ cons_closeConn()
function function
consAppender(new_content) consAppender(new_content)
{ {
var isHtml = htmlInEventMonitor && new_content.match(/<html>[\s\S]*<\/html>/);
// 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 = "";
var rTab = {'<':'&lt;', '>':'&gt;',' ':'&nbsp;', '\n':'<br>' }; var rTab = {'<':'&lt;', '>':'&gt;',' ':'&nbsp;', '\n':'<br>' };
new_content = new_content.replace(
/(<div class='fhemlog'>)([\s\S]*?)(<\/div>)/gm, function
function(all, div1, msg, div2) { doEscape(inStr)
logContent += div1+ {
msg.replace(/[<> \n]/g, function(a){return rTab[a]})+ let r = isHtml ? inStr :
div2; inStr.replace(/[<> \n]/g, function(a){return rTab[a]});
return ""; return isHtml ? inStr :
}); inStr.replace(/[<> \n]/g, function(a){return rTab[a]});
}
new_content = new_content
.replace(/(<div class='fhemlog'>)([\s\S]*?)(<\/div>)/gm,
function(all, div1, msg, div2) {
logContent += div1+msg+div2; // msg is already escaped
return "";
});
var isTa = $(consName).is("textarea"); // 102773 var isTa = $(consName).is("textarea"); // 102773
var ncA = new_content.split(/<br>[\r\n]/); var ncA = new_content.split(/<br>[\r\n]/);
for(var i1=0; i1<ncA.length; i1++) for(var i1=0; i1<ncA.length; i1++)
ncA[i1] = ncA[i1].replace(/[<> ]/g, function(a){return rTab[a]}); ncA[i1] = doEscape(ncA[i1]);
$(consName).append(logContent+ncA.join(isTa?"\n":"<br>")); $(consName).append(logContent+ncA.join(isTa?"\n":"<br>"));
} }
@ -217,6 +228,8 @@ consStart()
} }
}); });
consAddRegexpPart(); consAddRegexpPart();
htmlInEventMonitor = $("body").attr("data-htmlineventmonitor") == 1;
} }
function function