1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-21 07:15:15 +03:00

Merge pull request #2315 from haslinghuis/osd

This commit is contained in:
Michael Keller 2020-12-16 14:58:29 +01:00 committed by GitHub
commit 4469851a75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 29 deletions

View file

@ -2,7 +2,6 @@
TABS.landing = {}; TABS.landing = {};
TABS.landing.initialize = function (callback) { TABS.landing.initialize = function (callback) {
var self = this;
if (GUI.active_tab != 'landing') { if (GUI.active_tab != 'landing') {
GUI.active_tab = 'landing'; GUI.active_tab = 'landing';
@ -10,10 +9,10 @@ TABS.landing.initialize = function (callback) {
$('#content').load("./tabs/landing.html", function () { $('#content').load("./tabs/landing.html", function () {
function showLang(newLang) { function showLang(newLang) {
var bottomSection = $('.languageSwitcher'); bottomSection = $('.languageSwitcher');
bottomSection.find('a').each(function(index) { bottomSection.find('a').each(function(index) {
var element = $(this); const element = $(this);
var languageSelected = element.attr('lang'); const languageSelected = element.attr('lang');
if (newLang == languageSelected) { if (newLang == languageSelected) {
element.removeClass('selected_language'); element.removeClass('selected_language');
element.addClass('selected_language'); element.addClass('selected_language');
@ -22,18 +21,18 @@ TABS.landing.initialize = function (callback) {
} }
}); });
} }
var bottomSection = $('.languageSwitcher'); let bottomSection = $('.languageSwitcher');
bottomSection.html(' <span i18n="language_choice_message"></span>'); bottomSection.html(' <span i18n="language_choice_message"></span>');
bottomSection.append(' <a href="#" i18n="language_default_pretty" lang="DEFAULT"></a>'); bottomSection.append(' <a href="#" i18n="language_default_pretty" lang="DEFAULT"></a>');
var languagesAvailables = i18n.getLanguagesAvailables(); const languagesAvailables = i18n.getLanguagesAvailables();
languagesAvailables.forEach(function(element) { languagesAvailables.forEach(function(element) {
bottomSection.append(' <a href="#" lang="' + element + '" i18n="language_' + element + '"></a>'); bottomSection.append(' <a href="#" lang="' + element + '" i18n="language_' + element + '"></a>');
}); });
bottomSection.find('a').each(function(index) { bottomSection.find('a').each(function(index) {
var element = $(this); let element = $(this);
element.click(function(){ element.click(function(){
var element = $(this); element = $(this);
var languageSelected = element.attr('lang'); const languageSelected = element.attr('lang');
if (!languageSelected) { return; } if (!languageSelected) { return; }
if (i18n.selectedLanguage != languageSelected) { if (i18n.selectedLanguage != languageSelected) {
i18n.changeLanguage(languageSelected); i18n.changeLanguage(languageSelected);

View file

@ -4,7 +4,7 @@ const DEFAULT_ZOOM = 16,
ICON_IMAGE = '/images/icons/cf_icon_position.png', ICON_IMAGE = '/images/icons/cf_icon_position.png',
ICON_IMAGE_NOFIX = '/images/icons/cf_icon_position_nofix.png'; ICON_IMAGE_NOFIX = '/images/icons/cf_icon_position_nofix.png';
var iconGeometry, let iconGeometry,
map, map,
mapView, mapView,
iconStyle, iconStyle,
@ -15,7 +15,7 @@ window.onload = initializeMap;
function initializeMap() { function initializeMap() {
var lonLat = ol.proj.fromLonLat([DEFAULT_LON, DEFAULT_LAT]); const lonLat = ol.proj.fromLonLat([DEFAULT_LON, DEFAULT_LAT]);
mapView = new ol.View({ mapView = new ol.View({
center: lonLat, center: lonLat,
@ -33,14 +33,14 @@ function initializeMap() {
controls: [] controls: []
}); });
var icon = new ol.style.Icon(({ const icon = new ol.style.Icon(({
anchor: [0.5, 1], anchor: [0.5, 1],
opacity: 1, opacity: 1,
scale: 0.5, scale: 0.5,
src: ICON_IMAGE src: ICON_IMAGE
})); }));
var iconNoFix = new ol.style.Icon(({ const iconNoFix = new ol.style.Icon(({
anchor: [0.5, 1], anchor: [0.5, 1],
opacity: 1, opacity: 1,
scale: 0.5, scale: 0.5,
@ -62,11 +62,11 @@ function initializeMap() {
iconFeature.setStyle(iconStyle); iconFeature.setStyle(iconStyle);
var vectorSource = new ol.source.Vector({ const vectorSource = new ol.source.Vector({
features: [iconFeature] features: [iconFeature]
}); });
var currentPositionLayer = new ol.layer.Vector({ const currentPositionLayer = new ol.layer.Vector({
source: vectorSource source: vectorSource
}); });
@ -90,7 +90,7 @@ function processMapEvents(e) {
case 'center': case 'center':
iconFeature.setStyle(iconStyle); iconFeature.setStyle(iconStyle);
var center = ol.proj.fromLonLat([e.data.lon, e.data.lat]); const center = ol.proj.fromLonLat([e.data.lon, e.data.lat]);
mapView.setCenter(center); mapView.setCenter(center);
iconGeometry.setCoordinates(center); iconGeometry.setCoordinates(center);
break; break;
@ -100,7 +100,7 @@ function processMapEvents(e) {
break; break;
} }
} catch (e) { } catch (err) {
console.log('Map error ' + e); console.log(`Map error ${err}`);
} }
} }

View file

@ -4,7 +4,6 @@ TABS.setup_osd = {
}; };
TABS.setup_osd.initialize = function (callback) { TABS.setup_osd.initialize = function (callback) {
var self = this;
if (GUI.active_tab != 'setup_osd') { if (GUI.active_tab != 'setup_osd') {
GUI.active_tab = 'setup_osd'; GUI.active_tab = 'setup_osd';
@ -25,13 +24,13 @@ TABS.setup_osd.initialize = function (callback) {
function process_html() { function process_html() {
$('.tab-setup-osd .info').hide(); // requires an MSP update $('.tab-setup-osd .info').hide(); // requires an MSP update
/* Only used by get_slow_data() which is commented out.
var osdVideoModes = [ const osdVideoModes = new Set([
'AUTO', 'AUTO',
'NTSC', 'NTSC',
'PAL' 'PAL'
]; ]);
*/
// translate to user-selected language // translate to user-selected language
i18n.localizePage(); i18n.localizePage();
@ -48,10 +47,8 @@ TABS.setup_osd.initialize = function (callback) {
function get_slow_data() { function get_slow_data() {
/* FIXME requires MSP update /* FIXME requires MSP update
MSP.send_message(MSPCodes.MSP_OSD_VIDEO_STATUS, false, false, function () { MSP.send_message(MSPCodes.MSP_OSD_VIDEO_STATUS, false, false, function () {
var element; let element element = $('.video-mode');
const osdVideoMode = osdVideoModes[OSD_VIDEO_STATE.video_mode];
element = $('.video-mode');
var osdVideoMode = osdVideoModes[OSD_VIDEO_STATE.video_mode];
element.text(osdVideoMode); element.text(osdVideoMode);
element = $('.camera-connected'); element = $('.camera-connected');

View file

@ -2,12 +2,11 @@
TABS.staticTab = {}; TABS.staticTab = {};
TABS.staticTab.initialize = function (staticTabName, callback) { TABS.staticTab.initialize = function (staticTabName, callback) {
var self = this;
if (GUI.active_tab != staticTabName) { if (GUI.active_tab != staticTabName) {
GUI.active_tab = staticTabName; GUI.active_tab = staticTabName;
} }
var tabFile = "./tabs/" + staticTabName + ".html"; const tabFile = `./tabs/${staticTabName}.html`;
$('#content').html('<div id="tab-static"><div id="tab-static-contents"></div>'); $('#content').html('<div id="tab-static"><div id="tab-static-contents"></div>');
$('#tab-static-contents').load(tabFile, function () { $('#tab-static-contents').load(tabFile, function () {