streamline button generation
This commit is contained in:
parent
bb1b561c47
commit
39f9d4c273
@ -18,27 +18,30 @@ var Modes = {
|
|||||||
var normalModes = available.filter(function(m){ return !m.digimode; });
|
var normalModes = available.filter(function(m){ return !m.digimode; });
|
||||||
var digiModes = available.filter(function(m){ return m.digimode; });
|
var digiModes = available.filter(function(m){ return m.digimode; });
|
||||||
|
|
||||||
var index = 0;
|
|
||||||
var arrayLength = normalModes.length;
|
|
||||||
var chunks = [];
|
|
||||||
|
|
||||||
|
|
||||||
for (index = 0; index < arrayLength; index += 5) {
|
|
||||||
chunks.push(normalModes.slice(index, index + 5));
|
|
||||||
}
|
|
||||||
|
|
||||||
var html = []
|
var html = []
|
||||||
|
|
||||||
html.push.apply(html, chunks.map(function(chunk){
|
var buttons = normalModes.map(function(m){
|
||||||
return $(
|
return $(
|
||||||
'<div class="openwebrx-panel-line openwebrx-panel-flex-line">' +
|
'<div class="openwebrx-button openwebrx-demodulator-button"' +
|
||||||
chunk.map(function(m){
|
|
||||||
return '<div class="openwebrx-button openwebrx-demodulator-button"' +
|
|
||||||
'id="openwebrx-button-' + m.modulation + '"' +
|
'id="openwebrx-button-' + m.modulation + '"' +
|
||||||
'onclick="demodulator_analog_replace(\'' + m.modulation + '\');">' +
|
'onclick="demodulator_analog_replace(\'' + m.modulation + '\');">' +
|
||||||
m.name + '</div>';
|
m.name + '</div>'
|
||||||
}).join('') +
|
);
|
||||||
'</div>');
|
});
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
var arrayLength = buttons.length;
|
||||||
|
var chunks = [];
|
||||||
|
|
||||||
|
for (index = 0; index < arrayLength; index += 5) {
|
||||||
|
chunks.push(buttons.slice(index, index + 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
html.push.apply(html, chunks.map(function(chunk){
|
||||||
|
$line = $('<div class="openwebrx-panel-line openwebrx-panel-flex-line"></div>');
|
||||||
|
$line.append.apply($line, chunk);
|
||||||
|
return $line
|
||||||
}));
|
}));
|
||||||
|
|
||||||
html.push($(
|
html.push($(
|
||||||
@ -55,7 +58,7 @@ var Modes = {
|
|||||||
|
|
||||||
$("#openwebrx-panel-receiver").find(".openwebrx-modes").html(html);
|
$("#openwebrx-panel-receiver").find(".openwebrx-modes").html(html);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var Mode = function(json){
|
var Mode = function(json){
|
||||||
this.modulation = json.modulation;
|
this.modulation = json.modulation;
|
||||||
|
Loading…
Reference in New Issue
Block a user