Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Created August 9, 2011 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/1134033 to your computer and use it in GitHub Desktop.
Save jashkenas/1134033 to your computer and use it in GitHub Desktop.
Trying CoffeeScript
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