From 949d511755a3c686c570983226c7bfffd4f3cec1 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Mon, 26 Oct 2015 18:49:54 +0000
Subject: [PATCH] console.js: some changes (Forum #42258)
git-svn-id: https://svn.fhem.de/fhem/trunk@9694 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/01_FHEMWEB.pm | 3 ++-
fhem/www/pgm2/console.js | 30 +++++++++++++++++++++++-------
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm
index 73639e220..fe38de500 100755
--- a/fhem/FHEM/01_FHEMWEB.pm
+++ b/fhem/FHEM/01_FHEMWEB.pm
@@ -1929,7 +1929,8 @@ FW_style($$)
"";
FW_pO "
";
my $filter = ($a[2] && $a[2] ne "1") ? $a[2] : ".*";
- FW_pO "Events (Filter:
$filter):
\n";
+ FW_pO "Events (Filter:
$filter)".
+ "
[Reset]:
\n";
FW_pO "
";
FW_pO "
";
diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js
index ab6762e1f..4bb18c082 100644
--- a/fhem/www/pgm2/console.js
+++ b/fhem/www/pgm2/console.js
@@ -1,8 +1,7 @@
var consConn;
-var isFF = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1);
-var consFilter, consTxt;
-
+var consFilter, oldFilter;
+var consLastIndex = 0;
log("Console is opening");
function
@@ -16,9 +15,17 @@ consUpdate()
if(consConn.readyState != 3)
return;
-
+ var len = consConn.responseText.length;
+
+ if (consLastIndex == len) // No new data
+ return;
+
+ var new_content = consConn.responseText.substring(consLastIndex, len);
+ consLastIndex = len;
+
+ log("Console Rcvd: "+new_content);
$("#console")
- .html(consTxt+consConn.responseText)
+ .append(new_content.replace(/ /g, " "))
.scrollTop($("#console")[0].scrollHeight);
}
@@ -39,6 +46,11 @@ consFill()
consConn.open("GET", query, true);
consConn.onreadystatechange = consUpdate;
consConn.send(null);
+ consLastIndex = 0;
+ if(oldFilter != consFilter) // only clear, when filter changes
+ $("#console").html("");
+
+ oldFilter = consFilter;
}
function
@@ -49,9 +61,14 @@ consStart()
consFilter = $("a#eventFilter").html();
if(consFilter == undefined)
consFilter = ".*";
- consTxt = el.innerHTML;
+ oldFilter = consFilter;
setTimeout("consFill()", 1000);
+ $("a#eventReset").click(function(evt){ // Event Monitor Reset
+ log("Console resetted by user");
+ $("#console").html("");
+ });
+
$("a#eventFilter").click(function(evt){ // Event-Filter Dialog
$('body').append(
''+
@@ -70,7 +87,6 @@ consStart()
consFilter = val ? val : ".*";
$(this).dialog('close');
$("a#eventFilter").html(consFilter);
- $("#console").html(consTxt);
consFill();
}}]
});