Click to See Complete Forum and Search --> : optimalisation search script


paulwong
10-06-2003, 07:52 AM
Hello people,

I have found this search script on the internet and I really love it. It was full of buggs but I removed them. With this script I can decide my own keywords, description and url's.

There is only one problem. I dont know how to optimalize the script. i'll explain:

Now I have to do it like this:

Keyword [1] = "test"
Descrip [1] = "beschrijving "
Address [1] = http://URLnaarwebsite.nl

My problem is that I have to enter 400 keywords so doing it like this wont be easy.

I searched around and people told me to do it like this:

search[1]= new Array ('key','link1','discription');
search[2]= new Array ('key2','link2','discription');
search[3]= new Array ('test','link3','discription');
search[4]= new Array ('test','link4','discription');


I just have no clue how to put this in the script and what I have to change for it. I hop you can read all of this couse I am not englisch but Dutch.

I hope you can help me

greetings from the netherlands

<html>
<head>
<title>Search </title>
<xxbase target="basefrm">
</head>

<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000" <!--content start-- -->
<script>

</script>
<script language=JavaScript src="frames_body_array.js" type=text/javascript></script>
<script language=JavaScript src="mmenu.js" type=text/javascript></script>

<table WIDTH="96%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<tr>
<td WIDTH="100%"><font FACE="ARIEL,HELVETICA" SIZE="-1"><p align="center"><script
LANGUAGE="JavaScript">

<!-- Hide Script from Old Browsers
/*

Redesign by -->Paul
Optimized by -->Daniel Bergman [http://botw.cjb.net].

original from-->Java Search Engine
(c)1997 Adam ALLEN.
Version 2.0

*/

Keyword = new Object();
Descrip = new Object();
Address = new Object();

// Keyword[0] = n (where n is the number of keywords which can be searched
Keyword[0] = 6

// Each entry is split into
// Keyword[n] = text (where text is the keyword of which the entry is to
// be searched by (type Keywords in lowercase)
// Descrip[n] = text (where text is the description associated to this entry
// Address[n] = text (where text is the URL associated to the entry
// n is the entry number.

Keyword[1] = "test"
Descrip[1] = "URL naar een website."
Address[1] = "http://eenURLnaarWEBSITE.com"

Keyword[2] = "test2"
Descrip[2] = "een url naar locale site"
Address[2] = "//URLnaarlocalesite"

Keyword[3] = "test3"
Descrip[3] = "Click here to visit the Compaq site "
Address[3] = "http://URLnaarwebsite.nl"

Keyword[4] = "test4"
Descrip[4] = "Your site can go here!"
Address[4] = "\\urlnaarlocalesite";//Arakrys!!!!!!!!!

function checkDatabase() {

var Found = false
var Item = document.forms[0].searchfor.value.toLowerCase();

stats='toolbar=no,location=no,directories=no,statu
s=no,menubar=no,height=400,width=300,'
stats += 'scrollbars=yes,resizable=yes'
MsgBox = window.open ("","msgWindow",stats)
MsgBox.opener = window;
MsgBox.opener.name = "opener";
MsgBox.document.open();//Arakrys!!!!!!!!!
MsgBox.document.write("<head><title>Search Results</title></head>");
MsgBox.document.write ("<body bgcolor=white text=black link=blue vlink=darkblue alink=blue><H2><CENTER><font face=arial>Search Results</CENTER></H2>")
//alert(Item);
MsgBox.document.write ("<font size=3><b><center>For the keyword: "+Item+"</center><hr width=50%></b></font>");
for (var i=1; i <= Keyword[0]; i++) {
if(Item == Keyword[i]) {
Found = true;
MsgBox.document.write ("<li><font face=arial><font size=2><b>"+Descrip[i]+"<BR><A HREF="+Address[i]+" target='opener'>Click Here To Go There</A></font></font>")
}
}
if(!Found) MsgBox.document.write ("<H4>Nothing Found</H4>")
// Leave the line below intact if you want to legally use this script
MsgBox.document.write ("<FORM><CENTER>")
MsgBox.document.write ("<font size=2><font color=arial><INPUT type='button' value='Close' onClick = 'self.close()'></font></font>")
MsgBox.document.write ("</CENTER></FORM>")
MsgBox.document.write ("<H6><small><small><small><b></b><font color=white><font face=arial><font size=1><font color=black>Designed by Paul </font></font></small></small></small>")

MsgBox.document.close();//Arakrys!!!!!!!!!

// There must be my notice above if you are to use this script legally.
// It took many hours work, fairs is fair, I just want that little line in
// and you get a fully working Search ENGINE, for FREE, on your site
// In Java Scripts as well, and not crap JAVA!
// Also a copyright notice MUST appear with the form.
}
// -->

</script> </p>
<form NAME="form1" onSubmit="return checkDatabase()" Arakrys!!!!!!!!! >
<b><div align="center"><center><p>Search for server name or IP adress:</b><br>
<input TYPE="text" NAME="searchfor" VALUE="" SIZE="20"><b>
<input type="button" value="Search" align="absmiddle" onClick="checkDatabase()">
</b><br>
<br>
</font>
</p>
</center></div>
</form>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>

Dimitri
10-06-2003, 06:46 PM
I really hate sloppy JS code. I did my best to clean it up, but it's not as clean as I'd like. Still, it's much better than before. Hope you like it.

Dimitri

---------------------------

<html>
<head>
&nbsp;&nbsp;&nbsp;&nbsp;<title>Search</title>
&nbsp;&nbsp;&nbsp;&nbsp;<script language="JavaScript">
&nbsp;&nbsp;&nbsp;&nbsp;<!--
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var db = new Array;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function Term (keyword, description, url) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.keyword = keyword;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.description = description;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.url = url;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function checkDatabase() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var Found = false;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var Item = document.form1.searchfor.value;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var MsgBox = window.open("","msgWindow", 'toolbar=no,location=no,directories=no,status=no,menubar=no,height=400,width=300,scrollbars=yes,resi zable=yes');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox.opener = window;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox.opener.name = "opener";

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with (MsgBox.document) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;open();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<head><title>Search Results</title></head>");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<body bgcolor=white text=black link=blue vlink=darkblue alink=blue><H2><CENTER><font face=arial>Search Results</CENTER></H2>");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<font size=3><b><center>For the keyword: " + Item + "</center><hr width=50%></b></font>");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i=0; i < db.length; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(Item.toLowerCase() == db[i].keyword.toLowerCase()) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Found = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<li><font face=arial size=2><b>" + db[i].description + "<BR><A HREF=" + db[i].url + " target='opener'>Click Here To Go There</A></font>")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!Found)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<H4>Nothing Found</H4>");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write("<FORM><CENTER><font size=2><font color=arial><INPUT type='button' value='Close' onClick = 'self.close()'></font></font></CENTER></FORM>");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// All you have to do is add your terms here in this format
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db[db.length] = new Term("test", "URL naar een website.", "http://eenURLnaarWEBSITE.com");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db[db.length] = new Term("test2", "Click here to visit the Compaq site", "http://URLnaarwebsite.nl");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db[db.length] = new Term("test3", "Your site can go here!", "http://www.urlnaarlocalesite.com");
&nbsp;&nbsp;&nbsp;&nbsp;// -->
&nbsp;&nbsp;&nbsp;&nbsp;</script>
</head>
<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000">
<form NAME="form1" onsubmit="checkDatabase(); return false;">
&nbsp;&nbsp;&nbsp;&nbsp;<input TYPE="text" NAME="searchfor" SIZE="20">
&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Search">
</form>
</body>
</html>

paulwong
10-09-2003, 02:33 AM
thanx I'll test it as soon as possible.
I'll let you know

greetings from the netherlands