Shrink javascript

This commit is contained in:
Theo Arends 2022-04-03 15:25:07 +02:00
parent e9ec0934d3
commit 8588340bff
7 changed files with 12 additions and 12 deletions

View File

@ -116,7 +116,7 @@ const char HTTP_SCRIPT_HIDE[] PROGMEM =
"}";
const char HTTP_SCRIPT_RELOAD_TIME[] PROGMEM =
"setTimeout(function(){location.href='.';},%d);";
"setTimeout(()=>{location.href='.';},%d);";
#ifdef USE_UNISHOX_COMPRESSION
#include "./html_compressed/HTTP_SCRIPT_CONSOL.h"
@ -984,7 +984,7 @@ void WebRestart(uint32_t type)
#if ((RESTART_AFTER_INITIAL_WIFI_CONFIG) && (AFTER_INITIAL_WIFI_CONFIG_GO_TO_NEW_IP))
// In case of type 3 (New network has been configured) go to the new device's IP in the new Network
if (3 == type) {
WSContentSend_P("setTimeout(function(){location.href='http://%_I';},%d);",
WSContentSend_P("setTimeout(()=>{location.href='http://%_I';},%d);",
(uint32_t)WiFi.localIP(),
HTTP_RESTART_RECONNECT_TIME
);

View File

@ -7922,7 +7922,7 @@ const char HTTP_SCRIPT_FULLPAGE1[] PROGMEM =
"}"
"if(x!=null){x.abort();}" // Abort if no response within 2 seconds (happens on restart 1)
"x=new XMLHttpRequest();"
"x.onreadystatechange=function(){"
"x.onreadystatechange=()=>{"
"if(x.readyState==4&&x.status==200){"
// "var s=x.responseText.replace(/{t}/g,\"<table style='width:100%%'>\").replace(/{s}/g,\"<tr><th>\").replace(/{m}/g,\"</th><td>\").replace(/{e}/g,\"</td></tr>\").replace(/{c}/g,\"%%'><div style='text-align:center;font-weight:\");"
"var s=x.responseText.replace(/{t}/g,\"<table style='width:100%%'>\").replace(/{s}/g,\"<tr><th>\").replace(/{m}/g,\"</th><td>\").replace(/{e}/g,\"</td></tr>\");"

View File

@ -531,7 +531,7 @@ const char HTTP_SCRIPT_XFER_STATE[] PROGMEM =
"function z9(){"
"if(x!=null){x.abort();}" // Abort if no response within 2 seconds (happens on restart 1)
"x=new XMLHttpRequest();"
"x.onreadystatechange=function(){"
"x.onreadystatechange=()=>{"
"if(x.readyState==4&&x.status==200){"
"var s=x.responseText;"
"if(s!=7){" // ZBU_UPLOAD

View File

@ -1716,7 +1716,7 @@ const char ZB_WEB_U[] PROGMEM =
// index 4
// Auto-refresh
//=ZB_WEB_AUTO_REFRESH
"<script>setTimeout(function(){location.reload();},1990);</script>"
"<script>setTimeout(()=>{location.reload();},1990);</script>"
"\0"
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -144,12 +144,12 @@ const char HTTP_MLX90640_2a_SNS_COMPRESSED[] PROGMEM = "\x33\xBF\xA0\xB7\x9A\x3E
#else
const char HTTP_MLX90640_2a_SNS[] PROGMEM =
"var line = 0;"
"setInterval(function() {"
"setInterval(()=>{"
"rl('ul',line);" // 0 = do NOT force refresh
"},200);"
"function rl(s,v){" //source, value
"var xr=new XMLHttpRequest();"
"xr.onreadystatechange=function(){"
"xr.onreadystatechange=()=>{"
"if(xr.readyState==4&&xr.status==200){"
"var aB = xr.response;" // arrayBuffer
"var i;"

View File

@ -484,13 +484,13 @@ const char HTTP_SCRIPT_BERRY_CONSOLE[] PROGMEM =
"cn=0;"
"}"
"c.value='';"
"t.scrollTop=99999999;"
"t.scrollTop=1e8;"
"sn=t.scrollTop;"
"}"
"if(t.scrollTop>=sn){" // User scrolled back so no updates
"if(x!=null){x.abort();}" // Abort if no response within 2 seconds (happens on restart 1)
"x=new XMLHttpRequest();"
"x.onreadystatechange=function(){"
"x.onreadystatechange=()=>{"
"if(x.readyState==4&&x.status==200){"
"var d,t1;"
"d=x.responseText.split(/" BERRY_CONSOLE_CMD_DELIMITER "/,2);" // Field separator
@ -508,7 +508,7 @@ const char HTTP_SCRIPT_BERRY_CONSOLE[] PROGMEM =
"t1.innerText=d1;"
"t.appendChild(t1);"
"}"
"t.scrollTop=99999999;"
"t.scrollTop=1e8;"
"sn=t.scrollTop;"
"clearTimeout(ft);"
"lt=setTimeout(l,ltm);" // webrefresh timer....
@ -516,7 +516,7 @@ const char HTTP_SCRIPT_BERRY_CONSOLE[] PROGMEM =
"};"
"x.open('GET','bc?c2='+id+o,true);" // Related to Webserver->hasArg("c2") and WebGetArg("c2", stmp, sizeof(stmp))
"x.send();"
"ft=setTimeout(l,20000);" // fail timeout, triggered 20s after asking for XHR
"ft=setTimeout(l,2e4);" // fail timeout, triggered 20s after asking for XHR
"}else{"
"lt=setTimeout(l,ltm);" // webrefresh timer....
"}"

View File

@ -451,7 +451,7 @@ const char HTTP_MI32_SCRIPT_1[] PROGMEM =
"for(const el of ti){var t=parseInt(el.innerText);el.innerText=t+1;}}"
"function update(){" //source, value
"var xr=new XMLHttpRequest();"
"xr.onreadystatechange=function(){"
"xr.onreadystatechange=()=>{"
"if(xr.readyState==4&&xr.status==200){"
"var r = xr.response;" // new widget
"if(r.length>2000){return;};if(r.length==0){return;}"