Browse Source

minor design corrections

fix onkeyup / onchange event while typing / copying serial number to setup
pull/361/head^2
lumapu 2 years ago
parent
commit
1a57b23f5b
  1. 3
      tools/esp8266/app.cpp
  2. 2
      tools/esp8266/html/api.js
  3. 53
      tools/esp8266/html/setup.html
  4. 12
      tools/esp8266/html/style.css

3
tools/esp8266/app.cpp

@ -895,6 +895,7 @@ void app::setupMqtt(void) {
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void app::resetPayload(Inverter<>* iv) { void app::resetPayload(Inverter<>* iv) {
DPRINTLN(DBG_INFO, "resetPayload: id: " + String(iv->id)); DPRINTLN(DBG_INFO, "resetPayload: id: " + String(iv->id));
@ -907,6 +908,8 @@ void app::resetPayload(Inverter<>* iv) {
mPayload[iv->id].ts = mUtcTimestamp; mPayload[iv->id].ts = mUtcTimestamp;
} }
//-----------------------------------------------------------------------------
void app::calculateSunriseSunset() { void app::calculateSunriseSunset() {
// Source: https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth // Source: https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth

2
tools/esp8266/html/api.js

@ -27,7 +27,7 @@ function parseVersion(obj) {
); );
} }
function toggle(id, hide) { function setHide(id, hide) {
var elm = document.getElementById(id); var elm = document.getElementById(id);
if(hide) { if(hide) {
if(!elm.classList.contains("hide")) if(!elm.classList.contains("hide"))

53
tools/esp8266/html/setup.html

@ -62,7 +62,7 @@
<fieldset> <fieldset>
<legend class="des">Inverter</legend> <legend class="des">Inverter</legend>
<div id="inverter"></div><br/> <div id="inverter"></div><br/>
<input type="button" id="btnAdd" value="Add Inverter"/> <input type="button" id="btnAdd" class="btn" value="Add Inverter"/>
<p class="subdes">General</p> <p class="subdes">General</p>
<label for="invInterval">Interval [s]</label> <label for="invInterval">Interval [s]</label>
<input type="text" class="text" name="invInterval"/> <input type="text" class="text" name="invInterval"/>
@ -229,13 +229,14 @@
var e = document.getElementsByName(id + "Addr")[0]; var e = document.getElementsByName(id + "Addr")[0];
e.value = ""; e.value = "";
e.dispatchEvent(new Event("keyup")); e.dispatchEvent(new Event("keyup"));
e.dispatchEvent(new Event("change"));
document.getElementsByName(id + "Name")[0].value = ""; document.getElementsByName(id + "Name")[0].value = "";
} }
function ivHtml(obj, id) { function ivHtml(obj, id) {
highestId = id; highestId = id;
if(highestId == (maxInv - 1)) if(highestId == (maxInv - 1))
toggle("btnAdd", true); setHide("btnAdd", true);
iv = document.getElementById("inverter"); iv = document.getElementById("inverter");
iv.appendChild(des("Inverter " + id)); iv.appendChild(des("Inverter " + id));
id = "inv" + id; id = "inv" + id;
@ -244,28 +245,32 @@
iv.appendChild(lbl(id + "Addr", "Address*")); iv.appendChild(lbl(id + "Addr", "Address*"));
var addr = inp(id + "Addr", obj["serial"], 12) var addr = inp(id + "Addr", obj["serial"], 12)
iv.appendChild(addr); iv.appendChild(addr);
addr.addEventListener("keyup", (e) => { ['keyup', 'change'].forEach(function(evt) {
var serial = addr.value.substring(0,4);
var max = 0; addr.addEventListener(evt, (e) => {
for(var i=0;i<4;i++) { var serial = addr.value.substring(0,4);
toggle(id+"ModPwr"+i, true); var max = 0;
toggle(id+"ModName"+i, true); for(var i=0;i<4;i++) {
} setHide(id+"ModPwr"+i, true);
toggle("lbl"+id+"ModPwr", true); setHide(id+"ModName"+i, true);
toggle("lbl"+id+"ModName", true); }
setHide("lbl"+id+"ModPwr", true);
if(serial == "1161") max = 4; setHide("lbl"+id+"ModName", true);
else if(serial == "1141") max = 2;
else if(serial == "1121") max = 1; if(serial === "1161") max = 4;
else if(serial === "1141") max = 2;
for(var i=0;i<max;i++) { else if(serial === "1121") max = 1;
toggle(id+"ModPwr"+i, false); else max = 0;
toggle(id+"ModName"+i, false);
} if(max != 0) {
if(max != 0) { for(var i=0;i<max;i++) {
toggle("lbl"+id+"ModPwr", false); setHide(id+"ModPwr"+i, false);
toggle("lbl"+id+"ModName", false); setHide(id+"ModName"+i, false);
} }
setHide("lbl"+id+"ModPwr", false);
setHide("lbl"+id+"ModName", false);
}
})
}); });
for(var i of [["Name", "name", "Name*", 32]]) { for(var i of [["Name", "name", "Name*", 32]]) {

12
tools/esp8266/html/style.css

@ -39,7 +39,7 @@ h2 {
} }
.topnav a:hover { .topnav a:hover {
background-color: #555 !important; background-color: #044e86 !important;
color: #000; color: #000;
} }
@ -60,13 +60,13 @@ h2 {
} }
.topnav .active { .topnav .active {
background-color: #00afc1; background-color: #555;
} }
span.seperator { span.seperator {
width: 100%; width: 100%;
height: 1px; height: 1px;
margin: 10px 0px 10px; margin: 5px 0px 5px;
background-color: #494949; background-color: #494949;
display: block; display: block;
} }
@ -170,7 +170,7 @@ p.lic, p.lic a {
} }
.s_active, .s_collapsible:hover { .s_active, .s_collapsible:hover {
background-color: #006ec0; background-color: #044e86;
color: #fff; color: #fff;
} }
@ -180,7 +180,7 @@ p.lic, p.lic a {
} }
.s_collapsible { .s_collapsible {
background-color: #044e86; background-color: #006ec0;
color: white; color: white;
cursor: pointer; cursor: pointer;
padding: 18px; padding: 18px;
@ -222,7 +222,7 @@ a.btn {
} }
a.btn:hover { a.btn:hover {
background-color: #555 !important; background-color: #044e86 !important;
} }
input, select { input, select {

Loading…
Cancel
Save