You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
4.3 KiB
177 lines
4.3 KiB
<html>
|
|
<head>
|
|
<title>MiniWebCam</title>
|
|
<script src="jquery-3.1.0.min.js"></script>
|
|
<link rel="stylesheet" href="default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="toggle">
|
|
<label>Filter Processing<input id="floatimage" type="checkbox"><span class="slider"></span></label>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div class="webcamimage">
|
|
<img id="webcamimage" src="snapshot.jpg"></img>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div class="float">
|
|
<h2>Controls</h2><hr>
|
|
<table id="controls"></table>
|
|
</div>
|
|
<div class="float">
|
|
<h2>Infos</h2><hr>
|
|
<table id="variables"></table>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div id="debug">
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
<script>
|
|
|
|
let ctrls;
|
|
let variables;
|
|
|
|
function reloadImage() {
|
|
const img1 = document.getElementById('webcamimage');
|
|
const filterimage1 = document.getElementById('floatimage');
|
|
let src1 = "snapshot.jpg";
|
|
if (filterimage1.checked) src1 = "snapshot-float.jpg";
|
|
src1 = src1 + '?' + new Date().getTime();
|
|
img1.src = src1;
|
|
}
|
|
|
|
function refreshCtrls() {
|
|
let debug = document.getElementById("debug");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'get/ctrls',
|
|
data: "",
|
|
success: function(response)
|
|
{
|
|
let jsonData = {};
|
|
|
|
ctrls = JSON.parse(response);
|
|
let table = document.getElementById("controls");
|
|
let t = "<thead><tr><th>Name</th><th>Min</th><th>Max</th><th>Value</th></thead><tbody>";
|
|
ctrls.ctrls.forEach(function (elm, idx) {
|
|
t += "<tr><td>"+elm.name+"</td><td>"+elm.min+"</td>"+
|
|
"<td>"+elm.max+"</td><td>" +
|
|
"<input class=\"ctrlvalue\" dataid=\""+elm.id+"\" value=\""+elm.value+"\" size=\"6\"></td></tr>";
|
|
});
|
|
t += "</tbody>";
|
|
table.innerHTML = t;
|
|
},
|
|
error: function(error) {
|
|
debug.innerHTML = "ERROR";
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function refreshVariables() {
|
|
let debug = document.getElementById("debug");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'get/variables',
|
|
data: "",
|
|
success: function(response)
|
|
{
|
|
let jsonData = {};
|
|
|
|
variables = JSON.parse(response);
|
|
let table = document.getElementById("variables");
|
|
let t = "<tbody>";
|
|
variables.variables.forEach(function (elm, idx) {
|
|
t += "<tr><td>"+elm.name+"</td><td><input class=\"variablevalue\" dataid=\""+elm.name+"\" value=\""+elm.value+"\" size=\"6\"></td></tr>";
|
|
});
|
|
t += "</tbody>";
|
|
table.innerHTML = t;
|
|
},
|
|
error: function(error) {
|
|
debug.innerHTML = "ERROR";
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
function setCtrl(id, value) {
|
|
let debug = document.getElementById("debug");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'set/ctrl/'+id+"="+value,
|
|
data: "",
|
|
success: function(response)
|
|
{
|
|
refreshCtrls();
|
|
},
|
|
error: function(error) {
|
|
debug.innerHTML = "ERROR";
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
function setVariable(id, value) {
|
|
let debug = document.getElementById("debug");
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'set/var/'+id+"="+value,
|
|
data: "",
|
|
success: function(response)
|
|
{
|
|
refreshCtrls();
|
|
},
|
|
error: function(error) {
|
|
debug.innerHTML = "ERROR";
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
setInterval(reloadImage, 500);
|
|
refreshCtrls();
|
|
refreshVariables();
|
|
|
|
$(document).on('keypress', '.ctrlvalue', function(e) {
|
|
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
// Hier deine Funktion einfügen
|
|
let id = this.getAttribute('dataid');
|
|
let value = this.value;
|
|
setCtrl(id, value);
|
|
|
|
// Verhindert das Standard-Verhalten (z. B. Formular absenden)
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
$(document).on('keypress', '.variablevalue', function(e) {
|
|
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
// Hier deine Funktion einfügen
|
|
let id = this.getAttribute('dataid');
|
|
let value = this.value;
|
|
setVariable(id, value);
|
|
|
|
// Verhindert das Standard-Verhalten (z. B. Formular absenden)
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
</html> |