Skip to content

Instantly share code, notes, and snippets.

Created Aug 9, 2011
What would you like to do?
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment