diff --git a/js/gui.js b/js/gui.js index 94829539..a9882cf5 100644 --- a/js/gui.js +++ b/js/gui.js @@ -7,7 +7,6 @@ var GUI_control = function () { this.connecting_to = false; this.connected_to = false; this.active_tab; - this.active_tab_ref = false; this.tab_switch_in_progress = false; this.operating_system; 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 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 diff --git a/main.js b/main.js index 5e0df04b..e908cadd 100644 --- a/main.js +++ b/main.js @@ -17,8 +17,6 @@ googleAnalyticsService.getConfig().addCallback(function (config) { }); $(document).ready(function () { - googleAnalytics.sendAppView('Application Started'); - // translate to user-selected language localize(); diff --git a/tabs/auxiliary_configuration.js b/tabs/auxiliary_configuration.js index 5baf5c48..5fb734f6 100644 --- a/tabs/auxiliary_configuration.js +++ b/tabs/auxiliary_configuration.js @@ -3,7 +3,8 @@ // 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; + var self = this; + GUI.active_tab = '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); // 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); }, 250, true); diff --git a/tabs/cli.js b/tabs/cli.js index 5c0e88c1..f385e55b 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -7,7 +7,7 @@ TABS.cli = { TABS.cli.initialize = function (callback) { var self = this; - GUI.active_tab_ref = this; + GUI.active_tab = 'cli'; googleAnalytics.sendAppView('CLI Page'); diff --git a/tabs/configuration.js b/tabs/configuration.js index f8a02a29..845203f2 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -4,7 +4,7 @@ TABS.configuration = {}; TABS.configuration.initialize = function (callback) { var self = this; - GUI.active_tab_ref = this; + GUI.active_tab = 'configuration'; googleAnalytics.sendAppView('Configuration'); @@ -293,7 +293,7 @@ TABS.configuration.initialize = function (callback) { }); // 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); }, 250, true); diff --git a/tabs/firmware_flasher.js b/tabs/firmware_flasher.js index 064fe6db..28dbe1a2 100644 --- a/tabs/firmware_flasher.js +++ b/tabs/firmware_flasher.js @@ -2,7 +2,8 @@ TABS.firmware_flasher = {}; TABS.firmware_flasher.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'firmware_flasher'; googleAnalytics.sendAppView('Firmware Flasher'); diff --git a/tabs/gps.js b/tabs/gps.js index 7eb47de6..e8ecd73a 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -2,7 +2,8 @@ TABS.gps = {}; TABS.gps.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'gps'; googleAnalytics.sendAppView('GPS Page'); @@ -53,7 +54,7 @@ TABS.gps.initialize = function (callback) { GUI.interval_add('gps_pull', get_raw_gps_data, 75, true); // 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); }, 250, true); diff --git a/tabs/landing.js b/tabs/landing.js index 4d57a0e1..dd5c0df6 100644 --- a/tabs/landing.js +++ b/tabs/landing.js @@ -2,8 +2,10 @@ TABS.landing = {}; TABS.landing.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'landing'; + googleAnalytics.sendAppView('Landing Page'); $('#content').load("./tabs/landing.html", function () { //check_usb_permissions(); // temporary enabled in dev branch, should be commented out untill DFU support goes live diff --git a/tabs/logging.js b/tabs/logging.js index 967da9f9..5f17e0ba 100644 --- a/tabs/logging.js +++ b/tabs/logging.js @@ -2,7 +2,8 @@ TABS.logging = {}; TABS.logging.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'logging'; googleAnalytics.sendAppView('Logging'); diff --git a/tabs/motor_outputs.js b/tabs/motor_outputs.js index 7755e6fb..8a44fd69 100644 --- a/tabs/motor_outputs.js +++ b/tabs/motor_outputs.js @@ -2,7 +2,8 @@ TABS.motor_outputs = {}; TABS.motor_outputs.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'motor_outputs'; 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); // 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); }, 250, true); diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 94baefcb..5846d48b 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -2,7 +2,8 @@ TABS.pid_tuning = {}; TABS.pid_tuning.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = '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 - GUI.interval_add('status_pull', function () { + GUI.interval_add('status_pull', function status_pull() { MSP.send_message(MSP_codes.MSP_STATUS); }, 250, true); diff --git a/tabs/receiver.js b/tabs/receiver.js index 17cbcf66..46faf966 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -2,7 +2,8 @@ TABS.receiver = {}; TABS.receiver.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'receiver'; googleAnalytics.sendAppView('Receiver Page'); @@ -405,7 +406,7 @@ TABS.receiver.initialize = function (callback) { }); // 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); }, 250, true); diff --git a/tabs/sensors.js b/tabs/sensors.js index 5bdcf2b4..75438557 100644 --- a/tabs/sensors.js +++ b/tabs/sensors.js @@ -2,7 +2,8 @@ TABS.sensors = {}; TABS.sensors.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'sensors'; googleAnalytics.sendAppView('Sensor Page'); @@ -405,7 +406,7 @@ TABS.sensors.initialize = function (callback) { }); // 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); }, 250, true); diff --git a/tabs/servos.js b/tabs/servos.js index edd02d6d..8d262151 100644 --- a/tabs/servos.js +++ b/tabs/servos.js @@ -8,7 +8,8 @@ TABS.servos = {}; TABS.servos.initialize = function (callback) { - GUI.active_tab_ref = this; + var self = this; + GUI.active_tab = 'servos'; googleAnalytics.sendAppView('Servos'); @@ -295,7 +296,7 @@ TABS.servos.initialize = function (callback) { }); // 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); }, 250, true); diff --git a/tabs/setup.js b/tabs/setup.js index da5a14fe..f24022f8 100644 --- a/tabs/setup.js +++ b/tabs/setup.js @@ -6,7 +6,7 @@ TABS.setup = { TABS.setup.initialize = function (callback) { var self = this; - GUI.active_tab_ref = this; + GUI.active_tab = 'setup'; googleAnalytics.sendAppView('Setup'); @@ -294,7 +294,7 @@ TABS.setup.initialize = function (callback) { GUI.interval_add('setup_data_pull', get_analog_data, 50, true); // 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); }, 250, true);