mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 21:38:11 +01:00
Fix case-insensitive hint matching.
This commit is contained in:
@@ -135,8 +135,7 @@ function Hints() //{{{
|
|||||||
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none")
|
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO: mozilla docs recommend localName instead of tagName
|
tagname = elem.localName.toLowerCase();
|
||||||
tagname = elem.tagName.toLowerCase();
|
|
||||||
if (tagname == "input" || tagname == "textarea")
|
if (tagname == "input" || tagname == "textarea")
|
||||||
text = elem.value;
|
text = elem.value;
|
||||||
else if (tagname == "select")
|
else if (tagname == "select")
|
||||||
@@ -363,16 +362,21 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function hintMatcher(hintString) //{{{
|
function hintMatcher(hintString) //{{{
|
||||||
{
|
{
|
||||||
|
function tokenize(pat, string) string.split(pat).map(String.toLowerCase);
|
||||||
function containsMatcher(hintString) //{{{
|
function containsMatcher(hintString) //{{{
|
||||||
{
|
{
|
||||||
var tokens = hintString.split(/ +/);
|
var tokens = tokenize(/\s+/, hintString);
|
||||||
return function (linkText) tokens.every(function (token) linkText.indexOf(token) >= 0);
|
return function (linkText)
|
||||||
|
{
|
||||||
|
linkText = linkText.toLowerCase();
|
||||||
|
return tokens.every(function (token) linkText.indexOf(token) >= 0);
|
||||||
|
}
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{
|
function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{
|
||||||
{
|
{
|
||||||
var hintStrings = hintString.split(/ +/);
|
var hintStrings = tokenize(/\s+/, hintString);
|
||||||
var wordSplitRegex = new RegExp(options["wordseparators"]);
|
var wordSplitRegex = RegExp(options["wordseparators"]);
|
||||||
|
|
||||||
// What the **** does this do? --Kris
|
// What the **** does this do? --Kris
|
||||||
function charsAtBeginningOfWords(chars, words, allowWordOverleaping)
|
function charsAtBeginningOfWords(chars, words, allowWordOverleaping)
|
||||||
@@ -484,19 +488,17 @@ function Hints() //{{{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wordStartsWith(linkText)
|
return function (linkText)
|
||||||
{
|
{
|
||||||
if (hintStrings.length == 1 && hintStrings[0].length == 0)
|
if (hintStrings.length == 1 && hintStrings[0].length == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
let words = linkText.split(wordSplitRegex).map(String.toLowerCase);
|
let words = tokenize(linkText, wordSplitRegex);
|
||||||
if (hintStrings.length == 1)
|
if (hintStrings.length == 1)
|
||||||
return charsAtBeginningOfWords(hintStrings[0], words, allowWordOverleaping);
|
return charsAtBeginningOfWords(hintStrings[0], words, allowWordOverleaping);
|
||||||
else
|
else
|
||||||
return stringsAtBeginningOfWords(hintStrings, words, allowWordOverleaping);
|
return stringsAtBeginningOfWords(hintStrings, words, allowWordOverleaping);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wordStartsWith;
|
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
var hintMatching = options["hintmatching"];
|
var hintMatching = options["hintmatching"];
|
||||||
|
|||||||
Reference in New Issue
Block a user