mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 21:56:35 +00:00
Add more ES6 javascript
Add more ES6 javascript
This commit is contained in:
parent
1effa25402
commit
48b96528fc
@ -61,6 +61,8 @@ const char HTTP_HEAD[] PROGMEM =
|
|||||||
"eb=s=>document.getElementById(s);" // Alias to save code space
|
"eb=s=>document.getElementById(s);" // Alias to save code space
|
||||||
"qs=s=>document.querySelector(s);" // Alias to save code space
|
"qs=s=>document.querySelector(s);" // Alias to save code space
|
||||||
"sp=i=>eb(i).type=(eb(i).type==='text'?'password':'text');" // Toggle password visibility
|
"sp=i=>eb(i).type=(eb(i).type==='text'?'password':'text');" // Toggle password visibility
|
||||||
|
"wl=f=>window.addEventListener('load',f);" // Execute multiple window.onload
|
||||||
|
;
|
||||||
#else
|
#else
|
||||||
"function eb(s){"
|
"function eb(s){"
|
||||||
"return document.getElementById(s);" // Alias to save code space
|
"return document.getElementById(s);" // Alias to save code space
|
||||||
@ -71,22 +73,10 @@ const char HTTP_HEAD[] PROGMEM =
|
|||||||
"function sp(i){" // Toggle password visibility
|
"function sp(i){" // Toggle password visibility
|
||||||
"eb(i).type=(eb(i).type==='text'?'password':'text');"
|
"eb(i).type=(eb(i).type==='text'?'password':'text');"
|
||||||
"}"
|
"}"
|
||||||
#endif
|
|
||||||
|
|
||||||
// https://www.htmlgoodies.com/beyond/javascript/article.php/3724571/Using-Multiple-JavaScript-Onload-Functions.htm
|
|
||||||
"function wl(f){" // Execute multiple window.onload
|
"function wl(f){" // Execute multiple window.onload
|
||||||
"var o=window.onload;"
|
"window.addEventListener('load',f);"
|
||||||
"if(typeof window.onload!='function'){"
|
|
||||||
"window.onload=f;"
|
|
||||||
"}else{"
|
|
||||||
"window.onload=function(){"
|
|
||||||
"if(o){"
|
|
||||||
"o();"
|
|
||||||
"}"
|
|
||||||
"f();"
|
|
||||||
"}"
|
|
||||||
"}"
|
|
||||||
"}";
|
"}";
|
||||||
|
#endif
|
||||||
|
|
||||||
const char HTTP_SCRIPT_COUNTER[] PROGMEM =
|
const char HTTP_SCRIPT_COUNTER[] PROGMEM =
|
||||||
"var cn=180;" // seconds
|
"var cn=180;" // seconds
|
||||||
@ -118,12 +108,19 @@ const char HTTP_SCRIPT_ROOT[] PROGMEM =
|
|||||||
"x.send();"
|
"x.send();"
|
||||||
"lt=setTimeout(la,%d);" // Settings.web_refresh
|
"lt=setTimeout(la,%d);" // Settings.web_refresh
|
||||||
"}"
|
"}"
|
||||||
|
|
||||||
|
#ifdef USE_JAVASCRIPT_ES6
|
||||||
|
"lb=p=>la('&d='+p);" // Dark - Bright &d related to lb(value) and WebGetArg("d", tmp, sizeof(tmp));
|
||||||
|
"lc=p=>la('&t='+p);" // Cold - Warm &t related to lc(value) and WebGetArg("t", tmp, sizeof(tmp));
|
||||||
|
#else
|
||||||
"function lb(p){"
|
"function lb(p){"
|
||||||
"la('&d='+p);" // &d related to WebGetArg("d", tmp, sizeof(tmp));
|
"la('&d='+p);" // &d related to WebGetArg("d", tmp, sizeof(tmp));
|
||||||
"}"
|
"}"
|
||||||
"function lc(p){"
|
"function lc(p){"
|
||||||
"la('&t='+p);" // &t related to WebGetArg("t", tmp, sizeof(tmp));
|
"la('&t='+p);" // &t related to WebGetArg("t", tmp, sizeof(tmp));
|
||||||
"}"
|
"}"
|
||||||
|
#endif
|
||||||
|
|
||||||
"wl(la);";
|
"wl(la);";
|
||||||
|
|
||||||
const char HTTP_SCRIPT_WIFI[] PROGMEM =
|
const char HTTP_SCRIPT_WIFI[] PROGMEM =
|
||||||
@ -238,9 +235,15 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM =
|
|||||||
"sk(17,99);" // 17 = WEMOS
|
"sk(17,99);" // 17 = WEMOS
|
||||||
"st(" STR(USER_MODULE) ");"
|
"st(" STR(USER_MODULE) ");"
|
||||||
"}"
|
"}"
|
||||||
|
|
||||||
|
#ifdef USE_JAVASCRIPT_ES6
|
||||||
|
"sl=()=>ld('tp?m=1',x2);" // ?m related to WebServer->hasArg("m")
|
||||||
|
#else
|
||||||
"function sl(){"
|
"function sl(){"
|
||||||
"ld('tp?m=1',x2);" // ?m related to WebServer->hasArg("m")
|
"ld('tp?m=1',x2);" // ?m related to WebServer->hasArg("m")
|
||||||
"}"
|
"}"
|
||||||
|
#endif
|
||||||
|
|
||||||
"wl(sl);";
|
"wl(sl);";
|
||||||
|
|
||||||
const char HTTP_SCRIPT_MODULE1[] PROGMEM =
|
const char HTTP_SCRIPT_MODULE1[] PROGMEM =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user