diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 656cf415c9..cdec73e51d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1,4 +1,14 @@ { + "options_receive_app_notifications": { + "message": "Receive desktop notification when application updates" + }, + "options_improve_configurator": { + "message": "Improve Baseflight - Configurator by sending anonymous usage data to the developer team" + }, + "options_back": { + "message": "Leave Options" + }, + "notifications_app_just_updated_to_version": { "message": "Application just updated to version: $1" }, diff --git a/background.js b/background.js index bca1dde458..011cf91329 100644 --- a/background.js +++ b/background.js @@ -44,18 +44,22 @@ chrome.app.runtime.onLaunched.addListener(function() { chrome.runtime.onInstalled.addListener(function(details) { if (details.reason == 'update') { - var manifest = chrome.runtime.getManifest(); - var options = { - priority: 0, - type: 'basic', - title: manifest.name, - message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [manifest.version]), - iconUrl: '/images/icon_128.png', - buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}] - }; + chrome.storage.local.get('update_notify', function(result) { + if (typeof result.update_notify === 'undefined' || result.update_notify) { + var manifest = chrome.runtime.getManifest(); + var options = { + priority: 0, + type: 'basic', + title: manifest.name, + message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [manifest.version]), + iconUrl: '/images/icon_128.png', + buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}] + }; - chrome.notifications.create('baseflight_update', options, function(notificationId) { - // empty + chrome.notifications.create('baseflight_update', options, function(notificationId) { + // empty + }); + } }); } }); diff --git a/main.css b/main.css index a65779ceff..829e292120 100644 --- a/main.css +++ b/main.css @@ -172,8 +172,8 @@ input[type="number"]::-webkit-inner-spin-button { height: 15px; padding: 5px; - padding-left: 12px; - padding-right: 12px; + padding-left: 8px; + padding-right: 8px; background-color: #d0d0d0; } @@ -220,4 +220,13 @@ input[type="number"]::-webkit-inner-spin-button { border-top: 1px solid #7d7d79; background-color: #bfbeb5; -} \ No newline at end of file +} + + #status-bar div { + float: left; + + padding-right: 10px; + margin-right: 10px; + + border-right: 1px solid #7d7d79; + } \ No newline at end of file diff --git a/main.html b/main.html index 5e3edaffdb..319b452ccf 100644 --- a/main.html +++ b/main.html @@ -16,6 +16,7 @@ + @@ -44,6 +45,7 @@ + @@ -104,6 +106,7 @@
  • Motor/Servo Outputs
  • Raw Sensor Data
  • CLI
  • +
  • Options
  • @@ -111,9 +114,15 @@
    - D: 0% U: 0% | - 0 | - 0 +
    + D: 0% U: 0% +
    +
    + 0 +
    +
    + 0 +
    diff --git a/main.js b/main.js index 7599e3dc06..8e2a087de4 100644 --- a/main.js +++ b/main.js @@ -7,12 +7,20 @@ chrome.runtime.getBackgroundPage(function(result) { backgroundPage.app_window = window; }); -// Google Analytics stuff begin +// Google Analytics BEGIN +var ga_config; // google analytics config reference +var ga_tracking; // global result of isTrackingPermitted + var service = analytics.getService('ice_cream_app'); +service.getConfig().addCallback(function(config) { + ga_config = config; + ga_tracking = config.isTrackingPermitted(); +}); + var ga_tracker = service.getTracker('UA-32728876-6'); ga_tracker.sendAppView('Application Started'); -// Google Analytics stuff end +// Google Analytics END $(document).ready(function() { // translate to user-selected language @@ -42,13 +50,16 @@ $(document).ready(function() { var tabs = $('#tabs > ul'); $('a', tabs).click(function() { if ($(this).parent().hasClass('active') == false) { // only initialize when the tab isn't already active - if (configuration_received == false) { // if there is no active connection, return + var self = this; + var index = $(self).parent().index(); + + // i am using hardcoded index here (for options tab) since i don't have time to write tab locking mechanism at the moment + // if there is no active connection, return + if (configuration_received == false && index != 9) { GUI.log('You need to connect before you can view any of the tabs', 'red'); return; } - var self = this; - GUI.tab_switch_cleanup(function() { // disable previously active tab highlight $('li', tabs).removeClass('active'); @@ -90,6 +101,9 @@ $(document).ready(function() { case 'tab_cli': tab_initialize_cli(); break; + case 'tab_options': + tab_initialize_options(); + break; } }); } diff --git a/tabs/options.css b/tabs/options.css new file mode 100644 index 0000000000..f28727529d --- /dev/null +++ b/tabs/options.css @@ -0,0 +1,9 @@ +.tab-options { + line-height: 20px; +} + .tab-options input { + float: left; + + margin-top: 3px; + margin-right: 5px; + } \ No newline at end of file diff --git a/tabs/options.html b/tabs/options.html new file mode 100644 index 0000000000..2a2bfd91e5 --- /dev/null +++ b/tabs/options.html @@ -0,0 +1,9 @@ +
    +
    + +
    +
    + +
    + +
    \ No newline at end of file diff --git a/tabs/options.js b/tabs/options.js new file mode 100644 index 0000000000..7a62e52207 --- /dev/null +++ b/tabs/options.js @@ -0,0 +1,45 @@ +function tab_initialize_options() { + ga_tracker.sendAppView('Options'); + + $('#content').load("./tabs/options.html", function() { + GUI.active_tab = 'options'; + + // translate to user-selected language + localize(); + + if (configuration_received) { + $('a.back').hide(); + } else { + $('a.back').click(function() { + $('#tabs > ul li').removeClass('active'); // de-select any selected tabs + tab_initialize_default(); + }); + } + + // if notifications are enabled, or wasn't set, check the notifications checkbox + chrome.storage.local.get('update_notify', function(result) { + if (typeof result.update_notify === 'undefined' || result.update_notify) { + $('div.notifications input').prop('checked', true); + } + }); + + $('div.notifications input').change(function() { + var check = $(this).is(':checked'); + + chrome.storage.local.set({'update_notify': check}); + }); + + // if tracking is enabled, check the statistics checkbox + if (ga_tracking == true) { + $('div.statistics input').prop('checked', true); + } + + $('div.statistics input').change(function() { + var check = $(this).is(':checked'); + + ga_tracking = check; + + ga_config.setTrackingPermitted(check); + }); + }); +} \ No newline at end of file