From b0f7fd5d00b7c75c7bce25fe9985fa4761ca702f Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 10 May 2020 22:42:09 +0200 Subject: [PATCH] ability to add more config keys --- htdocs/settings.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/htdocs/settings.js b/htdocs/settings.js index 732e795..55abf45 100644 --- a/htdocs/settings.js +++ b/htdocs/settings.js @@ -68,16 +68,44 @@ function SdrDevice(el) { this.data = JSON.parse(decodeURIComponent(el.data('config'))); this.inputs = {}; this.render(); + + var self = this; + el.on('click', '.fieldselector .btn', function() { + var key = el.find('.fieldselector select').val(); + self.data[key] = false; + self.render(); + }); }; SdrDevice.prototype.render = function() { var self = this; + self.el.empty(); $.each(this.data, function(key, value) { var inputClass = Input.mappings[key] || TextInput; var input = new inputClass(key, value); self.inputs[key] = input; - self.el.append(input.render()) + self.el.append(input.render()); }); + self.el.append(this.renderFieldSelector()); +}; + +SdrDevice.prototype.renderFieldSelector = function() { + var self = this; + return '
' + + '

Add new configuration options

' + + '
' + + '
' + + '
' + + '
Add to config
' + + '
' + + '
' + + '

'; }; $.fn.sdrdevice = function() { @@ -113,5 +141,5 @@ $(function(){ }); }); - console.info($(".sdrdevice").sdrdevice()); + $(".sdrdevice").sdrdevice(); }); \ No newline at end of file