From 3e1e565dffad1fe48e7e3f9fb35e44a358d7bad2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 4 Mar 2019 12:36:44 +0100 Subject: [PATCH] Update xdrv_01_webserver.ino Fix webpage redirect --- sonoff/xdrv_01_webserver.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 6070d8ac8..cbd52ccee 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -84,7 +84,7 @@ const char HTTP_SCRIPT_ROOT[] PROGMEM = "eb('l1').innerHTML=s;" "}" "};" - "x.open('GET','?m=1'+a,true);" // ?m related to WebServer->hasArg("m") + "x.open('GET','.?m=1'+a,true);" // ?m related to WebServer->hasArg("m") "x.send();" "lt=setTimeout(la,{a});" // Settings.web_refresh "}" @@ -103,13 +103,11 @@ const char HTTP_SCRIPT_WIFI[] PROGMEM = "}"; const char HTTP_SCRIPT_RELOAD[] PROGMEM = - "setTimeout(function(){location.href='.';}," STR(HTTP_RESTART_RECONNECT_TIME) ");" - ""; + "setTimeout(function(){location.href='.';}," STR(HTTP_RESTART_RECONNECT_TIME) ");"; // Local OTA upgrade requires more time to complete cp: before web ui should be reloaded const char HTTP_SCRIPT_RELOAD_OTA[] PROGMEM = - "setTimeout(function(){location.href='.';}," STR(HTTP_OTA_RESTART_RECONNECT_TIME) ");" - ""; + "setTimeout(function(){location.href='.';}," STR(HTTP_OTA_RESTART_RECONNECT_TIME) ");"; const char HTTP_SCRIPT_CONSOL[] PROGMEM = "var sn=0;" // Scroll position @@ -348,7 +346,7 @@ const char HTTP_FORM_WIFI[] PROGMEM = "

" D_AP1_PASSWORD "

" "

" D_AP2_SSID " (" STA_SSID2 ")

" "

" D_AP2_PASSWORD "

" - "

" D_HOSTNAME " (" WIFI_HOSTNAME ")

"; + "

" D_HOSTNAME " (" WIFI_HOSTNAME ")

"; const char HTTP_FORM_LOG1[] PROGMEM = "
 " D_LOGGING_PARAMETERS " " @@ -661,6 +659,7 @@ void WebRestart(uint8_t type) AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART); String page = FPSTR(HTTP_HEAD); + page += FPSTR(HTTP_SCRIPT_RELOAD); page += FPSTR(HTTP_HEAD_STYLE); if (type) { @@ -683,7 +682,6 @@ void WebRestart(uint8_t type) } else { page += FPSTR(HTTP_BTN_MAIN); } - page.replace(F(""), FPSTR(HTTP_SCRIPT_RELOAD)); ShowPage(page, !reset_only); ShowWebSource(SRC_WEBGUI); @@ -1705,11 +1703,11 @@ void HandleUpgradeFirmwareStart(void) String page = FPSTR(HTTP_HEAD); page.replace(F("{v}"), FPSTR(S_INFORMATION)); + page += FPSTR(HTTP_SCRIPT_RELOAD_OTA); page += FPSTR(HTTP_HEAD_STYLE); page += F("
" D_UPGRADE_STARTED " ...
"); page += FPSTR(HTTP_MSG_RSTRT); page += FPSTR(HTTP_BTN_MAIN); - page.replace(F(""), FPSTR(HTTP_SCRIPT_RELOAD_OTA)); ShowPage(page); snprintf_P(command, sizeof(command), PSTR(D_CMND_UPGRADE " 1")); @@ -1730,6 +1728,9 @@ void HandleUploadDone(void) String page = FPSTR(HTTP_HEAD); page.replace(F("{v}"), FPSTR(S_INFORMATION)); + if (!upload_error) { + page += FPSTR(HTTP_SCRIPT_RELOAD_OTA); // Refesh main web ui after OTA upgrade + } page += FPSTR(HTTP_HEAD_STYLE); page += F("
" D_UPLOAD " " D_SUCCESSFUL "
"); page += FPSTR(HTTP_MSG_RSTRT); - page.replace(F(""), FPSTR(HTTP_SCRIPT_RELOAD_OTA)); // Refesh main web ui after OTA upgrade ShowWebSource(SRC_WEBGUI); restart_flag = 2; // Always restart to re-enable disabled features during update }