Browse Source

webserver cleaning

prepend all web server pages with web_ instead of pages_ for better
readability
Etienne Landon 9 years ago
parent
commit
40d5d2ae95
10 changed files with 167 additions and 169 deletions
  1. 7 9
      functions.h
  2. 9 9
      includes.h
  3. 34 34
      Page_Admin.h
  4. 3 3
      Page_General.h
  5. 4 4
      Page_Information.h
  6. 3 3
      Page_NTPSettings.h
  7. 5 5
      PAGE_NetworkConfiguration.h
  8. 3 3
      Page_Root.h
  9. 31 31
      Page_Script.js.h
  10. 68 68
      Page_Style.css.h

+ 7 - 9
functions.h

@@ -7,6 +7,7 @@ void ledBlink (int Led, int blink_qty, int blink_time) {
     digitalWrite(Led, HIGH);
     delay(blink_time);
   }
+}
   
   void startESP() {
   EEPROM.begin(512);
@@ -20,9 +21,6 @@ void ledBlink (int Led, int blink_qty, int blink_time) {
 }
 
 
-   
-}
-
 void setupWifi(){
   if (!ReadConfig())  {
     // DEFAULT CONFIG
@@ -75,14 +73,14 @@ void setupWifi(){
 }
 
 void setupWebserver(){
-  server.on ( "/", []() {digitalWrite(Blue_Led, LOW); Serial.println("admin.html"); server.send ( 200, "text/html", PAGE_AdminMainPage ); digitalWrite(Blue_Led, HIGH);  }  );
-  server.on ( "/admin.html", []() {digitalWrite(Blue_Led, LOW); Serial.println("admin.html"); server.send ( 200, "text/html", PAGE_AdminMainPage ); digitalWrite(Blue_Led, HIGH);  }  );
+  server.on ( "/", []() {digitalWrite(Blue_Led, LOW); Serial.println("admin.html"); server.send ( 200, "text/html", web_AdminMainPage ); digitalWrite(Blue_Led, HIGH);  }  );
+  server.on ( "/admin.html", []() {digitalWrite(Blue_Led, LOW); Serial.println("admin.html"); server.send ( 200, "text/html", web_AdminMainPage ); digitalWrite(Blue_Led, HIGH);  }  );
   server.on ( "/config.html", send_network_configuration_html );
-  server.on ( "/info.html", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("info.html"); server.send ( 200, "text/html", PAGE_Information ); digitalWrite(Blue_Led, HIGH) ; }  );
+  server.on ( "/info.html", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("info.html"); server.send ( 200, "text/html", web_Information ); digitalWrite(Blue_Led, HIGH) ; }  );
   server.on ( "/ntp.html", send_NTP_configuration_html  );
   server.on ( "/general.html",  send_general_html );
-  server.on ( "/style.css", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("style.css"); server.send ( 200, "text/plain", PAGE_Style_css ); digitalWrite(Blue_Led, HIGH) ; } );
-  server.on ( "/microajax.js", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("microajax.js"); server.send ( 200, "text/plain", PAGE_microajax_js ); digitalWrite(Blue_Led, HIGH); } );
+  server.on ( "/style.css", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("style.css"); server.send ( 200, "text/plain", web_Style_css ); digitalWrite(Blue_Led, HIGH) ; } );
+  server.on ( "/microajax.js", []() { digitalWrite(Blue_Led, LOW) ; Serial.println("microajax.js"); server.send ( 200, "text/plain", web_microajax_js ); digitalWrite(Blue_Led, HIGH); } );
   server.on ( "/admin/values", send_network_configuration_values_html );
   server.on ( "/admin/connectionstate", send_connection_state_values_html );
   server.on ( "/admin/infovalues", send_information_values_html );
@@ -194,4 +192,4 @@ void loopHandles(){
 }
 
 
-
+

+ 9 - 9
includes.h

@@ -28,19 +28,19 @@ WiFiUDP UKI_UDP;
 /*
   Include the HTML, STYLE and Script "Pages"
 */
