|
2 | 2 |
|
3 | 3 | TABS.power = { |
4 | 4 | supported: false, |
| 5 | + analyticsChanges: {}, |
5 | 6 | }; |
6 | 7 |
|
7 | 8 | TABS.power.initialize = function (callback) { |
@@ -114,6 +115,14 @@ TABS.power.initialize = function (callback) { |
114 | 115 | $('input[name="vbatresdivmultiplier-' + index + '"]').val(voltageDataSource[index].vbatresdivmultiplier); |
115 | 116 | } |
116 | 117 |
|
| 118 | + $('input[name="vbatscale-0"]').change(function () { |
| 119 | + let value = parseInt($(this).val()); |
| 120 | + |
| 121 | + if (value !== voltageDataSource[0].vbatscale) { |
| 122 | + self.analyticsChanges['PowerVBatUpdated'] = value; |
| 123 | + } |
| 124 | + }); |
| 125 | + |
117 | 126 | // amperage meters |
118 | 127 | if (BATTERY_CONFIG.currentMeterSource == 0) { |
119 | 128 | $('.boxAmperageConfiguration').hide(); |
@@ -164,6 +173,26 @@ TABS.power.initialize = function (callback) { |
164 | 173 | $('input[name="amperageoffset-' + index + '"]').val(currentDataSource[index].offset); |
165 | 174 | } |
166 | 175 |
|
| 176 | + $('input[name="amperagescale-0"]').change(function () { |
| 177 | + if (BATTERY_CONFIG.currentMeterSource === 1) { |
| 178 | + let value = parseInt($(this).val()); |
| 179 | + |
| 180 | + if (value !== currentDataSource[0].scale) { |
| 181 | + self.analyticsChanges['PowerAmperageUpdated'] = value; |
| 182 | + } |
| 183 | + } |
| 184 | + }); |
| 185 | + |
| 186 | + $('input[name="amperagescale-1"]').change(function () { |
| 187 | + if (BATTERY_CONFIG.currentMeterSource === 2) { |
| 188 | + let value = parseInt($(this).val()); |
| 189 | + |
| 190 | + if (value !== currentDataSource[1].scale) { |
| 191 | + self.analyticsChanges['PowerAmperageUpdated'] = value; |
| 192 | + } |
| 193 | + } |
| 194 | + }); |
| 195 | + |
167 | 196 | if(BATTERY_CONFIG.voltageMeterSource == 1 || BATTERY_CONFIG.currentMeterSource == 1 || BATTERY_CONFIG.currentMeterSource == 2) { |
168 | 197 | $('.calibration').show(); |
169 | 198 | } else { |
@@ -324,7 +353,7 @@ TABS.power.initialize = function (callback) { |
324 | 353 | closeButton: 'title', |
325 | 354 | animation: false, |
326 | 355 | attach: $('#calibrate'), |
327 | | - title: 'Calibration Manager Confirmation', |
| 356 | + title: i18n.getMessage('powerCalibrationManagerConfirmationTitle'), |
328 | 357 | content: $('#calibrationmanagerconfirmcontent'), |
329 | 358 | onCloseComplete: function() { |
330 | 359 | GUI.calibrationManager.close(); |
@@ -409,6 +438,14 @@ TABS.power.initialize = function (callback) { |
409 | 438 | $('output[name="amperagenewscale"').val(amperagenewscale); |
410 | 439 |
|
411 | 440 | $('a.applycalibration').click(function() { |
| 441 | + if (vbatscalechanged) { |
| 442 | + self.analyticsChanges['PowerVBatUpdated'] = 'Calibrated'; |
| 443 | + } |
| 444 | + |
| 445 | + if (amperagescalechanged) { |
| 446 | + self.analyticsChanges['PowerAmperageUpdated'] = 'Calibrated'; |
| 447 | + } |
| 448 | + |
412 | 449 | calibrationconfirmed = true; |
413 | 450 | GUI.calibrationManagerConfirmation.close(); |
414 | 451 | updateDisplay(VOLTAGE_METER_CONFIGS, CURRENT_METER_CONFIGS); |
@@ -440,6 +477,8 @@ TABS.power.initialize = function (callback) { |
440 | 477 | BATTERY_CONFIG.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val()); |
441 | 478 | BATTERY_CONFIG.capacity = parseInt($('input[name="capacity"]').val()); |
442 | 479 |
|
| 480 | + analytics.sendChangeEvents(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, self.analyticsChanges); |
| 481 | + |
443 | 482 | save_power_config(); |
444 | 483 | }); |
445 | 484 |
|
@@ -483,6 +522,8 @@ TABS.power.initialize = function (callback) { |
483 | 522 | function process_html() { |
484 | 523 | initDisplay(); |
485 | 524 |
|
| 525 | + self.analyticsChanges = {}; |
| 526 | + |
486 | 527 | // translate to user-selected language |
487 | 528 | i18n.localizePage(); |
488 | 529 |
|
|
0 commit comments