Skip to content

Commit

Permalink
Add search by item id
Browse files Browse the repository at this point in the history
  • Loading branch information
123jjck authored Mar 1, 2024
1 parent f464ca4 commit 043b38f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions list.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ class Table {

html += '</thead><tbody>';

if (query.trim().length >= 2) {
query = query.trim();
if (query.length >= 2 || !isNaN(query)) {
query = this.normalizeString(query);
for (let i in items) {
let normalizedName = this.normalizeString(items[i].Name);
if (normalizedName.indexOf(query) !== -1) {
if (normalizedName.indexOf(query) !== -1 || items[i].Id == query) {
let itemToRender = Object.assign({}, items[i]); // copy item
let normalizedNameWithQuotes = this.normalizeStringKeepQuotes(items[i].Name);

Expand All @@ -223,8 +224,9 @@ class Table {
itemToRender["Name"] += '</mark>';
}
}
itemToRender["Name"] += items[i]['Name'][letterIndex];
itemToRender["Name"] += items[i]["Name"][letterIndex];
}
if(items[i].Id == query) itemToRender["Id"] = '<mark>' + itemToRender['Id'] + '</mark>';
html += this.renderElement(itemToRender);
}
}
Expand Down

0 comments on commit 043b38f

Please sign in to comment.