Created
January 3, 2012 00:59
-
-
Save kmaglione/1552908 to your computer and use it in GitHub Desktop.
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
SWOOSTYhighlightSearchTerms: function (doc, searchText) { | |
var searchArray = [searchText, searchText.replace(/-/g, " "), searchText.replace(/ /g, "-")]; | |
if (!doc.body || typeof (doc.body.innerHTML) == "undefined") { | |
return false; | |
} | |
var bodyText = doc.body.innerHTML; | |
for (var i = 0; i < searchArray.length; i++) { | |
bodyText = this.SWOOSTYdoHighlight(bodyText, searchArray[i], this.mHighlightColours[this.mHighlightColourIndex]); | |
} | |
this.mHighlightColourIndex++; | |
if (this.mHighlightColourIndex >= this.mHighlightColours.length) { | |
this.mHighlightColourIndex = 0; | |
} | |
doc.body.innerHTML = bodyText; | |
return true; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment