Skip to content

Commit

Permalink
Merge pull request #7 from GwangrokBaek/master
Browse files Browse the repository at this point in the history
로딩중 에러 해결 및 종류 변경
  • Loading branch information
GwangrokBaek committed Aug 13, 2021
2 parents fc3277e + 9e5be7a commit e0947d7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 27 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions tasmota/html_uncompressed/HTTP_SCRIPT_ROOT_WEB_DISPLAY.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const char HTTP_SCRIPT_ROOT[] PROGMEM =
".replace(/{m}/g,\"</th><td style='width:20px;white-space:nowrap'>\")" // I want a right justified column with left justified text
".replace(/{e}/g,\"</td></tr>\");"
"eb('l1').innerHTML=s;"
"if(s.indexOf(\"{loader}\") != -1){"
"eb('loader').style.display=\"\";"
"} else {eb('loader').style.display=\"none\";}"
"clearTimeout(ft);clearTimeout(lt);"
"if(rfsh){"
"lt=setTimeout(la,%d);" // Settings.web_refresh
Expand Down
96 changes: 69 additions & 27 deletions tasmota/xdrv_01_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,57 @@ const uint16_t HTTP_OTA_RESTART_RECONNECT_TIME = 10000; // milliseconds - Allow
#include <ESP8266WebServer.h>
#include <DNSServer.h>

const char HTTP_SCRIPT_ROOT2[] PROGMEM =
"var rfsh=1,ft;"
"function la(p){"
"a=p||'';"
"clearTimeout(ft);clearTimeout(lt);"
"if(x!=null){x.abort();}" // Abort if no response within 2 seconds (happens on restart 1)
"x=new XMLHttpRequest();"
"x.onreadystatechange=function(){"
"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(/{m}/g,\"</th><td style='width:20px;white-space:nowrap'>\")" // I want a right justified column with left justified text
".replace(/{e}/g,\"</td></tr>\");"
"eb('l1').innerHTML=s;"
"if(s.indexOf(\"{loader}\") != -1){"
"eb('loader').style.display=\"\";"
"} else {eb('loader').style.display=\"none\";}"
"clearTimeout(ft);clearTimeout(lt);"
"if(rfsh){"
"lt=setTimeout(la,%d);" // Settings.web_refresh
"}"
"}"
"};"
"if(rfsh){"
"x.open('GET','.?m=1'+a,true);" // ?m related to Webserver->hasArg("m")
"x.send();"
"ft=setTimeout(la,20000);" // 20s failure timeout
"}"
"}"
"function seva(par,ivar){"
"la('&sv='+ivar+'_'+par);"
"}"
"function siva(par,ivar){"
"rfsh=1;"
"la('&sv='+ivar+'_'+par);"
"rfsh=0;"
"}"
"function pr(f){"
"if(f){"
"clearTimeout(lt);clearTimeout(ft);"
"lt=setTimeout(la,%d);"
"rfsh=1;"
"}else{"
"clearTimeout(lt);clearTimeout(ft);"
"rfsh=0;"
"}"
"}"
;


#ifdef USE_UNISHOX_COMPRESSION
#ifdef USE_JAVASCRIPT_ES6
#include "./html_compressed/HTTP_HEADER1_ES6.h"
Expand Down Expand Up @@ -199,15 +250,6 @@ const char HTTP_SCRIPT_INFO_END[] PROGMEM =
"}"
"wl(i);";

const char HTTP_SCRIPT_LOADER[] PROGMEM =
"<style>function _showPage(show){"
"if(show != 1){"
"var loader = $(\"div.loader\");"
"loader.css(\"display\",\"none\");}"
"else{"
"var loader = $(\"div.loader\");"
"loader.css(\"display\",\"block\");}};</style>";

#ifdef USE_UNISHOX_COMPRESSION
#include "./html_compressed/HTTP_HEAD_LAST_SCRIPT.h"
#include "./html_compressed/HTTP_HEAD_STYLE1.h"
Expand Down Expand Up @@ -236,16 +278,15 @@ const char HTTP_HEAD_STYLE_SSI[] PROGMEM =
".si .b0{height:25%%}.si .b1{height:50%%}.si .b2{height:75%%}.si .b3{height:100%%}.o30{opacity:.3}";

