mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 06:07:59 +01:00
prefer let over var in Hints
This commit is contained in:
@@ -107,19 +107,19 @@ function Hints() //{{{
|
|||||||
if (!win)
|
if (!win)
|
||||||
win = window.content;
|
win = window.content;
|
||||||
|
|
||||||
var doc = win.document;
|
let doc = win.document;
|
||||||
var height = win.innerHeight;
|
let height = win.innerHeight;
|
||||||
var width = win.innerWidth;
|
let width = win.innerWidth;
|
||||||
var scrollX = doc.defaultView.scrollX;
|
let scrollX = doc.defaultView.scrollX;
|
||||||
var scrollY = doc.defaultView.scrollY;
|
let scrollY = doc.defaultView.scrollY;
|
||||||
|
|
||||||
var baseNodeAbsolute = util.xmlToDom(<span highlight="Hint"/>, doc);
|
let baseNodeAbsolute = util.xmlToDom(<span highlight="Hint"/>, doc);
|
||||||
|
|
||||||
var elem, tagname, text, span, rect;
|
let elem, tagname, text, span, rect;
|
||||||
var res = buffer.evaluateXPath(hintMode.tags(), doc, null, true);
|
let res = buffer.evaluateXPath(hintMode.tags(), doc, null, true);
|
||||||
|
|
||||||
var fragment = util.xmlToDom(<div highlight="hints"/>, doc);
|
let fragment = util.xmlToDom(<div highlight="hints"/>, doc);
|
||||||
var start = pageHints.length;
|
let start = pageHints.length;
|
||||||
for (let elem in res)
|
for (let elem in res)
|
||||||
{
|
{
|
||||||
// TODO: for iframes, this calculation is wrong
|
// TODO: for iframes, this calculation is wrong
|
||||||
@@ -131,7 +131,7 @@ function Hints() //{{{
|
|||||||
if (!rect)
|
if (!rect)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var computedStyle = doc.defaultView.getComputedStyle(elem, null);
|
let computedStyle = doc.defaultView.getComputedStyle(elem, null);
|
||||||
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none")
|
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -171,11 +171,11 @@ function Hints() //{{{
|
|||||||
// TODO: make it aware of imgspans
|
// TODO: make it aware of imgspans
|
||||||
function showActiveHint(newID, oldID)
|
function showActiveHint(newID, oldID)
|
||||||
{
|
{
|
||||||
var oldElem = validHints[oldID - 1];
|
let oldElem = validHints[oldID - 1];
|
||||||
if (oldElem)
|
if (oldElem)
|
||||||
setClass(oldElem, false);
|
setClass(oldElem, false);
|
||||||
|
|
||||||
var newElem = validHints[newID - 1];
|
let newElem = validHints[newID - 1];
|
||||||
if (newElem)
|
if (newElem)
|
||||||
setClass(newElem, true);
|
setClass(newElem, true);
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function removeHints(timeout)
|
function removeHints(timeout)
|
||||||
{
|
{
|
||||||
var firstElem = validHints[0] || null;
|
let firstElem = validHints[0] || null;
|
||||||
|
|
||||||
for (let [,{ doc: doc, start: start, end: end }] in Iterator(docs))
|
for (let [,{ doc: doc, start: start, end: end }] in Iterator(docs))
|
||||||
{
|
{
|
||||||
@@ -329,9 +329,9 @@ function Hints() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeout = followFirst || events.feedingKeys ? 0 : 500;
|
let timeout = followFirst || events.feedingKeys ? 0 : 500;
|
||||||
var activeIndex = (hintNumber ? hintNumber - 1 : 0);
|
let activeIndex = (hintNumber ? hintNumber - 1 : 0);
|
||||||
var elem = validHints[activeIndex];
|
let elem = validHints[activeIndex];
|
||||||
removeHints(timeout);
|
removeHints(timeout);
|
||||||
|
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
@@ -369,7 +369,7 @@ function Hints() //{{{
|
|||||||
function tokenize(pat, string) string.split(pat).map(String.toLowerCase);
|
function tokenize(pat, string) string.split(pat).map(String.toLowerCase);
|
||||||
function containsMatcher(hintString) //{{{
|
function containsMatcher(hintString) //{{{
|
||||||
{
|
{
|
||||||
var tokens = tokenize(/\s+/, hintString);
|
let tokens = tokenize(/\s+/, hintString);
|
||||||
return function (linkText)
|
return function (linkText)
|
||||||
{
|
{
|
||||||
linkText = linkText.toLowerCase();
|
linkText = linkText.toLowerCase();
|
||||||
@@ -379,14 +379,14 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{
|
function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{
|
||||||
{
|
{
|
||||||
var hintStrings = tokenize(/\s+/, hintString);
|
let hintStrings = tokenize(/\s+/, hintString);
|
||||||
var wordSplitRegex = RegExp(options["wordseparators"]);
|
let 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)
|
||||||
{
|
{
|
||||||
var charIdx = 0;
|
let charIdx = 0;
|
||||||
var numMatchedWords = 0;
|
let numMatchedWords = 0;
|
||||||
for (let [,word] in Iterator(words))
|
for (let [,word] in Iterator(words))
|
||||||
{
|
{
|
||||||
if (word.length == 0)
|
if (word.length == 0)
|
||||||
@@ -414,7 +414,7 @@ function Hints() //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// the current word matches same characters as the previous word
|
// the current word matches same characters as the previous word
|
||||||
var prevCharIdx;
|
let prevCharIdx;
|
||||||
if (wcIdx > 0)
|
if (wcIdx > 0)
|
||||||
{
|
{
|
||||||
prevCharIdx = charIdx;
|
prevCharIdx = charIdx;
|
||||||
@@ -468,7 +468,7 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function stringsAtBeginningOfWords(strings, words, allowWordOverleaping)
|
function stringsAtBeginningOfWords(strings, words, allowWordOverleaping)
|
||||||
{
|
{
|
||||||
var strIdx = 0;
|
let strIdx = 0;
|
||||||
for (let [,word] in Iterator(words))
|
for (let [,word] in Iterator(words))
|
||||||
{
|
{
|
||||||
if (word.length == 0)
|
if (word.length == 0)
|
||||||
@@ -505,7 +505,7 @@ function Hints() //{{{
|
|||||||
}
|
}
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
var hintMatching = options["hintmatching"];
|
let hintMatching = options["hintmatching"];
|
||||||
switch (hintMatching)
|
switch (hintMatching)
|
||||||
{
|
{
|
||||||
case "contains" : return containsMatcher(hintString);
|
case "contains" : return containsMatcher(hintString);
|
||||||
@@ -655,8 +655,8 @@ function Hints() //{{{
|
|||||||
|
|
||||||
onEvent: function (event)
|
onEvent: function (event)
|
||||||
{
|
{
|
||||||
var key = events.toString(event);
|
let key = events.toString(event);
|
||||||
var followFirst = false;
|
let followFirst = false;
|
||||||
|
|
||||||
// clear any timeout which might be active after pressing a number
|
// clear any timeout which might be active after pressing a number
|
||||||
if (activeTimeout)
|
if (activeTimeout)
|
||||||
@@ -677,7 +677,7 @@ function Hints() //{{{
|
|||||||
if (hintNumber == 0)
|
if (hintNumber == 0)
|
||||||
hintNumber = 1;
|
hintNumber = 1;
|
||||||
|
|
||||||
var oldID = hintNumber;
|
let oldID = hintNumber;
|
||||||
if (key == "<Tab>")
|
if (key == "<Tab>")
|
||||||
{
|
{
|
||||||
if (++hintNumber > validHints.length)
|
if (++hintNumber > validHints.length)
|
||||||
@@ -721,7 +721,7 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
prevInput = "number";
|
prevInput = "number";
|
||||||
|
|
||||||
var oldHintNumber = hintNumber;
|
let oldHintNumber = hintNumber;
|
||||||
if (hintNumber == 0 || usedTabKey)
|
if (hintNumber == 0 || usedTabKey)
|
||||||
{
|
{
|
||||||
usedTabKey = false;
|
usedTabKey = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user