From 8588340bffe224c43914a773a18c0d51ba9f98be Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 3 Apr 2022 15:25:07 +0200 Subject: [PATCH] Shrink javascript --- tasmota/xdrv_01_webserver.ino | 4 ++-- tasmota/xdrv_10_scripter.ino | 2 +- tasmota/xdrv_23_zigbee_9a_upload.ino | 2 +- tasmota/xdrv_23_zigbee_A_impl.ino | 2 +- tasmota/xdrv_43_mlx90640.ino | 4 ++-- tasmota/xdrv_52_9_berry.ino | 8 ++++---- tasmota/xsns_62_esp32_mi.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 4bfc61b66..fbb83954f 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -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 ); diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 5dc343c32..3a7f50a85 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -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,\"\").replace(/{s}/g,\"\").replace(/{c}/g,\"%%'>
\").replace(/{s}/g,\"
\");" diff --git a/tasmota/xdrv_23_zigbee_9a_upload.ino b/tasmota/xdrv_23_zigbee_9a_upload.ino index c644bb685..07add3891 100644 --- a/tasmota/xdrv_23_zigbee_9a_upload.ino +++ b/tasmota/xdrv_23_zigbee_9a_upload.ino @@ -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 diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 41ee70119..8cc355a6b 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -1716,7 +1716,7 @@ const char ZB_WEB_U[] PROGMEM = // index 4 // Auto-refresh //=ZB_WEB_AUTO_REFRESH - "" + "" "\0" // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/tasmota/xdrv_43_mlx90640.ino b/tasmota/xdrv_43_mlx90640.ino index 9262b5734..833340c90 100644 --- a/tasmota/xdrv_43_mlx90640.ino +++ b/tasmota/xdrv_43_mlx90640.ino @@ -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;" diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index 443240b5a..47085ada8 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -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.... "}" diff --git a/tasmota/xsns_62_esp32_mi.h b/tasmota/xsns_62_esp32_mi.h index f536c6c9c..ba01d619a 100644 --- a/tasmota/xsns_62_esp32_mi.h +++ b/tasmota/xsns_62_esp32_mi.h @@ -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;}"
\").replace(/{m}/g,\"\").replace(/{e}/g,\"
\").replace(/{m}/g,\"\").replace(/{e}/g,\"