edited README.md

master
David Zálešák 4 years ago
parent fb8bc31204
commit 5340a0fae2

@ -14,7 +14,7 @@ Toto lze nastavit v configu.
- [ ] JS app
- [ ] OTA update
- [x] API
- [ ] JS app
- [x] JS app
- [ ] v flash paměti
- [ ] aktualizace
- [x] OTA update

@ -43,81 +43,7 @@
<div class="git"><a href="https://git.microlab.space/pixx/ESP8266-termostat">Git</a></div>
</footer>
</main>
<script>
var reqTempUp = document.getElementById("tempUp")
var reqTempDown = document.getElementById("tempDown")
var offsetUp = document.getElementById("offsetUp")
var offsetDown = document.getElementById("offsetDown")
reqTempUp.addEventListener("click", function () {
set("increasereqtemp", 0.1)
})
reqTempDown.addEventListener("click", function () {
set("increasereqtemp", -0.1)
})
offsetUp.addEventListener("click", function () {
set("increaseoffset", 0.05)
})
offsetDown.addEventListener("click", function () {
set("increaseoffset", -0.05)
})
function set(co, jak) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
if (co == "increasereqtemp") {
document.getElementById("reqTemp").innerHTML =
this.responseText;
} else if (co == "increaseoffset") {
document.getElementById("offset").innerHTML =
this.responseText;
}
}
};
xhttp.open("GET", "http://10.22.128.209/set?" + co + "=" + jak, true);
xhttp.send();
}
function get(x, y) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
if (x == "relay" && this.responseText == "1") {
document.getElementById("actual-state").innerHTML =
"Topí";
document.getElementById("actual-state").classList.add("topi");
document.getElementById("actual-state-img").src =
"img/topi.svg"
} else if (x == "relay" && this.responseText == "0") {
document.getElementById("actual-state").innerHTML =
"Netopí";
document.getElementById("actual-state").classList.remove("topi");
document.getElementById("actual-state-img").src =
"img/netopi.svg"
} else {
document.getElementById(y).innerHTML =
this.responseText;
}
}
};
xhttp.open("GET", "http://10.22.128.209/get?" + x, true);
xhttp.send();
}
get("temp", "temp");
get("reqtemp", "reqTemp");
get("offset", "offset");
get("relay", "relay");
const interval = setInterval(function () {
get("temp", "temp");
get("reqtemp", "reqTemp");
get("offset", "offset");
get("relay", "relay");
}, 5000);
</script>
<script src="script.js"></script>
</body>
</html>

@ -0,0 +1,64 @@
var reqTempUp = document.getElementById("tempUp");
var reqTempDown = document.getElementById("tempDown");
var offsetUp = document.getElementById("offsetUp");
var offsetDown = document.getElementById("offsetDown");
reqTempUp.addEventListener("click", function () {
set("increasereqtemp", 0.1);
});
reqTempDown.addEventListener("click", function () {
set("increasereqtemp", -0.1);
});
offsetUp.addEventListener("click", function () {
set("increaseoffset", 0.05);
});
offsetDown.addEventListener("click", function () {
set("increaseoffset", -0.05);
});
function set(co, jak) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
if (co == "increasereqtemp") {
document.getElementById("reqTemp").innerHTML = this.responseText;
} else if (co == "increaseoffset") {
document.getElementById("offset").innerHTML = this.responseText;
}
}
};
xhttp.open("GET", "http://10.22.128.209/set?" + co + "=" + jak, true);
xhttp.send();
}
function get(x, y) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
if (x == "relay" && this.responseText == "1") {
document.getElementById("actual-state").innerHTML = "Topí";
document.getElementById("actual-state").classList.add("topi");
document.getElementById("actual-state-img").src = "img/topi.svg";
} else if (x == "relay" && this.responseText == "0") {
document.getElementById("actual-state").innerHTML = "Netopí";
document.getElementById("actual-state").classList.remove("topi");
document.getElementById("actual-state-img").src = "img/netopi.svg";
} else {
document.getElementById(y).innerHTML = this.responseText;
}
}
};
xhttp.open("GET", "http://10.22.128.209/get?" + x, true);
xhttp.send();
}
get("temp", "temp");
get("reqtemp", "reqTemp");
get("offset", "offset");
get("relay", "relay");
const interval = setInterval(function () {
get("temp", "temp");
get("reqtemp", "reqTemp");
get("offset", "offset");
get("relay", "relay");
}, 5000);