From d4f4d619cff7cc33f3ba5c65fc0ef193ad2c00a7 Mon Sep 17 00:00:00 2001 From: cTn Date: Thu, 14 Aug 2014 16:41:49 +0200 Subject: [PATCH] another run on undefined comparators --- js/gui.js | 4 ++-- js/msp.js | 4 ++-- js/serial.js | 2 +- js/serial_backend.js | 20 ++++++++++---------- tabs/receiver.js | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/js/gui.js b/js/gui.js index 788534fd1d..94829539ec 100644 --- a/js/gui.js +++ b/js/gui.js @@ -30,7 +30,7 @@ var GUI_control = function () { // interval = time interval in miliseconds // first = true/false if code should be ran initially before next timer interval hits GUI_control.prototype.interval_add = function (name, code, interval, first) { - var data = {'name': name, 'timer': undefined, 'code': code, 'interval': interval, 'fired': 0, 'paused': false}; + var data = {'name': name, 'timer': null, 'code': code, 'interval': interval, 'fired': 0, 'paused': false}; if (first == true) { code(); // execute code @@ -132,7 +132,7 @@ GUI_control.prototype.interval_kill_all = function (keep_array) { // timeout = timeout in miliseconds GUI_control.prototype.timeout_add = function (name, code, timeout) { var self = this; - var data = {'name': name, 'timer': undefined, 'timeout': timeout}; + var data = {'name': name, 'timer': null, 'timeout': timeout}; // start timer with "cleaning" callback data.timer = setTimeout(function() { diff --git a/js/msp.js b/js/msp.js index c4bdb4b78e..c3ef028c80 100644 --- a/js/msp.js +++ b/js/msp.js @@ -61,8 +61,8 @@ var MSP = { code: 0, message_length_expected: 0, message_length_received: 0, - message_buffer: undefined, - message_buffer_uint8_view: undefined, + message_buffer: null, + message_buffer_uint8_view: null, message_checksum: 0, callbacks: [], diff --git a/js/serial.js b/js/serial.js index cabac688e6..ade6c7abc3 100644 --- a/js/serial.js +++ b/js/serial.js @@ -13,7 +13,7 @@ var serial = { var self = this; chrome.serial.connect(path, options, function(connectionInfo) { - if (connectionInfo !== undefined) { + if (connectionInfo) { self.connectionId = connectionInfo.connectionId; self.bitrate = connectionInfo.bitrate; self.bytes_received = 0; diff --git a/js/serial_backend.js b/js/serial_backend.js index fcabefbe7e..c2955fbfa8 100644 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -1,7 +1,7 @@ 'use strict'; -$(document).ready(function() { - $('div#port-picker a.connect').click(function() { +$(document).ready(function () { + $('div#port-picker a.connect').click(function () { if (GUI.connect_lock != true) { // GUI control overrides the user control var clicks = $(this).data('clicks'); @@ -60,8 +60,8 @@ $(document).ready(function() { }); // auto-connect - chrome.storage.local.get('auto_connect', function(result) { - if (typeof result.auto_connect === 'undefined' || result.auto_connect) { + chrome.storage.local.get('auto_connect', function (result) { + if (!result.auto_connect || result.auto_connect) { // default or enabled by user GUI.auto_connect = true; @@ -78,7 +78,7 @@ $(document).ready(function() { } // bind UI hook to auto-connect checkbos - $('input.auto_connect').change(function() { + $('input.auto_connect').change(function () { GUI.auto_connect = $(this).is(':checked'); // update title/tooltip @@ -111,8 +111,8 @@ function onOpen(openInfo) { GUI.log(chrome.i18n.getMessage('serialPortOpened', [openInfo.connectionId])); // save selected port with chrome.storage if the port differs - chrome.storage.local.get('last_used_port', function(result) { - if (typeof result.last_used_port != 'undefined') { + chrome.storage.local.get('last_used_port', function (result) { + if (result.last_used_port) { if (result.last_used_port != GUI.connected_to) { // last used port doesn't match the one found in local db, we will store the new one chrome.storage.local.set({'last_used_port': GUI.connected_to}); @@ -127,7 +127,7 @@ function onOpen(openInfo) { if (!CONFIGURATOR.mspPassThrough) { // disconnect after 10 seconds with error if we don't get IDENT data - GUI.timeout_add('connecting', function() { + GUI.timeout_add('connecting', function () { if (!CONFIGURATOR.connectionValid) { GUI.log(chrome.i18n.getMessage('noConfigurationReceived')); @@ -136,9 +136,9 @@ function onOpen(openInfo) { }, 10000); // request configuration data - MSP.send_message(MSP_codes.MSP_UID, false, false, function() { + MSP.send_message(MSP_codes.MSP_UID, false, false, function () { GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)])); - MSP.send_message(MSP_codes.MSP_IDENT, false, false, function() { + MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () { GUI.timeout_remove('connecting'); // kill connecting timer GUI.log(chrome.i18n.getMessage('firmwareVersion', [CONFIG.version])); diff --git a/tabs/receiver.js b/tabs/receiver.js index 2247693ebc..d34148e270 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -28,7 +28,7 @@ TABS.receiver.initialize = function (callback) { $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); chrome.storage.local.get('rx_refresh_rate', function (result) { - if (typeof result.rx_refresh_rate != 'undefined') { + if (result.rx_refresh_rate) { $('select[name="rx_refresh_rate"]').val(result.rx_refresh_rate).change(); } else { $('select[name="rx_refresh_rate"]').change(); // start with default value