--- a/browser/components/preferences/in-content/SearchEach.js
+++ b/browser/components/preferences/in-content/SearchEach.js
@@ -107,16 +107,17 @@ function stringMatchesFilters(str, filte
return !filterStrings.some(function(f) {
return searchStr.indexOf(f) == -1;
});
}
function nodeRecursion(nodeObject, searchPhrase, findSelection) {
let foundIn = false;
if (nodeObject.childElementCount == 0) {
+
let leafTextNodes, otherTextNodes = [];
let listOfWords = searchPhrase.trim().split(); // List of words to search from
// Searching in the Text Nodes
if (nodeObject) {
leafTextNodes = textNodesUnder(nodeObject);
}
if (nodeObject.boxObject) {
@@ -149,16 +150,17 @@ function nodeRecursion(nodeObject, searc
});
listOfWords.forEach(function(word) {
let boolAns = multiSearch(otherTextNodes, nodeSizes, allNodeText, word, findSelection);
// searchWord(node,node.textContent,word,findSelection)
foundIn = foundIn || boolAns;
});
+
// Searching in the buttons
listOfWords.forEach(function(word) {
let boolAns = getLabelAttribute(nodeObject, word);
foundIn = foundIn || boolAns;
// if (getLabelAttribute(nodeObject,word)){
// console.log(nodeObject)
// foundIn = true
// }
@@ -168,18 +170,19 @@ function nodeRecursion(nodeObject, searc
listOfWords.forEach(function(word) {
let boolAns = getValueAttribute(nodeObject, word, findSelection);
foundIn = foundIn || boolAns;
// if (getLabelAttribute(nodeObject,word)){
// console.log(nodeObject)
// foundIn = true
// }
});
+
}
- for (let i = 0; i < nodeObject.childElementCount; i++) {
+ for (let i = 0; i < nodeObject.childNodes.length; i++) {
let boolAns = nodeRecursion(nodeObject.childNodes[i], searchPhrase, findSelection);
foundIn = foundIn || boolAns;
// foundIn = foundIn || nodeRecursion(nodeObject.childNodes[i], searchPhrase, findSelection)
}
return foundIn;
}
// http:// stackoverflow.com/questions/10730309/find-all-text-nodes-in-html-page
@@ -195,16 +198,20 @@ function textNodesUnder(node) {
function searchWord(textNode, textSearch, word, findSelection) {
let regExp = new RegExp(word, "gi");
let result, indices = [];
while ((result = regExp.exec(textSearch))) {
indices.push(result.index);
}
+ if (indices.length > 0 ){
+ console.log("Search Word",textNode, textSearch)
+ }
+
// Add each found word to range
for (let i = 0; i < indices.length; i++) {
let range = document.createRange();
range.setStart(textNode, indices[i]);
range.setEnd(textNode, (indices[i] + word.length) );
findSelection.addRange(range); // Add each range to be highlighted
}
return indices.length > 0;
@@ -213,23 +220,26 @@ function searchWord(textNode, textSearch
function multiSearch(textNodes, nodeSizes, textSearch, word, findSelection) {
let regExp = new RegExp(word, "gi");
let result, indices = [];
while ((result = regExp.exec(textSearch))) {
indices.push(result.index);
}
- /* if (indices.length > 0){
- console.log("Other words")
- console.log(textNodes)
- console.log(nodeSizes)
- console.log(textSearch)
- console.log("End other words")
- } */
+ /*
+ if (indices.length > 0){
+ console.log("Multi Searcb",textNodes,textSearch)
+ //console.log("Other words")
+ //console.log(textNodes)
+ //console.log(nodeSizes)
+ //console.log(textSearch)
+ //console.log("End other words")
+ }
+ */
indices.forEach(function(startValue, startIndex) {
let endValue = startValue + word.length;
let startNode = null;
let endNode = null;
let nodeStartIndex = null;
nodeSizes.forEach(function(lengthNodes, index) {
if (!startNode && lengthNodes >= startValue) {