d3e7adfd1f
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif@161 2a923420-c742-0410-a762-8d5b09965624
45 lines
879 B
JavaScript
45 lines
879 B
JavaScript
|
|
function highlight(obj, searchTerm)
|
|
{
|
|
var bodyText = obj.innerHTML;
|
|
|
|
stag = "<span class=yellowshade>";
|
|
etag = "</span>";
|
|
|
|
var newText = "";
|
|
var i = -1;
|
|
var lcSearchTerm = searchTerm.toLowerCase();
|
|
var lcBodyText = bodyText.toLowerCase();
|
|
|
|
while (bodyText.length > 0)
|
|
{
|
|
i = lcBodyText.indexOf(lcSearchTerm, i + 1);
|
|
if (i < 0)
|
|
{
|
|
newText += bodyText;
|
|
bodyText = "";
|
|
}
|
|
else
|
|
{
|
|
if (bodyText.lastIndexOf(">", i) >=
|
|
bodyText.lastIndexOf("<", i))
|
|
{
|
|
if (lcBodyText.lastIndexOf("/script>", i) >=
|
|
lcBodyText.lastIndexOf("<script", i))
|
|
{
|
|
newText += bodyText.substring(0, i) +
|
|
stag +
|
|
bodyText.substr(i,
|
|
searchTerm.length) + etag;
|
|
bodyText = bodyText.substr(i +
|
|
searchTerm.length);
|
|
lcBodyText = bodyText.toLowerCase();
|
|
i = -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
obj.innerHTML = newText;
|
|
}
|
|
|