mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-26 09:45:23 +03:00
Enhanced feature to make more flexible
This commit is contained in:
parent
fe5a1cf6ca
commit
beab87b9db
3 changed files with 43 additions and 1 deletions
|
@ -3427,6 +3427,9 @@
|
||||||
"osd_switch_indicator_settings": {
|
"osd_switch_indicator_settings": {
|
||||||
"message" : "Switch Indicator Settings"
|
"message" : "Switch Indicator Settings"
|
||||||
},
|
},
|
||||||
|
"osd_switch_indicators_align_left": {
|
||||||
|
"message" : "Align switch names to left of switches"
|
||||||
|
},
|
||||||
"osdSwitchInd0": {
|
"osdSwitchInd0": {
|
||||||
"message" : "Switch 1"
|
"message" : "Switch 1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -240,6 +240,10 @@
|
||||||
<div class="spacer_box_title" data-i18n="osd_switch_indicator_settings"></div>
|
<div class="spacer_box_title" data-i18n="osd_switch_indicator_settings"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer_box settings">
|
<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>
|
<label>
|
||||||
<input type="text" class="osdSwitchIndName" id="osdSwitchInd0_name" data-setting="osd_switch_indicator_zero_name" />
|
<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>
|
<select class="osdSwitchInd_channel" data-setting="osd_switch_indicator_zero_channnel" data-live="true"></select>
|
||||||
|
|
37
tabs/osd.js
37
tabs/osd.js
|
@ -2513,6 +2513,9 @@ OSD.GUI.updateFields = function() {
|
||||||
// TODO: If we add more switches somewhere else, this
|
// TODO: If we add more switches somewhere else, this
|
||||||
// needs to be called after all of them have been set up
|
// needs to be called after all of them have been set up
|
||||||
GUI.switchery();
|
GUI.switchery();
|
||||||
|
|
||||||
|
// Update the OSD preview
|
||||||
|
refreshOSDSwitchIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
OSD.GUI.removeBottomLines = function(){
|
OSD.GUI.removeBottomLines = function(){
|
||||||
|
@ -2879,8 +2882,9 @@ TABS.osd.initialize = function (callback) {
|
||||||
$(this).text("Ch " + $(this).text());
|
$(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() {
|
$('.osdSwitchIndName').on('keyup', function() {
|
||||||
|
// Make sure that the switch hint only contains A to Z
|
||||||
let testExp = new RegExp('^[A-Za-z0-9]');
|
let testExp = new RegExp('^[A-Za-z0-9]');
|
||||||
let testText = $(this).val();
|
let testText = $(this).val();
|
||||||
if (testExp.test(testText.slice(-1))) {
|
if (testExp.test(testText.slice(-1))) {
|
||||||
|
@ -2888,6 +2892,14 @@ TABS.osd.initialize = function (callback) {
|
||||||
} else {
|
} else {
|
||||||
$(this).val(testText.slice(0, -1));
|
$(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
|
// 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) {
|
TABS.osd.cleanup = function (callback) {
|
||||||
PortHandler.flush_callbacks();
|
PortHandler.flush_callbacks();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue