Skip to content

Commit

Permalink
Merge commit 'd39e2ebce8a9e7ddb64ca8e8060bbdbe2d9123a8' as 'software/…
Browse files Browse the repository at this point in the history
…NRG_itho_wifi'
  • Loading branch information
arjenhiemstra committed Apr 11, 2020
2 parents 3116f40 + d39e2eb commit fe41baf
Show file tree
Hide file tree
Showing 16 changed files with 2,772 additions and 0 deletions.
462 changes: 462 additions & 0 deletions software/NRG_itho_wifi/01_Statics.ino

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions software/NRG_itho_wifi/02_HTML.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

const char html_mainpage[] PROGMEM = R"=====(
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A layout example with a side menu that hides on mobile, just like the Pure website.">
<title>Itho WiFi controller &ndash; System setup</title>
<script src="/js/zepto.min.js"></script>
<script src="/js/controls.js"></script>
<link rel="stylesheet" href="pure-min.css">
</head>
<body>
<div id="layout">
<div id="message_box"></div>
<!-- Menu toggle -->
<a href="#menu" id="menuLink" class="menu-link">
<!-- Hamburger icon -->
<span></span>
</a>
<div id="menu">
<div class="pure-menu">
<a class="pure-menu-heading" id="headingindex" href="index">Itho WiFi controller</a>
<ul class="pure-menu-list">
<li class="pure-menu-item"><a href="wifisetup" class="pure-menu-link">Wifi setup</a></li>
<li class="pure-menu-item"><a href="mqtt" class="pure-menu-link">MQTT</a></li>
<li class="pure-menu-item"><a href="help" class="pure-menu-link">Help</a></li>
<li class="pure-menu-item"><a href="update" class="pure-menu-link">Update</a></li>
<li class="pure-menu-item"><a href="reset" class="pure-menu-link">Reset</a></li>
<li class="pure-menu-item"><a href="debug" class="pure-menu-link">Debug</a></li>
</ul>
<div id="memory_box"></div>
</div>
</div>
<div id="main">
</div>
</div>
</body>
<script src="/js/general.js"></script>
</html>
)=====";


void handleMainpage(AsyncWebServerRequest *request) {
request->send_P(200, "text/html", html_mainpage);
}

void handleDebug(AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("text/html");

response->print("<div class=\"header\"><h1>Debug page</h1></div><br><br>");
response->print("<div>Firmware version: ");
response->print(FWVERSION);
response->print("<br><br>Config version: ");
response->print(CONFIG_VERSION);
response->print("</vid>");

request->send(response);
}
8 changes: 8 additions & 0 deletions software/NRG_itho_wifi/03_CSS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


void css_code(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", pure_min_css_gz, pure_min_css_gz_len);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}

28 changes: 28 additions & 0 deletions software/NRG_itho_wifi/04_JS_UI.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

void zepto_min_js_gz_code(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse_P(200, "application/javascript", zepto_min_js_gz, zepto_min_js_gz_len);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
}

void handleGeneralJs(AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("application/javascript");
response->addHeader("Server","Project WiFi Web Server");

response->print("var on_ap = false; var hostname = '");
response->print(EspHostname());
response->print("'; $(document).ready(function() { $('#headingindex').text(hostname); $('#headingindex').attr('href', 'http://' + hostname + '.local'); $('#main').append(html_index); });");

request->send(response);
}

void handleGeneralJsOnAp(AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("application/javascript");
response->addHeader("Server","Project WiFi Web Server");

response->print("var on_ap = true; var hostname = '");
response->print(EspHostname());
response->print("'; $(document).ready(function() { $('#headingindex').text(hostname); $('#headingindex').attr('href', 'http://' + hostname + '.local'); $('#main').append(html_wifisetup); });");

request->send(response);
}
Loading

0 comments on commit fe41baf

Please sign in to comment.