wa_gc_api / online.html
DmitrMakeev's picture
Update online.html
8ed38d0 verified
raw
history blame
5.79 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>My static Space</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container mt-3">
<div class="container text-center"> <br>
<h1>Онлайн данные системы</h1>
</div> <br>
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Название карточки</h5>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Название карточки</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<div class="container text-center">
<h4 class="card-title">Время</h4>
</div>
<div class="container text-center">
<p><h1><span id="v_hid"></span> : <span id="v_min"></span></h1></p>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<div class="container text-center">
<h4 class="card-title">Период</h4>
</div>
<div class="container text-center">
<p><h1>День: <span id="dey"></span> - Неделя: <span id="wek"></span></h1></p>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
<div class="card-deck">
<div class="card">
<div class="card-body">
<div class="container text-center">
<h5 class="card-title">pH раствора</h5>
</div>
<div class="container text-center">
<h2><span id="ph"></span></h2>
</div>
</div>
<div class="card-footer">
</div>
</div>
<div class="card">
<div class="card-body">
<div class="container text-center">
<h5 class="card-title">EC раствора</h5>
</div>
<div class="container text-center">
<h2><span id="ec"></span></h2>
</div>
</div>
<div class="card-footer">
</div>
</div>
<div class="card">
<div class="card-body">
<div class="container text-center">
<h5 class="card-title">Т. раствора</h5>
</div>
<div class="container text-center">
<h2><span id="tS"></span></h2>
</div>
</div>
<div class="card-footer">
</div>
</div>
</div>
<br>
<br>
<p>Т. раствора: <span id="tS"></span></p>
<p>Т. воздуха: <span id="tA"></span></p>
<p>Вл. воздуха: <span id="hDm"></span></p>
<p>Об. вентилятора: <span id="sVen"></span></p>
<br>
<p>Система: <span id="rFul"></span></p>
<p>Освещение: <span id="rLi"></span></p>
<p>Под.воды: <span id="rWat"></span></p>
<p>Под. раствора: <span id="rRas"></span></p>
<p>Доз. pH: <span id="rPH"></span></p>
<p>Доз. EC: <span id="rEC"></span></p>
<p>Слив: <span id="rSl"></span></p>
<p>Ур. раствора: <span id="rLe"></span></p>
<p>Дат. затопления: <span id="alW"></span></p>
</div>
<script>
function updateValues(data) {
document.getElementById("dey").textContent = data.dey;
document.getElementById("wek").textContent = data.wek;
document.getElementById("v_hid").textContent = data.v_hid;
document.getElementById("v_min").textContent = data.v_min;
document.getElementById("dey").textContent = data.dey;
document.getElementById("wek").textContent = data.wek;
document.getElementById("ph").textContent = data.ph;
document.getElementById("ec").textContent = data.ec;
document.getElementById("tS").textContent = data.tS;
document.getElementById("tA").textContent = data.tA;
document.getElementById("hDm").textContent = data.hDm;
document.getElementById("sVen").textContent = data.sVen;
document.getElementById("rFul").textContent = data.rFul;
document.getElementById("rLi").textContent = data.rLi;
document.getElementById("rWat").textContent = data.rWat;
document.getElementById("rRas").textContent = data.rRas;
document.getElementById("rPH").textContent = data.rPH;
document.getElementById("rEC").textContent = data.rEC;
document.getElementById("rSl").textContent = data.rSl;
document.getElementById("rLe").textContent = data.rLe;
document.getElementById("alW").textContent = data.alW;
}
function fetchValues() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/online_api", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
updateValues(response);
}
};
xhr.send();
}
fetchValues();
setInterval(fetchValues, 10000);
</script>
</body>
</html>