From 6e03f61daafa4a1a74659d14f762b2674f82b652 Mon Sep 17 00:00:00 2001 From: allo Date: Wed, 13 Sep 2006 11:26:26 +0000 Subject: [PATCH] fix for highlighting searched words in snippets git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2564 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/js/yacysearch.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/htroot/js/yacysearch.js b/htroot/js/yacysearch.js index 3e1e1f5b1..430ebe321 100644 --- a/htroot/js/yacysearch.js +++ b/htroot/js/yacysearch.js @@ -41,6 +41,27 @@ function handleState(req) { //span.setAttribute("class", "snippetError"); } - var snippetNode = document.createTextNode(snippetText); - span.appendChild(snippetNode); + var pos=snippetText.indexOf(""); + var pos2=snippetText.indexOf(""); + var tmpNode=null; + var tmpNode2=null; + while(pos >= 0 && pos2 > pos){ + tmpNode = document.createTextNode(snippetText.substring(0, pos); //other text + if(tmpNode != ""){ + span.appendChild(tmpNode); + } + //add the bold text + tmpNode=document.createElement("strong") + tmpNode2=document.createTextNode(snippetText.substring(pos+3,pos2); + tmpNode.append(tmpNode2); + span.appendChild(tmpNode) + + snippetText=substring(pos2+4) + var pos=snippetText.indexOf(""); + var pos2=snippetText.indexOf(""); + } + if(snippetText != ""){ + tmpNode = document.createTextNode(snippetText.substring(0, pos); //other text + span.appendChild(tmpNode); + } }