1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-25 09:15:42 +03:00

Enhanced feature to make more flexible

This commit is contained in:
Darren Lines 2022-01-20 19:32:13 +00:00
parent fe5a1cf6ca
commit beab87b9db
3 changed files with 43 additions and 1 deletions

View file

@ -3427,6 +3427,9 @@
"osd_switch_indicator_settings": {
"message" : "Switch Indicator Settings"
},
"osd_switch_indicators_align_left": {
"message" : "Align switch names to left of switches"
},
"osdSwitchInd0": {
"message" : "Switch 1"
},

View file

@ -240,6 +240,10 @@
<div class="spacer_box_title" data-i18n="osd_switch_indicator_settings"></div>
</div>
<div class="spacer_box settings">
<label>
<input type="checkbox" id="switchIndicators_alignLeft" data-setting="osd_switch_indicators_align_left" data-live="true" class="toggle"></select>
<span data-i18n="osd_switch_indicators_align_left"></span>
</label>
<label>
<input type="text" class="osdSwitchIndName" id="osdSwitchInd0_name" data-setting="osd_switch_indicator_zero_name" />
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_zero_channnel" data-live="true"></select>

View file

@ -2513,6 +2513,9 @@ OSD.GUI.updateFields = function() {
// TODO: If we add more switches somewhere else, this
// needs to be called after all of them have been set up
GUI.switchery();
// Update the OSD preview
refreshOSDSwitchIndicators();
};
OSD.GUI.removeBottomLines = function(){
@ -2879,8 +2882,9 @@ TABS.osd.initialize = function (callback) {
$(this).text("Ch " + $(this).text());
});
// Make sure that the switch hint only contains A to Z
// Function when text for switch indicators change
$('.osdSwitchIndName').on('keyup', function() {
// Make sure that the switch hint only contains A to Z
let testExp = new RegExp('^[A-Za-z0-9]');
let testText = $(this).val();
if (testExp.test(testText.slice(-1))) {
@ -2888,6 +2892,14 @@ TABS.osd.initialize = function (callback) {
} else {
$(this).val(testText.slice(0, -1));
}
// Update the OSD preview
refreshOSDSwitchIndicators();
});
// Function to update the OSD layout when the switch text alignment changes
$("#switchIndicators_alignLeft").on('change', function() {
refreshOSDSwitchIndicators();
});
// font preview window
@ -3029,6 +3041,29 @@ TABS.osd.initialize = function (callback) {
}));
};
function refreshOSDSwitchIndicators() {
let group = OSD.constants.ALL_DISPLAY_GROUPS.filter(function(e) {
return e.name == "osdGroupSwitchIndicators";
})[0];
for (let si = 0; si < group.items.length; si++) {
let item = group.items[si];
if ($("#osdSwitchInd" + si +"_name").val() != undefined) {
let switchIndText = $("#osdSwitchInd" + si +"_name").val();
if (switchIndText == "") {
item.preview = FONT.symbol(SYM.SWITCH_INDICATOR_HIGH);
} else {
if ($("#switchIndicators_alignLeft").prop('checked')) {
item.preview = switchIndText + FONT.symbol(SYM.SWITCH_INDICATOR_HIGH);
} else {
item.preview = FONT.symbol(SYM.SWITCH_INDICATOR_HIGH) + switchIndText;
}
}
}
}
OSD.GUI.updatePreviews();
}
TABS.osd.cleanup = function (callback) {
PortHandler.flush_callbacks();