Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

speed up search in OSD tab #2174

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ OSD.GUI.updateUnits = function() {
});
};

OSD.GUI.updateFields = function() {
OSD.GUI.updateFields = function(event) {
// display fields on/off and position
var $tmpl = $('#osd_group_template').hide();
// Clear previous groups, if any
Expand Down Expand Up @@ -2702,6 +2702,7 @@ OSD.GUI.updateFields = function() {
});
}
var $displayFields = groupContainer.find('.display-fields');
var osdSearch = $('.osd_search');
for (var jj = 0; jj < groupItems.length; jj++) {
var item = groupItems[jj];
var itemData = OSD.data.items[item.id];
Expand All @@ -2715,7 +2716,7 @@ OSD.GUI.updateFields = function() {
} else {
name = inflection.titleize(name);
}
var searchTerm = $('.osd_search').val();
var searchTerm = osdSearch.val();
if (searchTerm.length > 0 && !name.toLowerCase().includes(searchTerm.toLowerCase())) {
continue;
}
Expand Down Expand Up @@ -2811,10 +2812,13 @@ OSD.GUI.updateFields = function() {
// needs to be called after all of them have been set up
GUI.switchery();

// Update the OSD preview
refreshOSDSwitchIndicators();
updatePilotAndCraftNames();
updatePanServoPreview();
if(event != null && event.currentTarget !== osdSearch[0])
{
// Update the OSD preview
refreshOSDSwitchIndicators();
updatePilotAndCraftNames();
updatePanServoPreview();
}
};

OSD.GUI.removeBottomLines = function(){
Expand Down Expand Up @@ -3210,8 +3214,8 @@ OSD.GUI.updateAll = function() {
clear.off('change');
}

$('.osd_search').on('input', function() {
OSD.GUI.updateFields();
$('.osd_search').on('input', function(event) {
OSD.GUI.updateFields(event);
});
$('.supported').fadeIn();
OSD.GUI.updateVideoMode();
Expand Down
Loading