-#include "Page_Root.h"
-#include "Page_Admin.h"
-#include "Page_Script.js.h"
-#include "Page_Style.css.h"
-#include "Page_NTPSettings.h"
-#include "Page_Information.h"
-#include "Page_General.h"
-#include "PAGE_NetworkConfiguration.h"
+#include "web_Root.h"
+#include "web_Admin.h"
+#include "web_Script.js.h"
+#include "web_Style.css.h"
+#include "web_NTPSettings.h"
+#include "web_Information.h"
+#include "web_General.h"
+#include "web_NetworkConfiguration.h"
 
+#include "functions.h"
 
 
 
 
-#include "functions.h"
 
 

+ 34 - 34
Page_Admin.h

@@ -1,34 +1,34 @@
-
-
-//
-//  HTML PAGE
-//
-
-const char PAGE_AdminMainPage[] PROGMEM = R"=====(
-<meta name="viewport" content="width=device-width, initial-scale=1" />
-<strong>Administration</strong>
-<hr>
-<a href="general.html" style="width:250px" class="btn btn--m btn--blue" >General Configuration</a><br>
-<a href="config.html" style="width:250px" class="btn btn--m btn--blue" >Network Configuration</a><br>
-<a href="info.html"   style="width:250px"  class="btn btn--m btn--blue" >Network Information</a><br>
-<a href="ntp.html"   style="width:250px"  class="btn btn--m btn--blue" >NTP Settings</a><br>
-
-
-<script>
-window.onload = function ()
-{
-	load("style.css","css", function() 
-	{
-		load("microajax.js","js", function() 
-		{
-				// Do something after load...
-		});
-	});
-}
-function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}else if("css"==t){var a=document.createElement("link");a.href=e,a.rel="stylesheet",a.type="text/css",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}}
-
-</script>
-
-)=====";
-
-
+
+
+//
+//  HTML PAGE
+//
+
+const char web_AdminMainPage[] PROGMEM = R"=====(
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<strong>Administration</strong>
+<hr>
+<a href="general.html" style="width:250px" class="btn btn--m btn--blue" >General Configuration</a><br>
+<a href="config.html" style="width:250px" class="btn btn--m btn--blue" >Network Configuration</a><br>
+<a href="info.html"   style="width:250px"  class="btn btn--m btn--blue" >Network Information</a><br>
+<a href="ntp.html"   style="width:250px"  class="btn btn--m btn--blue" >NTP Settings</a><br>
+
+
+<script>
+window.onload = function ()
+{
+	load("style.css","css", function() 
+	{
+		load("microajax.js","js", function() 
+		{
+				// Do something after load...
+		});
+	});
+}
+function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}else if("css"==t){var a=document.createElement("link");a.href=e,a.rel="stylesheet",a.type="text/css",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}}
+
+</script>
+
+)=====";
+
+

+ 3 - 3
Page_General.h

@@ -2,7 +2,7 @@
 //  HTML PAGE
 //
 
-const char PAGE_AdminGeneralSettings[] PROGMEM =  R"=====(
+const char web_AdminGeneralSettings[] PROGMEM =  R"=====(
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <a href="admin.html"  class="btn btn--s"><</a>&nbsp;&nbsp;<strong>General Settings</strong>
@@ -97,7 +97,7 @@ void send_general_html()
 		WriteConfig();
 		firstStart = true;
 	}
-	server.send ( 200, "text/html", PAGE_AdminGeneralSettings ); 
+	server.send ( 200, "text/html", web_AdminGeneralSettings ); 
 	Serial.println(__FUNCTION__); 
 	
 	digitalWrite(Blue_Led, HIGH);
@@ -117,4 +117,4 @@ void send_general_configuration_values_html()
 	server.send ( 200, "text/plain", values);
 	Serial.println(__FUNCTION__); 
   digitalWrite(Blue_Led, HIGH);
-}
+}

+ 4 - 4
Page_Information.h

@@ -1,11 +1,11 @@
-#ifndef PAGE_INFOMATION_H
-#define PAGE_INFOMATION_H
+#ifndef web_INFOMATION_H
+#define web_INFOMATION_H
 
 
 //
 //   The HTML PAGE
 //
-const char PAGE_Information[] PROGMEM = R"=====(
+const char web_Information[] PROGMEM = R"=====(
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" href="style.css" type="text/css" />
@@ -71,4 +71,4 @@ void send_information_values_html ()
 }
 
 
-#endif
+#endif

+ 3 - 3
Page_NTPSettings.h

