2024-01-16 16:39:30 +02:00

61 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #ffffff;
}
</style>
<title>ESP Captive Portal</title>
</head>
<body>
<h1>ESP Captive Portal</h1>
<p>Hello World, this is ESP32!</p>
<form action="/configure" method="post" id="submit_form">
</form>
<script>
async function getParameterFields() {
const response = await fetch("parameters", {
method: "GET",
})
return response.json();
}
async function populateSubmitForm(form_root) {
const data = await getParameterFields();
for (let param of data) {
let input = document.createElement("input");
input.setAttribute("id", param.nvs_name);
input.setAttribute("name", param.nvs_name);
if (param.type === 0 || param.type === 1) {
input.setAttribute("type", "number");
} else {
input.setAttribute("type", "text");
}
let label = document.createElement("label");
label.setAttribute("for", param.nvs_name);
label.innerHTML = param.name + ":";
form_root.appendChild(label);
form_root.appendChild(document.createElement("br"));
form_root.appendChild(input);
form_root.appendChild(document.createElement("br"));
}
let submit = document.createElement("input");
submit.setAttribute("type", "submit");
submit.setAttribute("value", "Configure");
form_root.appendChild(submit);
}
populateSubmitForm(document.getElementById("submit_form"));
</script>
</body>
</html>