|
Lines 1-6
Link Here
|
| 1 |
/* |
1 |
/* |
| 2 |
|
2 |
|
| 3 |
highlight v3 |
3 |
highlight v5 |
| 4 |
|
4 |
|
| 5 |
Highlights arbitrary terms. |
5 |
Highlights arbitrary terms. |
| 6 |
|
6 |
|
|
Lines 19-24
jQuery.fn.highlight = function(pat) {
Link Here
|
| 19 |
var skip = 0; |
19 |
var skip = 0; |
| 20 |
if (node.nodeType == 3) { |
20 |
if (node.nodeType == 3) { |
| 21 |
var pos = node.data.toUpperCase().indexOf(pat); |
21 |
var pos = node.data.toUpperCase().indexOf(pat); |
|
|
22 |
pos -= (node.data.substr(0, pos).toUpperCase().length - node.data.substr(0, pos).length); |
| 22 |
if (pos >= 0) { |
23 |
if (pos >= 0) { |
| 23 |
var spannode = document.createElement('span'); |
24 |
var spannode = document.createElement('span'); |
| 24 |
spannode.className = 'term'; |
25 |
spannode.className = 'term'; |
|
Lines 37-45
jQuery.fn.highlight = function(pat) {
Link Here
|
| 37 |
} |
38 |
} |
| 38 |
return skip; |
39 |
return skip; |
| 39 |
} |
40 |
} |
| 40 |
return this.each(function() { |
41 |
return this.length && pat && pat.length ? this.each(function() { |
| 41 |
innerHighlight(this, pat.toUpperCase()); |
42 |
innerHighlight(this, pat.toUpperCase()); |
| 42 |
}); |
43 |
}) : this; |
| 43 |
}; |
44 |
}; |
| 44 |
|
45 |
|
| 45 |
jQuery.fn.removeHighlight = function() { |
46 |
jQuery.fn.removeHighlight = function() { |
| 46 |
- |
|
|