mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[LOG] Fix for the minified JS
This commit is contained in:
@@ -411,6 +411,7 @@ static const char DATA_UPDATE_SENSOR_VALUES_DEVICE_PAGE_JS[] PROGMEM = {
|
||||
#ifdef WEBSERVER_INCLUDE_JS
|
||||
static const char DATA_FETCH_AND_PARSE_LOG_JS[] PROGMEM = {
|
||||
"function elId(e){return document.getElementById(e)}"
|
||||
"const ct1 = elId('copyText_1');"
|
||||
"window.fetch?ct1.textContent='Fetching log entries...':"
|
||||
"ct1.textContent='Error: This browser is not supported. Please use a modern browser.';"
|
||||
"const logLevel={0:'Unused',1:'Error',2:'Info',3:'Debug',4:'Debug More',9:'Debug Dev'};"
|
||||
@@ -424,7 +425,7 @@ static const char DATA_FETCH_AND_PARSE_LOG_JS[] PROGMEM = {
|
||||
"o&&(ct1.textContent==='Fetching log entries...'&&(ct1.innerHTML=''),ct1.innerHTML+=o);"
|
||||
"applyLogFilter();"
|
||||
"elId('autoscroll')?.checked&&ct1.scrollTo({top:ct1.scrollHeight,behavior:e<=500?'auto':'smooth'});"
|
||||
"let n=t.Log.SettingsWebLogLevel,r=logLevel[n]??'Undefined';"
|
||||
"let n=t.Log.SettingsWebLogLevel,r=logLevel[n]?" "?'Undefined';"
|
||||
"elId('current_loglevel').textContent=`Logging: ${r} (${n})`;"
|
||||
"loopDeLoop(e)})"
|
||||
".catch(e=>{ct1.innerHTML+=`<div>>> ${e.message} <<</div>`;"
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
function elId(e){return document.getElementById(e)}document.getElementById("logfilter")||(document.querySelector("section").innerHTML+='<label>Filter: <input id="logfilter" size="35"></label>');const ct1=elId("copyText_1");window.fetch?ct1.textContent="Fetching log entries...":ct1.textContent="Error: This browser is not supported. Please use a modern browser.";const logLevel={0:"Unused",1:"Error",2:"Info",3:"Debug",4:"Debug More",9:"Debug Dev"};function loopDeLoop(e=1e3){setTimeout((function(){fetch("/logjson").then((e=>{if(!e.ok)throw new Error(e.status);return e.json()})).then((t=>{let o="";for(let e=0;e<t.Log.nrEntries;e++){const n=t.Log.Entries[e];n&&n.timestamp&&(o+=`<div class="level_${n.level}">\n <font color="gray">${n.timestamp}:</font> ${n.text}\n </div>`)}e=t.Log.TTL||e,o&&("Fetching log entries..."===ct1.textContent&&(ct1.innerHTML=""),ct1.innerHTML+=o),applyLogFilter(),elId("autoscroll")?.checked&&ct1.scrollTo({top:ct1.scrollHeight,behavior:e<=500?"auto":"smooth"});const n=t.Log.SettingsWebLogLevel,l=logLevel[n]??"Undefined";elId("current_loglevel").textContent=`Logging: ${l} (${n})`,loopDeLoop(e)})).catch((e=>{ct1.innerHTML+=`<div>>> ${e.message} <<</div>`,ct1.scrollTop=ct1.scrollHeight,loopDeLoop(5e3)}))}),e)}function applyLogFilter(){const e=elId("logfilter").value.split(";").map((e=>e.trim())).filter(Boolean),t=document.querySelectorAll("#copyText_1 > div"),o=e.some((e=>!e.startsWith("!")));for(const n of t){n.dataset.originalHtml||(n.dataset.originalHtml=n.innerHTML);let t=n.dataset.originalHtml;const l=n.textContent.toLowerCase();let i=[],s=!1,r=!o;for(const t of e)if(t.startsWith("!")){const e=t.slice(1);if(!e.includes("&")||e.startsWith("&")||e.endsWith("&")){if(e&&l.includes(e.toLowerCase())){s=!0;break}}else{const t=e.split("&").map((e=>e.trim())).filter(Boolean);let o=-1,n=!0;for(const e of t){const t=l.indexOf(e.toLowerCase(),o+1);if(-1===t){n=!1;break}o=t}if(n){s=!0;break}}}else if(!t.includes("&")||t.startsWith("&")||t.endsWith("&")){if(l.includes(t.toLowerCase())){i.push(t),r=!0;break}}else{const e=t.split("&").map((e=>e.trim())).filter(Boolean);if(e.length>=2){let t=-1,o=!0;for(const n of e){const e=l.indexOf(n.toLowerCase(),t+1);if(-1===e){o=!1;break}t=e}if(o){i.push(...e),r=!0;break}}}!s&&r?(n.style.display="",n.innerHTML=highlightOutsideTags(t,i)):n.style.display="none"}}function highlightOutsideTags(e,t){if(!t.length)return e;let o="",n=!1,l=0;for(;l<e.length;){const i=e[l];if("<"===i&&(n=!0),">"!==i){if(!n){let n=!1;for(const i of t){const t=e.slice(l,l+i.length);if(t.toLowerCase()===i.toLowerCase()){o+=`<span style="background-color: #bb9300;color: black;">${t}</span>`,l+=i.length,n=!0;break}}if(n)continue}o+=i,l++}else n=!1,o+=i,l++}return o}loopDeLoop(1e3);const input=document.getElementById("logfilter");input&&(input.placeholder='"!"=exclude ";"=or "&"=and (e.g. !act)');
|
||||
Reference in New Issue
Block a user