Skip to content
Open
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
22 changes: 16 additions & 6 deletions portfolio/src/main/webapp/assets/js/testimonials.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,23 @@ function filterFunction() {
filter = input.value.toUpperCase();
ul = document.getElementById("testimonialUl");
li = ul.getElementsByTagName("li");
const stringArray = [];
for (i = 0; i < li.length; i++) {
blockQuote = li[i].getElementsByTagName("blockquote")[0];
p = blockQuote.getElementsByTagName("p")[0];
txtValue = p.textContent || p.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
stringArray.push(txtValue.toUpperCase());

// set all of the list items to disapear so that they can be made to reapear later
li[i].style.display = "none";
}

// TODO: give user feedback that only one term is supported https://github.com/jackdavidweber/step-portfolio/pull/26#discussion_r443534422
const matches = distanceOfArr(stringArray, filter, 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider giving the user feedback that only one term is supported. Fine to just add a todo comment for now.


// make matches re-appear
for (let i=0; i < matches.length; i++){
li[matches[i].arrIndex].style.display = "";
}
}

Expand Down Expand Up @@ -171,11 +179,13 @@ function findEditDistance(w1,w2){

*/
function distanceOfArr(arrSentences, term, maxED){
let tracker = 0
let retArray = []
for (const sentence of arrSentences){
let ed = minEditDistanceWord(sentence, term)
if(ed < maxED){
retArray.push({"sentence": sentence, "editDistance": ed});
retArray.push({"sentence": sentence, "editDistance": ed, "arrIndex": tracker});
tracker++;
}
}
return retArray;
Expand Down