Created
August 9, 2011 13:24
-
-
Save jashkenas/1134033 to your computer and use it in GitHub Desktop.
Trying CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
highlightWord = (node, word) -> | |
if node.hasChildNodes | |
children = node.childNodes | |
highlightWord(item, word) for item in children | |
if node.nodeType == 3 | |
tempNodeVal = node.nodeValue.toLowerCase() | |
tempWordValue = word.toLowerCase() | |
if tempNodeVal.indexOf(tempWordVal) not -1 | |
pn = node.parentNode | |
# check if we're inside a "nosearchhi" zone | |
checkn = pn | |
while checkn.nodeType not 9 && checkn.nodeName.toLowerCase not 'body' | |
/\bnosearchhi\b/.test(checkn.className) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment