openwebrx-clone/htdocs/lib/settings/WsjtDecodingDepthsInput.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-02-15 19:19:43 +00:00
$.fn.wsjtDecodingDepthsInput = function() {
2021-02-15 21:14:56 +00:00
function WsjtDecodingDepthRow(inputs, mode, value) {
this.el = $('<tr>');
this.modeInput = $(inputs.get(0)).clone();
this.modeInput.val(mode);
this.valueInput = $(inputs.get(1)).clone();
this.valueInput.val(value);
this.el.append([this.modeInput, this.valueInput].map(function(i) {
return $('<td>').append(i);
2021-02-15 19:19:43 +00:00
}));
2021-02-15 21:14:56 +00:00
}
WsjtDecodingDepthRow.prototype.getEl = function() {
return this.el;
2021-02-15 19:19:43 +00:00
}
this.each(function(){
var $input = $(this);
var $el = $input.parent();
2021-02-15 21:14:56 +00:00
var $inputs = $el.find('.inputs')
var inputs = $inputs.find('input, select');
$inputs.remove();
var rows = $.map(JSON.parse($input.val()), function(value, mode) {
return new WsjtDecodingDepthRow(inputs, mode, value);
});
var $table = $('<table class="table table-sm table-borderless wsjt-decoding-depths-table">');
$table.append(rows.map(function(r) {
return r.getEl();
}));
2021-02-15 19:19:43 +00:00
$el.append($table);
});
};