Development :  K-Meleon Forum
K-Meleon development related discussions. 
highlight search results
Posted by: michael
Date: April 28, 2005 03:55AM

ich suche nach einer möglichkeit suchergebnisse, dessen worte ich über den suchbutton der toolbar eingebe einfach hervorzuheben, ohne die worte erneut eingeben zu müssen (denn eine highlightfunktion gibt's ja schon). eventuell durch eine funktionstaste oder einen weiteren toolbar button. da ich mich mit den makros nicht wirklich auskenne komme ich alleine nicht weiter.
lg michael

Options: ReplyQuote
Re: highlight search results
Posted by: Hugo
Date: June 04, 2005 01:54AM

michael,

Leider kann ich nicht auf Deutch antworten, weil ich nicht viel Deutch spreche. Ich kann doch die Frage U''bersetzen versuchen, und vielleich später auf Englisch antworten.

---
The question goes something like this (corrections on the translation are very welcome, I am not very good at German):

o) The user performs a search (from the address bar), and views the search results (say a Google results page)

o) The user visits one of the resulting pages. Could there be a way to have the "search terms" highlighted (something like Find and Highlight, Ctrl+F3) on that page, without having to retype the search terms -- just by pressing a function key or another toolbar button or something?

michael also says that he doesn't know macro-hacking well enough to figure this one out himself.
----

I agree, this is a compelling idea. I'll take a look at it and see if I can figure it out..

Cheers/Tschu''ss

Hugo

Options: ReplyQuote
Re: highlight search results
Posted by: Hugo
Date: June 04, 2005 02:45AM

Well,

If the search terms were *stored* (e.g on the clipboard or as a preference maybe) we could let the Find (and Highlight)-macro (in macros.cfg) *retrieve* them, and disply them as "default" in the prompt.

(Any ideas on the optimal way to *store* the search terns?)

The user only needs to press Ctrl+F3 and then Enter to achieve the desired effect.

Find{
# with a little luck, something useful (e.g search terms) is stored on the clipboard:
$q = getclipboard();
$q = gsub( "\n", " ", $q );
# Prompt for searched words (with current clipboard as default):
$highlight_strings=prompt("Highlight words", "Highlight words:", $q);

open("javascriptsad smileyfunction(){var count=0, text, dv;text='".$highlight_strings."'; if(text==null || text.length==0) return; ...snip...
}

(Be careful to get the apostrophes and quotes in the JavaScript right)

Hugo

Options: ReplyQuote
Re: highlight search results
Posted by: Kat
Date: December 14, 2005 02:45AM
Options: ReplyQuote
Re: highlight search results
Posted by: vpowell
Date: March 06, 2006 02:12AM

# try the following


Find{
# This is an extension of Hugo's work:
$tmp=getclipboard(); setclipboard(); id(ID_EDIT_COPY);
# Now selected text is stored in the clipboard:
$q = getclipboard();
$q = gsub( "\n", " ", $q );
# Prompt for searched words (with current clipboard as default):
$highlight_strings=prompt("Highlight words", "Highlight words:", $q);
open("javascriptsad smileyfunction(){var count=0, text, dv;text='".$highlight_strings."'; if(text==null || text.length==0) return;dv=document.defaultView;function searchWithinNode(node, te, len){var pos, skip, spannode, middlebit, endbit, middleclone;skip=0;if( node.nodeType==3 ){pos=node.data.toUpperCase().indexOf(te);if(pos>=0){spannode=document.createElement(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;middlebit=node.splitText(pos);endbit=middlebit.splitText(len);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);++count;skip=1;}}else if( node.nodeType==1&& node.childNodes&& dv.getComputedStyle(node, null).getPropertyValue(%22display%22)!=%22none%22){for (var child=0; child < node.childNodes.length; ++child){child=child+searchWithinNode(node.childNodes[child], te, len);}}return skip;}window.status=%22Searching for '%22+text+%22'...%22;searchWithinNode(document.body, text.toUpperCase(), text.length);window.status=%22Found %22+count+%22 occurrence%22+(count==1?%22%22:%22s%22)+%22 of '%22+text+%22'.%22;})();"); setclipboard($tmp);
}

Options: ReplyQuote
Re: highlight search results
Posted by: vpowell
Date: March 06, 2006 02:17AM

I'm afraid that example has stretched this thread. It is just an extension of Hugo's work to copy the selected text and then prompt to see if it is correct search term.

Options: ReplyQuote
Re: highlight search results
Posted by: vpowell
Date: March 06, 2006 02:35AM

The ixquick search engine provides that option already.
Just click on the link on the bottom left of the result.
(the result below is a NON-WORKING example to show the place to click)

SourceForge.net: K-Meleon
The world's largest development and download repository of Open Source code and applications.
http://www.sourceforge.net/projects/kmeleon
Highlight - Found by AltaVista/AllTheWeb (2), Yahoo (4), WiseNut (5), Netscape (5)

Options: ReplyQuote


K-Meleon forum is powered by Phorum.