Revision history for SearchHighlighter
Revision [23280]
Last edited on 2016-05-20 07:38:47 by RolandStens [Replaces old-style internal links with new pipe-split links.]Additions:
The following code implements a feature that will highlight the search word in the pages that where found by TextSearch or by Google, Yahoo and many other search engines. The core of this feature is a JavaScript library by the name of [[http://www.kryogenix.org/code/browser/searchhi/ | searchhi]].
It is installed on [[http://stens.ca/kb | my Wikka]] so you can see for yourself how it works.
It is installed on [[http://stens.ca/kb | my Wikka]] so you can see for yourself how it works.
Deletions:
It is installed on [[http://stens.ca/kb my Wikka]] so you can see for yourself how it works.
Revision [19317]
Edited on 2008-01-28 00:15:07 by RolandStens [Modified links pointing to docs server]No Differences
Additions:
In the **actions/header.php** file add the following code just before the **</HEAD>** tag:
Deletions:
Additions:
The following code implements a feature that will highlight the search word in the pages that where found by TextSearch or by Google, Yahoo and many other search engines. The core of this feature is a JavaScript library by the name of [[http://www.kryogenix.org/code/browser/searchhi/ searchhi]].
Deletions:
Additions:
for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
after = document.createTextNode(nv.substr(ni+word.length));
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++) {
qsip = qsa[i].split('=');
if (qsip.length == 1) continue;
if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'phrase') { // q= for Google, p= for Yahoo, phrase for wikka
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;w<words.length;w++) {
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
window.onload = SearchHighlight;
Now all that rest us is two small changes to the **wikka.css** file and to the **header.php** action.
In **css/wikka.css** add the following lines:
%%(css)
/* ##### searchhi plugin ##### */
.searchword {
background-color: yellow;
In the **actions/header.php** file add the following code just before of the **</HEAD>** tag:
%%(html4strict)
<script src="3rdparty/plugins/searchhi/searchhi.js" type="text/javascript"></script>
It is installed on [[http://stens.ca/kb my Wikka]] so you can see for yourself how it works.
----
CategoryUserContributions
after = document.createTextNode(nv.substr(ni+word.length));
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++) {
qsip = qsa[i].split('=');
if (qsip.length == 1) continue;
if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'phrase') { // q= for Google, p= for Yahoo, phrase for wikka
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;w<words.length;w++) {
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
window.onload = SearchHighlight;
Now all that rest us is two small changes to the **wikka.css** file and to the **header.php** action.
In **css/wikka.css** add the following lines:
%%(css)
/* ##### searchhi plugin ##### */
.searchword {
background-color: yellow;
In the **actions/header.php** file add the following code just before of the **</HEAD>** tag:
%%(html4strict)
<script src="3rdparty/plugins/searchhi/searchhi.js" type="text/javascript"></script>
It is installed on [[http://stens.ca/kb my Wikka]] so you can see for yourself how it works.
----
CategoryUserContributions
Deletions:
after = document.createTextNode(nv.substr(ni word.length));
qs = ref.substr(ref.indexOf('?') 1);
qsa = qs.split('
Additions:
for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn ) {
after = document.createTextNode(nv.substr(ni word.length));
qs = ref.substr(ref.indexOf('?') 1);
qsa = qs.split('
after = document.createTextNode(nv.substr(ni word.length));
qs = ref.substr(ref.indexOf('?') 1);
qsa = qs.split('
Deletions:
after = document.createTextNode(nv.substr(ni+word.length));
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++) {
qsip = qsa[i].split('=');
if (qsip.length == 1) continue;
if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'phrase') { // q= for Google, p= for Yahoo, phrase for wikka
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;w<words.length;w++) {
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
window.onload = SearchHighlight;
Now all that rest us is two small changes to the **wikka.css** file and to the **header.php** action.
In **css/wikka.css** add the following lines:
%%(css)
/* ##### searchhi plugin ##### */
.searchword {
background-color: yellow;
In the **actions/header.php** file add the following code just before of the **</HEAD>** tag:
%%(html4strict)
<script src="3rdparty/plugins/searchhi/searchhi.js" type="text/javascript"></script>
It is installed on [[http://stens.ca/kb my Wikka]] so you can see for yourself how it works.
----
CategoryUserContributions
Deletions:
Additions:
{{backlinks}}
Deletions:
But version 1.5 works.
Additions:
First I had to make a few minor changes to this JavaScript libary. This to make it aware of the TextSearch activity.
Deletions:
Additions:
This did not seem to work on older versions of Firefox, see comments.
But version 1.5 works.
But version 1.5 works.
Deletions:
Additions:
%%(css)
%%(html4strict)
%%(html4strict)
Deletions:
Additions:
=====Highlight Searched-for Text=====
Deletions:
Additions:
It is installed on [[http://stens.ca/kb my Wikka]] so you can see for yourself how it works.
But, it only seems to work in IE, so I am open for any suggestions for making this work for FireFox/Mozilla as well.
But, it only seems to work in IE, so I am open for any suggestions for making this work for FireFox/Mozilla as well.
Deletions:
Additions:
I am about to put this on [[http://stens.ca/kb my Wikka]] so that you can see how it works.