alessandro trinca tornidor
commited on
Commit
·
9074889
1
Parent(s):
a0b0525
feat: now result search is case-insensitive
Browse filesresult search works on actual words (not only stemmings)
- static/index.js +10 -20
static/index.js
CHANGED
|
@@ -551,27 +551,17 @@ function dynamicSort(property, order) {
|
|
| 551 |
}
|
| 552 |
|
| 553 |
/**
|
| 554 |
-
*
|
|
|
|
| 555 |
*
|
| 556 |
-
* @
|
| 557 |
-
*
|
| 558 |
-
*
|
| 559 |
-
*
|
| 560 |
-
* @param {array} arr - The array to filter.
|
| 561 |
-
* @param {string} key - The property key to match against.
|
| 562 |
-
* @param {string} value - The value to search for in the array elements.
|
| 563 |
-
* @returns {array} A new array containing only the elements that match the specified value.
|
| 564 |
*/
|
| 565 |
-
function
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
let currentValue = currentElement[key]
|
| 570 |
-
if(currentValue.toLowerCase().includes(value)) {
|
| 571 |
-
newArray.push(arr[i]);
|
| 572 |
-
}
|
| 573 |
-
}
|
| 574 |
-
return newArray;
|
| 575 |
}
|
| 576 |
|
| 577 |
/**
|
|
@@ -599,7 +589,7 @@ async function updateWordsFrequencyTables() {
|
|
| 599 |
let inputFilter = document.getElementById("filter-words-frequency")
|
| 600 |
let inputFilterValue = inputFilter.value
|
| 601 |
if (inputFilterValue !== undefined && inputFilter.value !== "") {
|
| 602 |
-
reduced =
|
| 603 |
}
|
| 604 |
|
| 605 |
let listOfWords = document.getElementById("id-list-of-words")
|
|
|
|
| 551 |
}
|
| 552 |
|
| 553 |
/**
|
| 554 |
+
* Filters an array of objects by checking if a specified nested value exists within any object.
|
| 555 |
+
* The search is case-insensitive and checks all nested properties by converting the object to a JSON string.
|
| 556 |
*
|
| 557 |
+
* @param {Array<Object>} array - The array of objects to filter.
|
| 558 |
+
* @param {string} nestedValue - The value to search for within the objects.
|
| 559 |
+
* @returns {Array<Object>} - A new array containing objects where the nested value is found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
*/
|
| 561 |
+
function arrayFilterNestedValue(array, nestedValue) {
|
| 562 |
+
return array.filter(item => {
|
| 563 |
+
return JSON.stringify(item).toLowerCase().includes(nestedValue.toLowerCase());
|
| 564 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
}
|
| 566 |
|
| 567 |
/**
|
|
|
|
| 589 |
let inputFilter = document.getElementById("filter-words-frequency")
|
| 590 |
let inputFilterValue = inputFilter.value
|
| 591 |
if (inputFilterValue !== undefined && inputFilter.value !== "") {
|
| 592 |
+
reduced = arrayFilterNestedValue(reduced, inputFilterValue)
|
| 593 |
}
|
| 594 |
|
| 595 |
let listOfWords = document.getElementById("id-list-of-words")
|