From b408a89c1df764f255e63f9c2dfb07de0be6e533 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 5 Dec 2020 12:55:59 +0100 Subject: [PATCH] update preset --- server.py | 5 +++++ static/js/cccc.js | 50 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index fb477dc..3a6fc98 100755 --- a/server.py +++ b/server.py @@ -101,6 +101,11 @@ class API(object): result['presets'] = ctl.camera.get_presets(True) return result + def setPreset(self, **data): + result = {} + ctl.camera.set_preset(data['id'], data['name']) + return result + def setPresets(self, **data): result = {} ctl.camera.set_presets(data['presets']) diff --git a/static/js/cccc.js b/static/js/cccc.js index 645362a..7626f98 100644 --- a/static/js/cccc.js +++ b/static/js/cccc.js @@ -52,12 +52,29 @@ if (value == null || value == undefined || !value.length || !isInt(value)) { } var presets = []; +var system_presets = [ + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105 +]; -function presetSelect() { +function presetSelect(all) { var options = '' - presets.forEach(function(preset) { - options += ''; - }) + if (all) { + for (var id=1;id<=300;id++) { + if (system_presets.indexOf(id) == -1) { + var preset = getPreset(id) + if (preset) { + options += ''; + } else { + options += ''; + } + } + } + } else { + presets.forEach(function(preset) { + options += ''; + }) + } return $('') } @@ -679,5 +696,28 @@ function init_ptz() { }) }) } - + api('getPresets', {}, function(response) { + presets = response.result.presets + var id = 1 + presetSelect(true).on({ + change: event => { + id = parseInt(event.target.value) + var preset = getPreset(id) + name.val(preset ? preset.name : '') + } + }).appendTo($('body')) + var name = $('').appendTo($('body')) + name.val(getPreset(id).name) + $('