/** * Search Engine Keyword Highlight (http://fucoder.com/code/se-hilite/) * * This module can be imported by any HTML page, and it would analyse the * referrer for search engine keywords, and then highlight those keywords on * the page, by wrapping them around ... tags. * Document can then define styles else where to provide visual feedbacks. * * Usage: * * In HTML. Add the following line towards the end of the document. * * * * In CSS, define the following style: * * .hilite { background-color: #ff0; } * * If Hilite.style_name_suffix is true, then define the follow styles: * * .hilite1 { background-color: #ff0; } * .hilite2 { background-color: #f0f; } * .hilite3 { background-color: #0ff; } * .hilite4 ... * * @author Scott Yang * @version 1.3 */ Hilite={elementid:'content',exact:false,max_nodes:1000,onload:true,style_name:'hilite',style_name_suffix:true,debug_referrer:''};Hilite.search_engines=[['^http://(www)?\\.?google.*','q='],['^http://search\\.yahoo.*','p='],['^http://search\\.msn.*','q='],['^http://search\\.aol.*','userQuery='],['^http://(www\\.)?altavista.*','q='],['^http://(www\\.)?feedster.*','q='],['^http://search\\.lycos.*','query='],['^http://(www\\.)?alltheweb.*','q='],['^http://(www||uus)\\.ekspress.*','str='],['^http://(www||uus)\\.ekspress.*','sstring=']];Hilite.decodeReferrer=function(referrer){var query=null;var match=new RegExp('');for(var i=0;i0){count++;if(count>=Hilite.max_nodes){var handler=function(){Hilite.walkElements(node,depth,textproc);};setTimeout(handler,50);return;}if(node.nodeType==1){if(!skipre.test(node.tagName)&&node.childNodes.length>0){node=node.childNodes[0];depth++;continue;}}else if(node.nodeType==3){node=textproc(node);}if(node.nextSibling){node=node.nextSibling;}else{while(depth>0){node=node.parentNode;depth--;try{if(node==null)node==null;if(node.nextSibling){node=node.nextSibling;break;}}catch(e){break;}}}}};if(Hilite.onload){if(window.attachEvent){window.attachEvent('onload',Hilite.hilite);}else if(window.addEventListener){window.addEventListener('load',Hilite.hilite,false);}else{var __onload=window.onload;window.onload=function(){Hilite.hilite();__onload();};}}