remove active_tab_ref, name some of the anonymous functions, cleanup

10.3.x-maintenance
cTn 2014-10-01 12:58:09 +02:00
parent b9b5568a3b
commit 5cd042ae9d
15 changed files with 34 additions and 26 deletions

View File

@ -7,7 +7,6 @@ var GUI_control = function () {
this.connecting_to = false; this.connecting_to = false;
this.connected_to = false; this.connected_to = false;
this.active_tab; this.active_tab;
this.active_tab_ref = false;
this.tab_switch_in_progress = false; this.tab_switch_in_progress = false;
this.operating_system; this.operating_system;
this.optional_usb_permissions = false; // controlled by usb permissions code this.optional_usb_permissions = false; // controlled by usb permissions code
@ -198,7 +197,7 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
GUI.interval_kill_all(); // all intervals (mostly data pulling) needs to be removed on tab switch GUI.interval_kill_all(); // all intervals (mostly data pulling) needs to be removed on tab switch
this.active_tab_ref.cleanup(callback); TABS[this.active_tab].cleanup(callback);
}; };
// initialize object into GUI variable // initialize object into GUI variable

View File

@ -17,8 +17,6 @@ googleAnalyticsService.getConfig().addCallback(function (config) {
}); });
$(document).ready(function () { $(document).ready(function () {
googleAnalytics.sendAppView('Application Started');
// translate to user-selected language // translate to user-selected language
localize(); localize();

View File

@ -3,7 +3,8 @@
// TODO: rework box_highlight & update_ui to accept flexible amount of aux channels // TODO: rework box_highlight & update_ui to accept flexible amount of aux channels
TABS.auxiliary_configuration = {}; TABS.auxiliary_configuration = {};
TABS.auxiliary_configuration.initialize = function (callback) { TABS.auxiliary_configuration.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'auxiliary_configuration'; GUI.active_tab = 'auxiliary_configuration';
googleAnalytics.sendAppView('Auxiliary Configuration'); googleAnalytics.sendAppView('Auxiliary Configuration');
@ -141,7 +142,7 @@ TABS.auxiliary_configuration.initialize = function (callback) {
GUI.interval_add('aux_data_pull', get_rc_data, 50); GUI.interval_add('aux_data_pull', get_rc_data, 50);
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -7,7 +7,7 @@ TABS.cli = {
TABS.cli.initialize = function (callback) { TABS.cli.initialize = function (callback) {
var self = this; var self = this;
GUI.active_tab_ref = this;
GUI.active_tab = 'cli'; GUI.active_tab = 'cli';
googleAnalytics.sendAppView('CLI Page'); googleAnalytics.sendAppView('CLI Page');

View File

@ -4,7 +4,7 @@ TABS.configuration = {};
TABS.configuration.initialize = function (callback) { TABS.configuration.initialize = function (callback) {
var self = this; var self = this;
GUI.active_tab_ref = this;
GUI.active_tab = 'configuration'; GUI.active_tab = 'configuration';
googleAnalytics.sendAppView('Configuration'); googleAnalytics.sendAppView('Configuration');
@ -293,7 +293,7 @@ TABS.configuration.initialize = function (callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function status_pull () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -2,7 +2,8 @@
TABS.firmware_flasher = {}; TABS.firmware_flasher = {};
TABS.firmware_flasher.initialize = function (callback) { TABS.firmware_flasher.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'firmware_flasher'; GUI.active_tab = 'firmware_flasher';
googleAnalytics.sendAppView('Firmware Flasher'); googleAnalytics.sendAppView('Firmware Flasher');

View File

@ -2,7 +2,8 @@
TABS.gps = {}; TABS.gps = {};
TABS.gps.initialize = function (callback) { TABS.gps.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'gps'; GUI.active_tab = 'gps';
googleAnalytics.sendAppView('GPS Page'); googleAnalytics.sendAppView('GPS Page');
@ -53,7 +54,7 @@ TABS.gps.initialize = function (callback) {
GUI.interval_add('gps_pull', get_raw_gps_data, 75, true); GUI.interval_add('gps_pull', get_raw_gps_data, 75, true);
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -2,8 +2,10 @@
TABS.landing = {}; TABS.landing = {};
TABS.landing.initialize = function (callback) { TABS.landing.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'landing'; GUI.active_tab = 'landing';
googleAnalytics.sendAppView('Landing Page');
$('#content').load("./tabs/landing.html", function () { $('#content').load("./tabs/landing.html", function () {
//check_usb_permissions(); // temporary enabled in dev branch, should be commented out untill DFU support goes live //check_usb_permissions(); // temporary enabled in dev branch, should be commented out untill DFU support goes live

View File

@ -2,7 +2,8 @@
TABS.logging = {}; TABS.logging = {};
TABS.logging.initialize = function (callback) { TABS.logging.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'logging'; GUI.active_tab = 'logging';
googleAnalytics.sendAppView('Logging'); googleAnalytics.sendAppView('Logging');

View File

@ -2,7 +2,8 @@
TABS.motor_outputs = {}; TABS.motor_outputs = {};
TABS.motor_outputs.initialize = function (callback) { TABS.motor_outputs.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'motor_outputs'; GUI.active_tab = 'motor_outputs';
googleAnalytics.sendAppView('Motor Outputs Page'); googleAnalytics.sendAppView('Motor Outputs Page');
@ -407,7 +408,7 @@ TABS.motor_outputs.initialize = function (callback) {
GUI.interval_add('motor_pull', get_motor_data, 50, true); GUI.interval_add('motor_pull', get_motor_data, 50, true);
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function get_status_data() { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -2,7 +2,8 @@
TABS.pid_tuning = {}; TABS.pid_tuning = {};
TABS.pid_tuning.initialize = function (callback) { TABS.pid_tuning.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'pid_tuning'; GUI.active_tab = 'pid_tuning';
googleAnalytics.sendAppView('PID Tuning'); googleAnalytics.sendAppView('PID Tuning');
@ -272,7 +273,7 @@ TABS.pid_tuning.initialize = function (callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -2,7 +2,8 @@
TABS.receiver = {}; TABS.receiver = {};
TABS.receiver.initialize = function (callback) { TABS.receiver.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'receiver'; GUI.active_tab = 'receiver';
googleAnalytics.sendAppView('Receiver Page'); googleAnalytics.sendAppView('Receiver Page');
@ -405,7 +406,7 @@ TABS.receiver.initialize = function (callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -2,7 +2,8 @@
TABS.sensors = {}; TABS.sensors = {};
TABS.sensors.initialize = function (callback) { TABS.sensors.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'sensors'; GUI.active_tab = 'sensors';
googleAnalytics.sendAppView('Sensor Page'); googleAnalytics.sendAppView('Sensor Page');
@ -405,7 +406,7 @@ TABS.sensors.initialize = function (callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -8,7 +8,8 @@
TABS.servos = {}; TABS.servos = {};
TABS.servos.initialize = function (callback) { TABS.servos.initialize = function (callback) {
GUI.active_tab_ref = this; var self = this;
GUI.active_tab = 'servos'; GUI.active_tab = 'servos';
googleAnalytics.sendAppView('Servos'); googleAnalytics.sendAppView('Servos');
@ -295,7 +296,7 @@ TABS.servos.initialize = function (callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);

View File

@ -6,7 +6,7 @@ TABS.setup = {
TABS.setup.initialize = function (callback) { TABS.setup.initialize = function (callback) {
var self = this; var self = this;
GUI.active_tab_ref = this;
GUI.active_tab = 'setup'; GUI.active_tab = 'setup';
googleAnalytics.sendAppView('Setup'); googleAnalytics.sendAppView('Setup');
@ -294,7 +294,7 @@ TABS.setup.initialize = function (callback) {
GUI.interval_add('setup_data_pull', get_analog_data, 50, true); GUI.interval_add('setup_data_pull', get_analog_data, 50, true);
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function status_pull () { GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);