From e394248baffc0484751c27cd509806c97c4c403b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 5 Oct 2021 19:21:55 -0400 Subject: [PATCH] Add ajax controls to realtime change the v4l2 ctrls --- web/skins/classic/views/js/watch.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 66dabc7ec..82bc26df5 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -783,6 +783,25 @@ function getCtrlPresetModal() { .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() { $j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId) .done(function(data) { @@ -792,6 +811,10 @@ function getSettingsModal() { evt.preventDefault(); $j('#settingsForm').submit(); }); + $j('#newBrightness').change(changeControl); + $j('#newContrast').change(changeControl); + $j('#newHue').change(changeControl); + $j('#newColour').change(changeControl); }) .fail(logAjaxFail); }