mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
lots of work on removing global variables
This commit is contained in:
parent
377853b58a
commit
ec44b77ff2
8 changed files with 156 additions and 265 deletions
22
eventPage.js
22
eventPage.js
|
@ -18,14 +18,14 @@ function start_app() {
|
|||
minWidth: 974,
|
||||
minHeight: 632
|
||||
}
|
||||
}, function(createdWindow) {
|
||||
createdWindow.onClosed.addListener(function() {
|
||||
}, function (createdWindow) {
|
||||
createdWindow.onClosed.addListener(function () {
|
||||
// connectionId is passed from the script side through the chrome.runtime.getBackgroundPage refference
|
||||
// allowing us to automatically close the port when application shut down
|
||||
|
||||
// save connectionId in separate variable before app_window is destroyed
|
||||
var connectionId = app_window.serial.connectionId;
|
||||
var valid_connection = app_window.configuration_received;
|
||||
var valid_connection = app_window.CONFIGURATOR.connectionValid;
|
||||
var mincommand = app_window.MISC.mincommand;
|
||||
|
||||
if (connectionId > 0 && valid_connection) {
|
||||
|
@ -53,13 +53,13 @@ function start_app() {
|
|||
|
||||
bufView[5 + 16] = checksum;
|
||||
|
||||
chrome.serial.send(connectionId, bufferOut, function(sendInfo) {
|
||||
chrome.serial.disconnect(connectionId, function(result) {
|
||||
chrome.serial.send(connectionId, bufferOut, function (sendInfo) {
|
||||
chrome.serial.disconnect(connectionId, function (result) {
|
||||
console.log('SERIAL: Connection closed - ' + result);
|
||||
});
|
||||
});
|
||||
} else if (connectionId > 0) {
|
||||
chrome.serial.disconnect(connectionId, function(result) {
|
||||
chrome.serial.disconnect(connectionId, function (result) {
|
||||
console.log('SERIAL: Connection closed - ' + result);
|
||||
});
|
||||
}
|
||||
|
@ -67,18 +67,18 @@ function start_app() {
|
|||
});
|
||||
}
|
||||
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.runtime.onLaunched.addListener(function () {
|
||||
start_app();
|
||||
});
|
||||
|
||||
chrome.runtime.onInstalled.addListener(function(details) {
|
||||
chrome.runtime.onInstalled.addListener(function (details) {
|
||||
if (details.reason == 'update') {
|
||||
var previousVersionArr = details.previousVersion.split('.');
|
||||
var currentVersionArr = chrome.runtime.getManifest().version.split('.');
|
||||
|
||||
// only fire up notification sequence when one of the major version numbers changed
|
||||
if (currentVersionArr[0] != previousVersionArr[0] || currentVersionArr[1] != previousVersionArr[1]) {
|
||||
chrome.storage.local.get('update_notify', function(result) {
|
||||
chrome.storage.local.get('update_notify', function (result) {
|
||||
if (typeof result.update_notify === 'undefined' || result.update_notify) {
|
||||
var manifest = chrome.runtime.getManifest();
|
||||
var options = {
|
||||
|
@ -90,7 +90,7 @@ chrome.runtime.onInstalled.addListener(function(details) {
|
|||
buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}]
|
||||
};
|
||||
|
||||
chrome.notifications.create('baseflight_update', options, function(notificationId) {
|
||||
chrome.notifications.create('baseflight_update', options, function (notificationId) {
|
||||
// empty
|
||||
});
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ chrome.runtime.onInstalled.addListener(function(details) {
|
|||
}
|
||||
});
|
||||
|
||||
chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex) {
|
||||
chrome.notifications.onButtonClicked.addListener(function (notificationId, buttonIndex) {
|
||||
if (notificationId == 'baseflight_update') {
|
||||
start_app();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue