Browse Source

Merge pull request #330 from DanielR92/serial_dynamic-list

serial page list is now dynamic
pull/341/head
lumapu 2 years ago
committed by GitHub
parent
commit
67f99abdfc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      tools/esp8266/html/serial.html

30
tools/esp8266/html/serial.html

@ -11,7 +11,10 @@
<div id="content" class="content"> <div id="content" class="content">
<div class="serial"> <div class="serial">
<textarea id="serial" cols="80" rows="20" readonly></textarea><br/> <textarea id="serial" cols="80" rows="20" readonly></textarea><br/>
connected: <span class="dot" id="connected"></span> Uptime: <span id="uptime"></span><input type="button" value="clear" class="btn" id="clear"/> <input type="button" value="autoscroll" class="btn" id="scroll"/> connected: <span class="dot" id="connected"></span>
Uptime: <span id="uptime"></span>
<input type="button" value="clear" class="btn" id="clear"/>
<input type="button" value="autoscroll" class="btn" id="scroll"/>
<br/> <br/>
<br/> <br/>
@ -21,11 +24,7 @@
<h3>handle next buttons with care - test / debug only!!</h3> <h3>handle next buttons with care - test / debug only!!</h3>
<br/> <br/>
<label for="iv">Select Inverter:</label> <label for="iv">Select Inverter:</label>
<select name="iv" id="iv"> <select name="iv" id="InvID">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select> </select>
<br/> <br/>
<input type="button" value="power limit 100%" class="btn" id="pwrlim2"/> <input type="button" value="power limit 100%" class="btn" id="pwrlim2"/>
@ -65,6 +64,21 @@
} }
} }
function parse(root) {
select = document.getElementById('InvID');
if(null == root) return;
root = root.inverter;
for(var i = 0; i < root.inverter.length; i++)
{
inv = root.inverter[i];
var opt = document.createElement('option');
opt.value = inv.id;
opt.innerHTML = inv.name;
select.appendChild(opt);
}
}
document.getElementById("clear").addEventListener("click", function() { document.getElementById("clear").addEventListener("click", function() {
con.value = ""; con.value = "";
}); });
@ -105,7 +119,7 @@
function get_selected_iv() function get_selected_iv()
{ {
var e = document.getElementById("iv"); var e = document.getElementById("InvID");
return e.value; return e.value;
} }
@ -150,6 +164,8 @@
obj.payload = [2000, 1]; obj.payload = [2000, 1];
getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj)); getAjax("/api/ctrl", ctrlCb, "POST", JSON.stringify(obj));
}); });
getAjax("/api/setup", parse);
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save