@@ -1,5 +1,5 @@
 
-const char PAGE_NTPConfiguration[] PROGMEM = R"=====(
+const char web_NTPConfiguration[] PROGMEM = R"=====(
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <a href="admin.html"  class="btn btn--s"><</a>&nbsp;&nbsp;<strong>NTP Settings</strong>
@@ -88,7 +88,7 @@ void send_NTP_configuration_html()
 		WriteConfig();
 		firstStart = true;
 	}
-	server.send ( 200, "text/html", PAGE_NTPConfiguration ); 
+	server.send ( 200, "text/html", web_NTPConfiguration ); 
 	Serial.println(__FUNCTION__); 
 	digitalWrite(Blue_Led, HIGH);
 }
@@ -109,4 +109,4 @@ void send_NTP_configuration_values_html()
 	server.send ( 200, "text/plain", values);
 	Serial.println(__FUNCTION__); 
 	
-}
+}

+ 5 - 5
PAGE_NetworkConfiguration.h

@@ -3,7 +3,7 @@
 //
 //  HTML PAGE
 //
-const char PAGE_NetworkConfiguration[] PROGMEM = R"=====(
+const char web_NetworkConfiguration[] PROGMEM = R"=====(
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <a href="admin.html"  class="btn btn--s"><</a>&nbsp;&nbsp;<strong>Network Configuration</strong>
@@ -63,7 +63,7 @@ function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,
 
 )=====";
 
-const char PAGE_WaitAndReload[] PROGMEM = R"=====(
+const char web_WaitAndReload[] PROGMEM = R"=====(
 <meta http-equiv="refresh" content="5; URL=config.html">
 Please Wait....Configuring and Restarting.
 )=====";
@@ -97,7 +97,7 @@ void send_network_configuration_html()
 			if (server.argName(i) == "gw_3") if (checkRange(server.arg(i))) 	config.Gateway[3] =  server.arg(i).toInt();
 			if (server.argName(i) == "dhcp") config.dhcp = true;
 		}
-		 server.send ( 200, "text/html", PAGE_WaitAndReload );
+		 server.send ( 200, "text/html", web_WaitAndReload );
 		WriteConfig();
 		ConfigureWifi();
 		AdminTimeOutCounter=0;
@@ -105,7 +105,7 @@ void send_network_configuration_html()
 	}
 	else
 	{
-		server.send ( 200, "text/html", PAGE_NetworkConfiguration ); 
+		server.send ( 200, "text/html", web_NetworkConfiguration ); 
 	}
 	Serial.println(__FUNCTION__); 
   digitalWrite(Blue_Led, HIGH);
@@ -203,4 +203,4 @@ void send_connection_state_values_html()
 	server.send ( 200, "text/plain", values);
 	Serial.println(__FUNCTION__); 
 	digitalWrite(Blue_Led, HIGH);
-}
+}

+ 3 - 3
Page_Root.h

@@ -1,6 +1,6 @@
 
 
-const char PAGE_Root[] PROGMEM = R"=====(
+const char web_Root[] PROGMEM = R"=====(
 <!doctype html>
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <script src="microajax.js"></script> 
@@ -26,7 +26,7 @@ void sendRootPage()
             
         }
     }
-    server.send ( 200, "text/html", PAGE_Root ); 
+    server.send ( 200, "text/html", web_Root ); 
     digitalWrite(Blue_Led, HIGH);
 }
- 
+ 

File diff suppressed because it is too large
+ 31 - 31
Page_Script.js.h


+ 68 - 68
Page_Style.css.h

