rename vars

This commit is contained in:
rolux 2012-05-26 00:18:08 +02:00
parent 93cefc518a
commit 463c9d9e90

View file

@ -80,7 +80,7 @@ Ox.highlightHTML <f> Highlight matches in an HTML string
> Ox.highlightHTML('a <br> c', 'b', 'h')
'a <br> c'
@*/
Ox.highlightHTML = function(html, str, classname, tags) {
Ox.highlightHTML = function(html, string, classname, tags) {
var count = 0,
isEntity = false,
isTag = false,
@ -99,12 +99,12 @@ Ox.highlightHTML = function(html, str, classname, tags) {
// other
'a', 'br', 'img',
]);
str = Ox.encodeHTML(str).toLowerCase();
Ox.forEach(html.toLowerCase(), function(chr, i) {
string = Ox.encodeHTML(string).toLowerCase();
Ox.forEach(html.toLowerCase(), function(char, i) {
// check for entity or tag start
if (!isEntity && chr == '&') {
if (!isEntity && char == '&') {
isEntity = true;
} else if (!isTag && chr == '<') {
} else if (!isTag && char == '<') {
Ox.forEach(tags, function(tag) {
if (html.slice(i + 1).match(new RegExp('^/?' + tag + '\\W'))) {
isTag = true;
@ -115,12 +115,12 @@ Ox.highlightHTML = function(html, str, classname, tags) {
// if outside entity or tag
if (!isEntity && !isTag) {
// if character matches
if (chr == str[count]) {
if (char == string[count]) {
if (count == 0) {
position = i;
}
count++;
if (count == str.length) {
if (count == string.length) {
// make sure matches are last to first
positions.unshift([position, i + 1]);
}
@ -129,9 +129,9 @@ Ox.highlightHTML = function(html, str, classname, tags) {
}
}
// check for entity or tag end
if (isEntity && chr == ';') {
if (isEntity && char == ';') {
isEntity = false;
} else if (isTag && chr == '>') {
} else if (isTag && char == '>') {
isTag = false;
}
});