Make printer model search more flexible (#9050)

The printer model search can be hard to use, depending on how profiles
are named. This makes it a little easier by matching on both the vendor
and model name, and tokenizing the query and matching all of the tokens,
instead of trying to find the whole query substring in the model name.
This commit is contained in:
Russell Cloran 2025-03-24 17:59:32 -07:00 committed by GitHub
parent 41450b3a64
commit 108eeaed0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -216,14 +216,16 @@ function FilterModelList(keyword) {
let nTotal = pModel.length;
let ModelHtml = {};
let kwSplit = keyword.toLowerCase().match(/\S+/g) || [];
$('#Content').empty();
for (let n = 0; n < nTotal; n++) {
let OneModel = pModel[n];
let strVendor = OneModel['vendor'];
let ModelName = OneModel['model'];
if (ModelName.toLowerCase().indexOf(keyword.toLowerCase()) == -1)
let search = (OneModel['model'] + '\0' + strVendor).toLowerCase();
if (!kwSplit.every(s => search.includes(s)))
continue;
//Add Vendor Html Node