Skip to content

Commit fe0190d

Browse files
committed
improved restart behavior
1 parent 4550909 commit fe0190d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Arduino/Open_IOT_Okai/Open_IOT_Okai.ino

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,12 @@ void goHome()
224224
}
225225

226226
String SendHTML(){
227-
String page = "<!DOCTYPE html> <html>\n";
228-
page +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
229-
page +="<title>Scooter Control</title>\n";
230-
page +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
231-
page +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}#status {font-size: 36px;}\n";
227+
String page = "<!DOCTYPE html>\n";
228+
page += "<html>\n";
229+
page += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
230+
page += "<title>Scooter Config</title>\n";
231+
page += "<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
232+
page += "body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}#status {font-size: 36px;}\n";
232233
page += ".button {display: block;width: 120px;background-color: #1abc9c;border: none;color: white;padding: 13px 30px;";
233234
page += "text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
234235
page += ".button2 {display: inline;width: 100px;background-color: #1abc9c;border: none;color: white;padding: 13px 30px;";
@@ -280,6 +281,7 @@ String SendRestart(){
280281
page +="<small style='vertical-align: super;'>"+WiFi.localIP().toString()+" | "+WiFi.softAPIP().toString()+"</small>\n";
281282
page += "<script>\n";
282283
page += "var numFailures = 0;\n";
284+
page += "var timer;\n";
283285
page +="function checkStatus()\n";
284286
page +="{\n";
285287
page +="var xhr = new XMLHttpRequest();\n";
@@ -293,6 +295,8 @@ String SendRestart(){
293295
page +=" if (xhr.status === 200) {\n";
294296
page +=" document.getElementById('status').style.color = 'green';\n";
295297
page += " window.location.href = '/';\n";
298+
page += " clearInterval(timer);\n";
299+
page += " document.getElementById('timer').innerHTML = '0';\n";
296300
page +=" }\n";
297301
page +=" else\n";
298302
page +=" {\n";
@@ -320,7 +324,7 @@ String SendRestart(){
320324
page += "\t\tcheckStatus();\n";
321325
page += "\t\t}\n";
322326
page += "\t}\n";
323-
page += "\tvar timer = setInterval(asecondhaspassed, 1000);\n";
327+
page += "\ttimer = setInterval(asecondhaspassed, 1000);\n";
324328
page += "</script>\n";
325329
page +="</body>\n";
326330

0 commit comments

Comments
 (0)