rename vars
This commit is contained in:
parent
93cefc518a
commit
463c9d9e90
1 changed files with 9 additions and 9 deletions
|
@ -80,7 +80,7 @@ Ox.highlightHTML <f> Highlight matches in an HTML string
|
||||||
> Ox.highlightHTML('a <br> c', 'b', 'h')
|
> Ox.highlightHTML('a <br> c', 'b', 'h')
|
||||||
'a <br> c'
|
'a <br> c'
|
||||||
@*/
|
@*/
|
||||||
Ox.highlightHTML = function(html, str, classname, tags) {
|
Ox.highlightHTML = function(html, string, classname, tags) {
|
||||||
var count = 0,
|
var count = 0,
|
||||||
isEntity = false,
|
isEntity = false,
|
||||||
isTag = false,
|
isTag = false,
|
||||||
|
@ -99,12 +99,12 @@ Ox.highlightHTML = function(html, str, classname, tags) {
|
||||||
// other
|
// other
|
||||||
'a', 'br', 'img',
|
'a', 'br', 'img',
|
||||||
]);
|
]);
|
||||||
str = Ox.encodeHTML(str).toLowerCase();
|
string = Ox.encodeHTML(string).toLowerCase();
|
||||||
Ox.forEach(html.toLowerCase(), function(chr, i) {
|
Ox.forEach(html.toLowerCase(), function(char, i) {
|
||||||
// check for entity or tag start
|
// check for entity or tag start
|
||||||
if (!isEntity && chr == '&') {
|
if (!isEntity && char == '&') {
|
||||||
isEntity = true;
|
isEntity = true;
|
||||||
} else if (!isTag && chr == '<') {
|
} else if (!isTag && char == '<') {
|
||||||
Ox.forEach(tags, function(tag) {
|
Ox.forEach(tags, function(tag) {
|
||||||
if (html.slice(i + 1).match(new RegExp('^/?' + tag + '\\W'))) {
|
if (html.slice(i + 1).match(new RegExp('^/?' + tag + '\\W'))) {
|
||||||
isTag = true;
|
isTag = true;
|
||||||
|
@ -115,12 +115,12 @@ Ox.highlightHTML = function(html, str, classname, tags) {
|
||||||
// if outside entity or tag
|
// if outside entity or tag
|
||||||
if (!isEntity && !isTag) {
|
if (!isEntity && !isTag) {
|
||||||
// if character matches
|
// if character matches
|
||||||
if (chr == str[count]) {
|
if (char == string[count]) {
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
position = i;
|
position = i;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
if (count == str.length) {
|
if (count == string.length) {
|
||||||
// make sure matches are last to first
|
// make sure matches are last to first
|
||||||
positions.unshift([position, i + 1]);
|
positions.unshift([position, i + 1]);
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,9 @@ Ox.highlightHTML = function(html, str, classname, tags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check for entity or tag end
|
// check for entity or tag end
|
||||||
if (isEntity && chr == ';') {
|
if (isEntity && char == ';') {
|
||||||
isEntity = false;
|
isEntity = false;
|
||||||
} else if (isTag && chr == '>') {
|
} else if (isTag && char == '>') {
|
||||||
isTag = false;
|
isTag = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue