Gossamer Forum
Home : Products : Links 2.0 : Customization :

Neat Suggestion for Top Search Mod (Keyword Logger)

(Page 1 of 3)
> >
Quote Reply
Neat Suggestion for Top Search Mod (Keyword Logger)
I was wondering if anyone has any thoughts about how Ask Jeeves shows recent questions in a text box?

www.aj.com

Might be a cool thing to add to the Top Search (Keyword Logger) Mod.

Any thoughts?

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
For universal accessiblity and also because I am more comfortable progamming in Perl than js.

That's why.

Wink

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 04, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Well, looking at the source of the main page, its javascript. Webcrawler did this before with search words, as did i. Just steal the free javascript if you want.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Right. I noticed that. Thanks, Bmxer.

But how about the ability to click on a search button when a search term pops up? The script on Ask Jeeves is an ASP script, but I was wondering if anyone knew how this could be done in Perl. This is what I am interested in implementing.

Smile

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 04, 1999).]

[This message has been edited by Eliot (edited November 04, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
No need to. Its all in the Javascript, you just have it say if document.search exists, which is the name of the form, document.search.query, query is the name of the box. Then you would have onload="scroll stuff. Then just name a form search and a box query, and it works. Its really cool.

Anyway, i don't know why you would want it in perl when its in javascript right there. Its gonna be on my homepage in about 20 minutes, when i change the look.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Bmxer,

Very nice...checked out your site.

Pretty cool!

Tried using the js codes and it didn't work on my site....Is there something that needs to be written between the () near the new Array(). Currently I am using the following codes:

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
var ms = navigator.appVersion.indexOf("MSIE");
var ver = parseInt(navigator.appVersion.substring(ms+5, ms+6))
var text = new Array()
var count = text.length;
var i = count;
function scroll () {
if (count != null) {
if (i - 1 < 0) {
i = count;
}
if (document.topsearch) {
document.topsearch.query.value = text[--i];
}
setTimeout ("scroll()", 3500);
}
}
function OpenPopup(strFileName)
{
popupWnd=window.open(strFileName, "PopupWindow", "");
}
// -->
</SCRIPT>

Then I have the following in the search form:

Code:
<form action="/cgibin/wwwvl/search.cgi" method="get" name="topsearch">

Anything I am missing??

Also...I do have a hidden field in the search form (for the Titles and Summaries option)...do I need to write something in the js codes to recognize this hidden field?

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
javascript is pretty easy.. just if you do perl first.. you never can remember all the operators and such..

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
var text = new Array("Hello","You","Are","Reading","This")
var count = text.length;
var i = count;

function scroll () {
if (count != null) {
if (i - 1 < 0) {
i = count;
}
if (document.rotate) {
document.rotate.ask.value = text[--i];
}
setTimeout ("scroll()", 3500);
}
}
// -->
</SCRIPT>

is all you need..

Code:
onLoad="scroll();"

in the body tag..

and then the textarea's name has to be ask and then the form name is rotate

you can change these by editing

Code:
if (document.rotate) {
document.rotate.ask.value = text[--i];
}
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Yeah, Widgetz, i changed the document.rotate.ask to document.search.query.
Widgetz already said this Eliot but the part you were missing was onLoad="scroll();"
so its like <body bgcolor="#FFCC00" onLoad="scroll();">
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Thanks...guys.

Appreciate the speedy and thoughtful responses.

See ya.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Okay...It works! Great. However, how do I actually pull live search terms (like from the keywords.txt) file. I put some words in the new Array(), and the terms show up. So, it functions.

But what I was looking for is a way to pull search terms from the keywords.txt file or possibly through another method of showing what people are searching for in real time or close to it.

Any suggestions?

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
One Suggestion to save people from having to make code... check cgi-resources and see if they have random quote things, mess around with it a bit, and make it pull from your keyword database file. If that doesn't go well, i'll help.
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
I do have a simple random quote script working on my site. Hmm...that is a good lead...I will see what I come up with.

However, I may need assistance plugging the codes into the js codes.

js is not my cup of tea or preferred programming language....Sorry.

Thanks,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 05, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Good work Jerry! However, it comes out backwards unless you reverse the array or change the js to :

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
var text = new Array("Hello","You","Are","Reading","This")
var count = -1;
var i = count;
function scroll () {
if (count != null) {
if (i + 1 == text.length) {
i = count;
}
if (document.rotate) {
document.rotate.ask.value = text[++i];
}
setTimeout ("scroll()", 3500);
}
}
// -->
</SCRIPT>

Dan Smile
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
ok.. this is what i'd do to pull random lines.. not sure if it's what random quote thingys do.. but yea...

Code:
open (FILE, "file.txt");
@file = <FILE>;
close FILE;

$nmbr = int rand $#file;
$random = $file[$nmbr];

and then $random would be the line..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
I am using the following codes for my random quote program:

Code:
open (INFO,"inspire") or die "Can't open inspire: $!";
@inspire=<INFO>;
close (INFO);
$N=@inspire;
$R=rand($N);
print "Content-type: text/html\n\n";
print "<hr>\n";
print "<font face=\"Verdana\" SIZE=\"2\">";
print "$inspire[$R]\n";
print "</font>";
print "<BR><FONT FACE=\"Verdana\" SIZE=\"1\" COLOR=\"ff0000\"><B><CENTER>Reloa
d this page for another quote!</FONT></B></CENTER>\n";
print "</b>\n<hr>\n";

I am still unsure about how to plug these codes into the js that we've come up with.

The confusion stems from using server side codes (Perl) with client side codes (JS).

Any ideas?

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
if you want it to update every single time.. then you'd have to use SSI..

and btw. i guess i know how to make a random quote generator! code is pretty much the same.. except mine doesn't print but mine has less variables.. HA.. Wink

since that only does 1 random line.. you might as well do this

Code:
open (FILE, "file.txt");
@file = <FILE>;
close FILE;

for (my $i = 0; $i < 5; $i++) {
while (1) {
$nmbr = int rand $#file;
($done{$nmbr}) or last;
}
$done{$nmbr}++;
$output .= qq~"$file[$nmbr]",~;
}
chop $output;

#print "Content-type: text/plain\n\n"; #not sure if needed for SSI.
print $output;

then in the javascript.. you'd put

<!--#exec cgi="randomquery.cgi"-->

or something..

sorry.. i couldn't think of a better way Wink

jerry

[This message has been edited by widgetz (edited November 05, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Okay...Here is what I've come up....Using a variation of the codes Jerry (Widgetz) provided and the codes I have for my random quote script (still needs to be cleaned up to take out the hit count for the keywords stored in the keywords.txt file via the Keyword Logger Mod), I came up with a cgi script.

Then I put the SSI call in the javascript:

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
var ms = navigator.appVersion.indexOf("MSIE");
var ver = parseInt(navigator.appVersion.substring(ms+5, ms+6))
var text = <!--#exec cgi="/cgibin/misc/random2.cgi"-->
function scroll () {
if (document.topsearch) {
document.topsearch.query.value = text;
}
setTimeout ("scroll()", 3500);
}
function OpenPopup(strFileName) {
popupWnd=window.open(strFileName, "PopupWindow", "");
}
// -->
</SCRIPT>

Notice that I took out all the count stuff because it was causing a bunch of Javascript errors.

When I rebuilt the index page, I got the following Javascript Error:

participate observation undefined

Then when I click on the small ok button in the pop-up window, undefined pulls up in the search box.

So, it looks like the keywords are being pulled, however, the javascript does not know how to handle the keywords and therefore they are undefined.

Any ideas?

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Code:
var text = new Array(<!--#exec cgi="/cgibin/misc/random2.cgi"--> )

is more realistic.. but dunno..

if SSI works the way i think it does.. it should work..

jerry

[This message has been edited by widgetz (edited November 05, 1999).]
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Jerry (Widgetz),

I am preparing a file with bare bones codes for us to analyze this problem. It will be up in about fifteen minutes.

The file will be located at:

www.anthrotech.com/tmp/index.shtml

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Eliot (Eliot) Smile,

i got it to work perfectly fine with my instructions.. of course with one or two tweaks.. but

http://www.pdamania.com/jsrotate.html

reading from

http://www.pdamania.com/jsrandomq.txt

using SSI of course

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Widgetz,

Great idea!! But it didn't work. The JS just choked with too many errors.

Oh well...We are close though, I think.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
ok. i have another idea..

can you give me the URL to this page.. i wanna see what the javascript looks like

i've never actually seen a javascript or know code to let javascript read from a file..

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
i see you've got it too..

just you have to do like

Code:
$line = (split(/\|/, $file[$nmbr]))[0];
$output .= qq~"$line",~;

jerry
Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
Perfect! It works great!

I did make a copy of my search.cgi file as not to disrupt the logging process because when people click on the Search button, the count of the keyword would increase, which would disrupt the logging process.

Cool!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Neat Suggestion for Top Search Mod (Keyword Logger) In reply to
i think ask jeeves doesn't do random queries..

i think they get a random number in a file and then takes the next 20 starting from that line..

cause if you did it with mine.. and you only had like 3 queries.. you're server will either kill the process or it will crash..

so i am using this now

Code:
#!/usr/local/bin/perl

open (FILE, "jsrandomq.txt");
@file = <FILE>;
close FILE;
$nbr = int rand $#file;

for ($i = 0; $i < 20; $i++) {
$row = $nbr+$i;
($row > $#file) and $row -= $#file+1;
$line = $file[$row];
chomp $line;
$output .= qq~"$line",~;
}

chop $output;
print "Content-type: text/plain\n\n";
print $output;

it's faster.. especially for smaller sites that have less queries

jerry
> >