@@ -1,68 +1,68 @@
-
-const char PAGE_Style_css[] PROGMEM = R"=====(
-body { color: #000000; font-family: avenir, helvetica, arial, sans-serif;  letter-spacing: 0.15em;} 
-hr {    background-color: #eee;    border: 0 none;   color: #eee;    height: 1px; } 
-.btn, .btn:link, .btn:visited {  
-	border-radius: 0.3em;  
-	border-style: solid;  
-	border-width: 1px;  
-color: #111;  
-display: inline-block;  
-	font-family: avenir, helvetica, arial, sans-serif;  
-	letter-spacing: 0.15em;  
-	margin-bottom: 0.5em;  
-padding: 1em 0.75em;  
-	text-decoration: none;  
-	text-transform: uppercase;  
-	-webkit-transition: color 0.4s, background-color 0.4s, border 0.4s;  
-transition: color 0.4s, background-color 0.4s, border 0.4s; 
-} 
-.btn:hover, .btn:focus {
-color: #7FDBFF;  
-border: 1px solid #7FDBFF;  
-	-webkit-transition: background-color 0.3s, color 0.3s, border 0.3s;  
-transition: background-color 0.3s, color 0.3s, border 0.3s; 
-}
-	.btn:active {  
-color: #0074D9;  
-border: 1px solid #0074D9;  
-		-webkit-transition: background-color 0.3s, color 0.3s, border 0.3s;  
-transition: background-color 0.3s, color 0.3s, border 0.3s; 
-	} 
-	.btn--s 
-	{  
-		font-size: 12px; 
-	}
-	.btn--m { 
-		font-size: 14px; 
-	}
-	.btn--l {  
-		font-size: 20px;  border-radius: 0.25em !important; 
-	} 
-	.btn--full, .btn--full:link {
-		border-radius: 0.25em; 
-display: block;  
-			margin-left: auto; 
-			margin-right: auto; 
-			text-align: center; 
-width: 100%; 
-	} 
-	.btn--blue:link, .btn--blue:visited {
-color: #fff;  
-		background-color: #0074D9; 
-	}
-	.btn--blue:hover, .btn--blue:focus {
-color: #fff !important;  
-		background-color: #0063aa;  
-		border-color: #0063aa; 
-	}
-	.btn--blue:active {
-color: #fff; 
-		background-color: #001F3F;  border-color: #001F3F; 
-	}
-	@media screen and (min-width: 32em) {
-		.btn--full {  
-			max-width: 16em !important; } 
-	}
-)=====";
- 
+
+const char web_Style_css[] PROGMEM = R"=====(
+body { color: #000000; font-family: avenir, helvetica, arial, sans-serif;  letter-spacing: 0.15em;} 
+hr {    background-color: #eee;    border: 0 none;   color: #eee;    height: 1px; } 
+.btn, .btn:link, .btn:visited {  
+	border-radius: 0.3em;  
+	border-style: solid;  
+	border-width: 1px;  
+color: #111;  
+display: inline-block;  
+	font-family: avenir, helvetica, arial, sans-serif;  
+	letter-spacing: 0.15em;  
+	margin-bottom: 0.5em;  
+padding: 1em 0.75em;  
+	text-decoration: none;  
+	text-transform: uppercase;  
+	-webkit-transition: color 0.4s, background-color 0.4s, border 0.4s;  
+transition: color 0.4s, background-color 0.4s, border 0.4s; 
+} 
+.btn:hover, .btn:focus {
+color: #7FDBFF;  
+border: 1px solid #7FDBFF;  
+	-webkit-transition: background-color 0.3s, color 0.3s, border 0.3s;  
+transition: background-color 0.3s, color 0.3s, border 0.3s; 
+}
+	.btn:active {  
+color: #0074D9;  
+border: 1px solid #0074D9;  
+		-webkit-transition: background-color 0.3s, color 0.3s, border 0.3s;  
+transition: background-color 0.3s, color 0.3s, border 0.3s; 
+	} 
+	.btn--s 
+	{  
+		font-size: 12px; 
+	}
+	.btn--m { 
+		font-size: 14px; 
+	}
+	.btn--l {  
+		font-size: 20px;  border-radius: 0.25em !important; 
+	} 
+	.btn--full, .btn--full:link {
+		border-radius: 0.25em; 
+display: block;  
+			margin-left: auto; 
+			margin-right: auto; 
+			text-align: center; 
+width: 100%; 
+	} 
+	.btn--blue:link, .btn--blue:visited {
+color: #fff;  
+		background-color: #0074D9; 
+	}
+	.btn--blue:hover, .btn--blue:focus {
+color: #fff !important;  
+		background-color: #0063aa;  
+		border-color: #0063aa; 
+	}
+	.btn--blue:active {
+color: #fff; 
+		background-color: #001F3F;  border-color: #001F3F; 
+	}
+	@media screen and (min-width: 32em) {
+		.btn--full {  
+			max-width: 16em !important; } 
+	}
+)=====";
+