You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.6 KiB
HTML
123 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Termostat</title>
|
|
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
|
|
<body>
|
|
<main>
|
|
<header>
|
|
<div class="logo">
|
|
<img src="img/logo.svg" alt="Logo">
|
|
<h1>Termo<sub>stat</sub></h1>
|
|
</div>
|
|
<div class="state">
|
|
<span>Aktuální stav</span>
|
|
<div>
|
|
<span id="actual-state">Netopí</span>
|
|
<img id="actual-state-img" src="img/netopi.svg" alt="Stav - netopí">
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<section>
|
|
<h2>Požadovaná teplota</h2>
|
|
<div class="inputs">
|
|
<img id="tempUp" src="img/arrow_up.svg" alt="Zvýšit požadovanou teplotu">
|
|
<div id="reqTemp">0</div>
|
|
<img id="tempDown" src="img/arrow_down.svg" alt="Snížit požadovanou teplotu">
|
|
<span>Offset</span>
|
|
<img id="offsetUp" src="img/arrow_up_offset.svg" alt="Zvýšit offset">
|
|
<div id="offset">0</div>
|
|
<img id="offsetDown" src="img/arrow_down_offset.svg" alt="Snížit offset">
|
|
</div>
|
|
</section>
|
|
<footer>
|
|
<h2>Aktuální teplota</h2>
|
|
<div id="temp">0</div>
|
|
<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>
|
|
</body>
|
|
|
|
</html> |