From d61858b0ad47a13428e850ee475619ac57e0af62 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Tue, 1 Nov 2016 21:24:48 +0200 Subject: [PATCH] added support for custom resolutions --- motioneye/static/js/main.js | 26 +++++++++++++++++++++++--- motioneye/templates/main.html | 10 ++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index b978106..49467b4 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -578,6 +578,18 @@ function initUI() { return true; }, ''); + makeCustomValidator($('#customWidthEntry, #customHeightEntry'), function (value) { + if (!value) { + return 'this field is required'; + } + + value = Number(value); + if (value % 8) { + return "value must be a multiple of 8"; + } + + return true; + }, ''); makeCustomValidator($('#rootDirectoryEntry'), function (value) { if ($('#storageDeviceSelect').val() == 'custom-path' && String(value).trim() == '/') { return 'files cannot be created directly on the root of your system'; @@ -1371,9 +1383,9 @@ function updateConfigUI() { $('tr.advanced-setting, div.advanced-setting, table.advanced-setting').each(markHideAdvanced); } - /* hide resolution select if no resolution is selected (none matches) */ + /* set resolution to custom if no existing value matches */ if ($('#resolutionSelect')[0].selectedIndex == -1) { - $('#resolutionSelect').parents('tr:eq(0)').each(markHideLogic); + $('#resolutionSelect').val('custom'); } /* video device switch */ @@ -1904,7 +1916,10 @@ function cameraUi2Dict() { dict['working_schedule'] = false; } - if ($('#resolutionSelect')[0].selectedIndex != -1) { + if ($('#resolutionSelect').val() == 'custom') { + dict.resolution = $('#customWidthEntry').val() + 'x' + $('#customHeightEntry').val(); + } + else { dict.resolution = $('#resolutionSelect').val(); } @@ -2033,8 +2048,13 @@ function dict2CameraUi(dict) { dict['available_resolutions'].forEach(function (resolution) { $('#resolutionSelect').append(''); }); + $('#resolutionSelect').append(''); } $('#resolutionSelect').val(dict['resolution']); markHideIfNull('available_resolutions', 'resolutionSelect'); + if (dict['resolution']) { + $('#customWidthEntry').val(dict['resolution'].split('x')[0]); + $('#customHeightEntry').val(dict['resolution'].split('x')[1]); + } $('#rotationSelect').val(dict['rotation']); markHideIfNull('rotation', 'rotationSelect'); $('#framerateSlider').val(dict['framerate']); markHideIfNull('framerate', 'framerateSlider'); diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html index 76f6685..eda3e23 100644 --- a/motioneye/templates/main.html +++ b/motioneye/templates/main.html @@ -292,6 +292,16 @@ ? + + Width + + ? + + + Height + + ? + Video Rotation -- 2.39.5