const char HTTP_HEAD_STYLE_LOADER[] PROGMEM =
".loader{margin:auto;"
"border: 5px solid #31353c; border-radius:50%%; border-top:5px solid #ffa400; width:40px; height:40px;"
"-webkit-animation: spin 1.4s linear infinite;"
"animation: spin 1.4s linear infinite;}"
"@-webkit-keyframes spin{"
"0%% {-webkit-transform: rotate(0deg);}"
"100%% {-webkit-transform: rotate(360deg);}}"
"@keyframes spin{"
"0%% {transform:rotate(0deg);}"
"100%% {transform:rotate(360deg);}}";
"#loader, #loader:before, #loader:after {border-radius: 50%%;width: 1.5em;height: 1.5em;-webkit-animation-fill-mode: both;"
"animation-fill-mode: both;-webkit-animation: load7 1.8s infinite ease-in-out;animation: load7 1.5s infinite ease-in-out;}"
"#loader {color: #ffa400;font-size: 10px;margin: auto;margin-bottom:2rem;position: relative;text-indent: -9999em;"
"-webkit-transform: translateZ(0);-ms-transform: translateZ(0);transform: translateZ(0);-webkit-animation-delay: -0.16s;animation-delay: -0.16s;}"
"#loader:before,#loader:after {content: '';position: absolute;top: 0;}"
"#loader:before {left: -3.5em;-webkit-animation-delay: -0.32s;animation-delay: -0.32s;}"
"#loader:after {left: 3.5em;}"
"@-webkit-keyframes load7 {0%%,80%%,100%% {box-shadow: 0 2.5em 0 -1.3em;}40%% {box-shadow: 0 2.5em 0 0;}}"
"@keyframes load7 {0%%,80%%,100%% {box-shadow: 0 2.5em 0 -1.3em;}40%% {box-shadow: 0 2.5em 0 0;}}";

const char HTTP_HEAD_STYLE3[] PROGMEM =
"</style>"
Expand Down Expand Up @@ -1067,16 +1108,15 @@ void HandleRoot(void)

WSContentStart_P(PSTR(D_MAIN_MENU));
#ifdef USE_SCRIPT_WEB_DISPLAY
WSContentSend_P(HTTP_SCRIPT_ROOT, Settings->web_refresh, Settings->web_refresh);
WSContentSend_P(HTTP_SCRIPT_ROOT2, Settings->web_refresh, Settings->web_refresh);
#else
WSContentSend_P(HTTP_SCRIPT_ROOT, Settings->web_refresh);
WSContentSend_P(HTTP_SCRIPT_ROOT2, Settings->web_refresh);
#endif
WSContentSend_P(HTTP_SCRIPT_ROOT_PART2);

WSContentSendStyle();
WSContentSend_P(HTTP_SCRIPT_LOADER);
WSContentSend_P("<div class=\"loader\"></div>");
WSContentSend_P("<br>");
WSContentSend_P("<div id=\"loader\" style='padding:0'></div>");
WSContentSend_P("</br>");

WSContentSend_P(PSTR("<div style='padding:0;' id='l1' name='l1'></div>"));

Expand Down Expand Up @@ -1109,10 +1149,12 @@ bool HandleRootStatusRefresh(void)
#endif

WSContentSend_P(PSTR("{t}<tr>"));
WSContentSend_P(HTTP_DEVICE_STATE, 40, PSTR("normal"), 17, TasmotaGlobal.mqtt_connected ? "홈 IoT 서비스가 동작 중입니다.":"홈 IoT 서비스에 연결 중입니다...");
WSContentSend_P(PSTR("</tr></table>"));
WSContentSend_P(HTTP_DEVICE_STATE, 40, PSTR("normal"), 17, TasmotaGlobal.mqtt_connected ? "홈 IoT 서비스가 동작 중입니다.":"홈 IoT 서비스에 연결중입니다..");
WSContentSend_P(PSTR("</tr></table></br>"));
WSContentSend_P(PSTR("\n\n")); // Prep for SSE
WSContentSend_P(PSTR("<script>_showPage(%s);</script>"), TasmotaGlobal.mqtt_connected);
if (!TasmotaGlobal.mqtt_connected) {
WSContentSend_P("<div style='display:none'>{loader}</div>");
}
WSContentEnd();

return true;
Expand Down

0 comments on commit e0947d7

Please sign in to comment.