Start using optional ES6 saving code space

Start using optional ES6 saving code space
This commit is contained in:
Theo Arends 2019-06-12 17:32:25 +02:00
parent 2e7c72724d
commit 9d706c9864
2 changed files with 8 additions and 4 deletions

View File

@ -278,6 +278,7 @@
#define USE_WEBSERVER // Enable web server and Wifi Manager (+66k code, +8k mem)
#define WEB_PORT 80 // Web server Port for User and Admin mode
#define WEB_USERNAME "admin" // Web server Admin mode user name
// #define USE_JAVASCRIPT_ES6 // Enable ECMAScript6 syntax using less JavaScript code bytes (fails on IE11)
#define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
#define USE_EMULATION_WEMO // Enable Belkin WeMo emulation for Alexa (+6k code, +2k mem common)

View File

@ -56,6 +56,12 @@ const char HTTP_HEAD[] PROGMEM =
"<script>"
"var x=null,lt,to,tp,pc='';" // x=null allow for abortion
#ifdef USE_JAVASCRIPT_ES6
// Following bytes saving ES6 syntax fails on old browsers like IE 11 - https://kangax.github.io/compat-table/es6/
"eb=s=>document.getElementById(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
#else
"function eb(s){"
"return document.getElementById(s);" // Alias to save code space
"}"
@ -65,10 +71,7 @@ const char HTTP_HEAD[] PROGMEM =
"function sp(i){" // Toggle password visibility
"eb(i).type=(eb(i).type==='text'?'password':'text');"
"}"
// Following bytes saving ES6 syntax fails on old browsers like IE 11 - https://kangax.github.io/compat-table/es6/
// "eb=s=>document.getElementById(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
#endif
// https://www.htmlgoodies.com/beyond/javascript/article.php/3724571/Using-Multiple-JavaScript-Onload-Functions.htm
"function wl(f){" // Execute multiple window.onload