From 1b63fdf0c6b710835467c2f041b94ae328cea03e Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Thu, 17 Oct 2024 17:26:47 +0000
Subject: [PATCH] 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
---
fhem/FHEM/01_FHEMWEB.pm | 15 +++++++++++++++
fhem/www/pgm2/console.js | 33 +++++++++++++++++++++++----------
2 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm
index a06037da1..f0006aa7e 100644
--- a/fhem/FHEM/01_FHEMWEB.pm
+++ b/fhem/FHEM/01_FHEMWEB.pm
@@ -177,6 +177,7 @@ FHEMWEB_Initialize($)
hiddengroupRegexp
hiddenroom
hiddenroomRegexp
+ htmlInEventMonitor:1,0
httpHeader
iconPath
jsLog:1,0
@@ -1256,6 +1257,7 @@ FW_dataAttr()
addParam($FW_wname, "addHtmlTitle", 1).
addParam($FW_wname, "styleData", "").
addParam($FW_wname, "hiddenroom", "").
+ addParam($FW_wname, "htmlInEventMonitor", 0). #139453
addParam("global", "language", "EN").
"data-availableJs='$FW_fhemwebjs' ".
"data-webName='$FW_wname' ";
@@ -4126,6 +4128,12 @@ FW_log($$)
+
+
htmlInEventMonitor
+ if set to 1, text enclosed in <html>...</html> will not be
+ escaped in the event monitor.
+
+
HTTPS
@@ -4988,6 +4996,13 @@ FW_log($$)
+
+ htmlInEventMonitor
+ falls 1, Text in <html>...</html> wird im Event Monitor als
+ HTML interpretiert.
+
+
+
HTTPS
Ermöglicht HTTPS Verbindungen. Es werden die Perl Module
diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js
index ed5b1090c..77a11c8a0 100644
--- a/fhem/www/pgm2/console.js
+++ b/fhem/www/pgm2/console.js
@@ -3,13 +3,14 @@ FW_version["console.js"] = "$Id$";
var consConn;
var consName="#console";
+var htmlInEventMonitor;
var consFilter, oldFilter, consFType="";
var consLastIndex = 0;
var withLog = 0;
var mustScroll = 1;
-log("Event monitor is starting!");
+log("Event monitor is starting");
function
cons_closeConn()
@@ -26,22 +27,32 @@ cons_closeConn()
function
consAppender(new_content)
{
+ var isHtml = htmlInEventMonitor && new_content.match(/[\s\S]*<\/html>/);
+
// Extract the FHEM-Log, to avoid escaping its formatting (Forum #104842)
var logContent = "";
var rTab = {'<':'<', '>':'>',' ':' ', '\n':'
' };
- new_content = new_content.replace(
- /()([\s\S]*?)(<\/div>)/gm,
- function(all, div1, msg, div2) {
- logContent += div1+
- msg.replace(/[<> \n]/g, function(a){return rTab[a]})+
- div2;
- return "";
- });
+
+ function
+ doEscape(inStr)
+ {
+ let r = isHtml ? inStr :
+ inStr.replace(/[<> \n]/g, function(a){return rTab[a]});
+ return isHtml ? inStr :
+ inStr.replace(/[<> \n]/g, function(a){return rTab[a]});
+ }
+
+ new_content = new_content
+ .replace(/(
)([\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 ncA = new_content.split(/
[\r\n]/);
for(var i1=0; i1 ]/g, function(a){return rTab[a]});
+ ncA[i1] = doEscape(ncA[i1]);
$(consName).append(logContent+ncA.join(isTa?"\n":"
"));
}
@@ -217,6 +228,8 @@ consStart()
}
});
consAddRegexpPart();
+
+ htmlInEventMonitor = $("body").attr("data-htmlineventmonitor") == 1;
}
function