Skip to content

Commit

Permalink
Fixed several issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ijkilchenko committed Dec 27, 2015
1 parent 56c7906 commit 16d50b9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
30 changes: 15 additions & 15 deletions content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function parseDom() {

var uniqueWords = new Set();
visibleWords.forEach(function(word) {
uniqueWords.add(sanitize(word));
uniqueWords.add(sanitize(word));
});

sanitizedUniqueVisibleWords = Array.from(uniqueWords);
Expand Down Expand Up @@ -249,21 +249,21 @@ function getMatches(searchText, knn) {
var text = m[1] + '<b>' + m[2] + '</b>' + m[3];
matches[matches.length] = {id: id, thisMatch: matches_by_hash[hash].element.innerHTML,
context: text, element: matches_by_hash[hash].element};
id += 1;
id += 1;
}
j += 1;
if (matches.length > 100) {
break;
}
}
j += 1;
/* Performance condition. We shall care about the first 100 matches only. */
if (matches.length > 100) {
break;
matches = matches.slice(0, 100);
}

}
/* Performance condition. We shall care about the first 100 matches only. */
if (matches.length > 100) {
matches = matches.slice(0, 100);
}

}
/* The following block sorts the matches array based on thisMatch attribute and
how close it is to the original searchText based on the edit-distance score. */
how close it is to the original searchText based on the edit-distance score. */
var cache = {};
matches = matches.sort(function(elem1, elem2) {
var a;
Expand Down Expand Up @@ -319,16 +319,16 @@ function _highlite(node, regex) {
matchElement.parentNode.replaceChild(highlited, matchElement); // replace the middle node with the matchElement
}
} else if (node.nodeType == 1 &&
node.childNodes.length > 0 &&
node.childNodes.length > 0 &&
node.tagName != 'SCRIPT' && // don't change script tags
node.tagName != 'STYLE' && // don't change style tags
node.tagName != 'IMG' &&
node.className != 'fzbl_highlite') { // don't look at something we already inserted
for (var i = 0; i < node.childNodes.length; i++) {
_highlite(node.childNodes[i], regex);
}
for (var i = 0; i < node.childNodes.length; i++) {
_highlite(node.childNodes[i], regex);
}
}
}

function unhighlite() {
var highlited = document.getElementsByClassName('fzbl_highlite');
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fuzbal",
"version": "0.92",
"version": "0.93",
"manifest_version": 2,
"description": "Gives Ctrl+F like find results which include non-exact (fuzzy) matches. ",
"icons": {
Expand Down
17 changes: 8 additions & 9 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ <h1>Fuzbal</h1>
</div>

<div id="helpTips" style="display:none">
<h1>Welcome to Fuzbal
<h1>Fuzbal v.0.93 (beta)
</h1>
<p>Fuzbal gives Ctrl+F like find results which include non-exact (fuzzy) matches. The fuzziness comes from trying to match potentially
misspellet words and words that are often seen together in context. The former uses Damerau-Levenshtein string edit distance while
the latter uses word2vec trained language model. The language dictionary file takes up 99% of the extension's size and so all searches are
done locally.
misspellet words and words that are often seen together in context (synonyms). The former uses <a href="https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance">
Damerau-Levenshtein string edit distance</a> while
the latter uses <a href="http://nlp.stanford.edu/projects/glove/">GloVe</a> pre-trained word vectors. The language file is included
with the extension and so all searches are done locally.
</p>
<p>Each opened page is preprocessed even if the extension is never used on that page. In the future versions, we may give an option to disable
this feature in some settings page.
<p><b>Tip:</b> Use UP/DOWN arrow keys to cycle through results.
</p>
<p>Use <b>Ctrl+Shift+K</b> to open the extension.
</p>
<p>Use up/down arrow keys to cycle through results.
<p><b>Tip:</b> Try <b>Ctrl+Shift+K</b> (<b>Command</b> on a Mac) to open/close the extension or <a href="http://lifehacker.com/add-custom-keyboard-shortcuts-to-chrome-extensions-for-1595322121">
set a custom shortcut</a> if this combination is already taken.
</p>
<p><a href="https://github.com/ijkilchenko/Fuzbal">Fuzbal is open source</a>
</p>
Expand Down
18 changes: 9 additions & 9 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ document.getElementById("help").addEventListener("click", function(e) {
sendAndReceive();
})

var tips = ['<b>Tip</b>: Use <b>Ctrl+Shift+K</b> to open/close the extension. ',
var tips = ['<b>Tip:</b> Try <b>Ctrl+Shift+K</b> (<b>Command</b> on a Mac) to open/close the extension or <a href="http://lifehacker.com/add-custom-keyboard-shortcuts-to-chrome-extensions-for-1595322121">set a custom shortcut</a> if this combination is already taken. ',
'<b>Info:</b> Synonyms and related words are found locally in a dictionary file. ',
'<b>Tip:</b>: Press ENTER to go down the match list. ',
'<b>Tip:</b> Use UP/DOWN keys to cycle up and down the match list. ',
'<b>Info:</b> Edit distance between phrases gives roughly the number of letters out of place between the phrases. ',
'<b>Tip:</b> To search by synonyms and related words, be sure to enter your words fully. '];
'<b>Tip:</b> Clicking on a find result will scroll your window to where the result appears on the page. ',
'<b>Tip:</b> Press ENTER to go down the match list. ',
'<b>Tip:</b> Use UP/DOWN keys to cycle up and down the match list. ',
'<b>Info:</b> The current find result is highlighted in green and others are highlighted in yellow. '];

window.onload = function() {
document.getElementById("searchText").value = 'loading...';
Expand All @@ -140,8 +140,8 @@ window.onload = function() {
};

$(document).ready(function(){
$('body').on('click', 'a', function(){
chrome.tabs.create({url: $(this).attr('href')});
return false;
});
$('body').on('click', 'a', function(){
chrome.tabs.create({url: $(this).attr('href')});
return false;
});
});

0 comments on commit 16d50b9

Please sign in to comment.