pushbutton functie werkt
This commit is contained in:
parent
f48e9309b9
commit
b2a397d4f8
@ -3,9 +3,14 @@
|
||||
<title>Hardware</title>
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<body class="text-center">
|
||||
{% include "t-navbar.html" %}
|
||||
<div class="container">
|
||||
{% if RPI == False %}
|
||||
<div class="alert alert-danger mt-4" role="alert">
|
||||
Volgens de webserver is de hardware niet aangesloten en kan dus niet worden bestuurd. (Is de variabele aangepast in run.py?)
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row row-cols-2">
|
||||
<div class="col">
|
||||
<h1>Afstand sensor</h1>
|
||||
@ -13,7 +18,7 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<h1>Push buttons</h1>
|
||||
kkkk
|
||||
<h2>Button0 is <span class="badge badge-danger" id="button-badge">Niet ingedrukt</span></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row row-cols-3">
|
||||
@ -47,5 +52,32 @@
|
||||
$.post("/api/ledstrip", {setstate:valinbox})
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// dit script blok geldt alleen voor de pushknoppen
|
||||
|
||||
// functie om de badge groen te maken en text 'ingedrukt'
|
||||
function set_true() {
|
||||
document.getElementById('button-badge').className = "badge badge-success";
|
||||
document.getElementById('button-badge').textContent = 'Ingedrukt';
|
||||
};
|
||||
|
||||
// functie om de badge rood te maken en text 'niet ingedrukt'
|
||||
function set_false() {
|
||||
document.getElementById('button-badge').className = "badge badge-danger";
|
||||
document.getElementById('button-badge').textContent = 'Niet ingedrukt';
|
||||
};
|
||||
|
||||
function doPoll() {
|
||||
$.getJSON('/api/pushbutton', function(data) {
|
||||
if (data.button0 == true) {
|
||||
set_true();
|
||||
} else {
|
||||
set_false();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
{% if RPI == False %}// {% endif %}setInterval(function(){ doPoll(); }, 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user