bootstrap.bootstrap-phloc-typeahead.js Maven / Gradle / Ivy
/**
* Replace searchTerm in string with searchTerm
* @param bodyText Original text
* @param searchTerm Term to search
* @returns {String}
*/
function _doHighlightSingleTerm(bodyText, searchTerm){
var ret = "";
var i = -1;
var lcSearchTerm = searchTerm.toLowerCase();
var lcBodyText = bodyText.toLowerCase();
while (bodyText.length > 0) {
i = lcBodyText.indexOf(lcSearchTerm, i+1);
if (i < 0) {
ret += bodyText;
bodyText = "";
} else {
// skip anything inside an HTML tag
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
// skip anything inside a