From 34e089ff4335bae5c21a633de3c0e0c8724aab9d Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 7 Apr 2016 18:58:11 +0000 Subject: [PATCH] console.js: autoscroll patch by Markus (Forum #51897) git-svn-id: https://svn.fhem.de/fhem/trunk@11200 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/console.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js index cf8378cc9..6b1d965d9 100644 --- a/fhem/www/pgm2/console.js +++ b/fhem/www/pgm2/console.js @@ -3,6 +3,8 @@ var consConn; var consFilter, oldFilter; var consLastIndex = 0; var withLog = 0; +var mustScroll = 1; + log("Console is opening"); function @@ -27,9 +29,11 @@ consUpdate() log("Console Rcvd: "+new_content); if(new_content.indexOf('<') != 0) new_content = new_content.replace(/ /g, " "); - $("#console") - .append(new_content) - .scrollTop($("#console")[0].scrollHeight); + + $("#console").append(new_content); + + if(mustScroll) + $("#console").scrollTop($("#console")[0].scrollHeight); } function @@ -105,6 +109,22 @@ consStart() withLog = ($("#eventWithLog").is(':checked') ? 1 : 0); consFill(); }); + + + $("#console").scroll(function() { // autoscroll check + if($("#console")[0].scrollHeight - $("#console").scrollTop() == + $("#console").outerHeight()) { + if(!mustScroll) { + mustScroll = 1; + log("Console autoscroll restarted"); + } + } else { + if(mustScroll) { + mustScroll = 0; + log("Console autoscroll stopped"); + } + } + }); } window.onload = consStart;