Add ajax controls to realtime change the v4l2 ctrls

This commit is contained in:
Isaac Connor 2021-10-05 19:21:55 -04:00
parent 94cd3a6e69
commit e394248baf
1 changed files with 23 additions and 0 deletions

View File

@ -783,6 +783,25 @@ function getCtrlPresetModal() {
.fail(logAjaxFail); .fail(logAjaxFail);
} }
function changeControl(e) {
const input = e.target;
$j.getJSON(monitorUrl+'?request=v4l2_settings&mid='+monitorId+'&'+input.name+'='+input.value)
.done(function(evt) {
if (evt.result == 'Ok') {
evt.controls.forEach(function(control) {
const element = $j('#new'+control.control.charAt(0).toUpperCase() + control.control.slice(1));
if (element.length) {
element.val(control.value);
element.attr('title', control.value);
} else {
console.err('Element not found for #new'+control.control.charAt(0).toUpperCase() + control.control.slice(1));
}
});
}
})
.fail(logAjaxFail);
}
function getSettingsModal() { function getSettingsModal() {
$j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId) $j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId)
.done(function(data) { .done(function(data) {
@ -792,6 +811,10 @@ function getSettingsModal() {
evt.preventDefault(); evt.preventDefault();
$j('#settingsForm').submit(); $j('#settingsForm').submit();
}); });
$j('#newBrightness').change(changeControl);
$j('#newContrast').change(changeControl);
$j('#newHue').change(changeControl);
$j('#newColour').change(changeControl);
}) })
.fail(logAjaxFail); .fail(logAjaxFail);
} }