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.
192 lines
5.3 KiB
192 lines
5.3 KiB
<html>
|
|
<head>
|
|
<title>MiniWebCam</title>
|
|
<script src="jquery-3.1.0.min.js"></script>
|
|
<link rel="stylesheet" href="default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<table class="noborder"><tr><td>
|
|
<label>Filter Processing<input id="floatimage" type="checkbox"></label>
|
|
</td><td>
|
|
<label>Auto Brightness<input id="autobright" type="search" list="autobrightlist"><datalist id="autobrightlist"></datalist></label>
|
|
</td></tr>
|
|
</table>
|
|
<br>
|
|
|
|
<div class="webcamimage">
|
|
<img id="webcamimage" src="snapshot.jpg"></img>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div class="float">
|
|
<h2>Controls</h2><hr>
|
|
<table id="controls" class="withborder"></table>
|
|
</div>
|
|
<div class="float">
|
|
<h2>Infos</h2><hr>
|
|
<table id="variables" class="withborder"></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");
|
|
let datalist = document.getElementById("autobrightlist");
|
|
datalist.innerHTML = "";
|
|
$.ajax({
|
|
type: "POST",
|
|
url: 'get/ctrls',
|
|
data: "",
|
|
success: function(response)
|
|
{
|
|
let jsonData = {};
|
|
|
|
ctrls = JSON.parse(response);
|
|
let table = document.getElementById("controls");
|
|
let t = "<thead class=\"withborder\"><tr class=\"withborder\"><th class=\"withborder\">Name</th><th class=\"withborder\">Min</th><th class=\"withborder\">Max</th><th class=\"withborder\">Value</th></thead><tbody>";
|
|
ctrls.ctrls.forEach(function (elm, idx) {
|
|
t += "<tr class=\"withborder\"><td class=\"withborder\">"+elm.name+"</td><td class=\"withborder\">"+elm.min+"</td>"+
|
|
"<td class=\"withborder\">"+elm.max+"</td><td class=\"withborder\">" +
|
|
"<input class=\"ctrlvalue\" dataid=\""+elm.id+"\" value=\""+elm.value+"\" size=\"6\" inputmode=\"search\"></td></tr>";
|
|
datalist.innerHTML += "<option value=\""+elm.id + " " + elm.name+"\">";
|
|
});
|
|
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 = "<thead><tr class=\"withborder\"><th class=\"withborder\">Name</th><th class=\"withborder\">Value</th><th class=\"withborder\">Description</th></thead><tbody>";
|
|
variables.variables.forEach(function (elm, idx) {
|
|
t += "<tr class=\"withborder\"><td class=\"withborder\">"+elm.name+"</td>"+
|
|
"<td class=\"withborder\"><input class=\"variablevalue\" dataid=\""+elm.name+"\" value=\""+elm.value+"\" size=\"6\" inputmode=\"search\"></td>"+
|
|
"<td class=\"withborder\">"+elm.desc+"</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";
|
|
}
|
|
});
|
|
}
|
|
|
|
let cyclecnt = 0;
|
|
function refresh() {
|
|
reloadImage();
|
|
|
|
if (((cyclecnt++) % 25) == 0) {
|
|
refreshCtrls();
|
|
refreshVariables();
|
|
}
|
|
}
|
|
|
|
|
|
setInterval(refresh, 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> |