'use strict';
// TODO: rework box_highlight & update_ui to accept flexible amount of aux channels
TABS.auxiliary_configuration = {};
TABS.auxiliary_configuration.initialize = function (callback) {
GUI.active_tab_ref = this;
GUI.active_tab = 'auxiliary_configuration';
googleAnalytics.sendAppView('Auxiliary Configuration');
function get_box_data() {
MSP.send_message(MSP_codes.MSP_BOX, false, false, get_box_ids);
}
function get_box_ids() {
MSP.send_message(MSP_codes.MSP_BOXIDS, false, false, get_rc_data);
}
function get_rc_data() {
MSP.send_message(MSP_codes.MSP_RC, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/auxiliary_configuration.html", process_html);
}
MSP.send_message(MSP_codes.MSP_BOXNAMES, false, false, get_box_data);
function process_html() {
// generate heads according to RC count
var table_head = $('table.boxes .heads');
var main_head = $('table.boxes .main');
for (var i = 0; i < (RC.active_channels - 4); i++) {
table_head.append('
AUX ' + (i + 1) + '
');
// 3 columns per aux channel (this might be requested to change to 6 in the future, so watch out)
main_head.append('\
\
\
\
');
}
// translate to user-selected language
localize();
// generate table from the supplied AUX names and AUX data
for (var i = 0; i < AUX_CONFIG.length; i++) {
var line = '
';
line += '
' + AUX_CONFIG[i] + '
';
var switches = '';
var auxChannelCount = RC.active_channels - 4;
var bitIndex = 0;
var chunks = 1;
if (bit_check(CONFIG.capability, 5) && (auxChannelCount) > 4) {
chunks = 2;
}
var channelsRemaining = auxChannelCount;
var channelsPerChunk = 4;
for (var chunk = 0; chunk < chunks; chunk++) {
for (var chunkChannel = 0; chunkChannel < channelsPerChunk && channelsRemaining; chunkChannel++, channelsRemaining--) {
for (var j = 0; j < 3; j++) {
if (bit_check(AUX_CONFIG_values[i], bitIndex++)) {
switches += '