Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Script ..Help!

Status
Not open for further replies.

Matrix0319

IS-IT--Management
Feb 7, 2003
28
CA
I found a script on the Net and I want to know how could i insert the listings or the directory/folder on where this script would search. This is for intanet use only.
The script is below:

<!-- TWO STEPS TO INSTALL SITE SEARCH:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Original: Dion (biab@iinet.net.au) -->
<!-- Web Site: -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->

<!-- Begin
var item = new Array();

/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/

// &quot;Page Name&quot;,&quot;path&quot;,&quot;Page Title&quot;,&quot;Many,Key,Words&quot;,&quot;Descriptive Comments&quot;

c=0; item[c]=new Array(&quot;index.html&quot;,&quot;&quot;,&quot;DemoSite&quot;,&quot;index,main,start,home,front&quot;,&quot;Demonstration search engine data about an

imagined but probable internet site.&quot;);
c++; item[c]=new Array(&quot;about.htm&quot;,&quot;&quot;,&quot;About Me&quot;,&quot;about,author,contact,email,who&quot;,&quot;Contact details and general information

about the creator of the site and what the site is about.&quot;);
c++; item[c]=new Array(&quot;links.htm&quot;,&quot;&quot;,&quot;Links page&quot;,&quot;links,more,where,similar,friends&quot;,&quot;Links to my favourite sites which I

find interesting. Other friends sites which have similar interests to my own.&quot;);
c++; item[c]=new Array(&quot;main.htm&quot;,&quot;main/&quot;,&quot;Main Page&quot;,&quot;content,main,focus&quot;,&quot;The main part of my site which contains what you

have come to see. Lots of stuff like that and more great things. All in a sub directory.&quot;);
c++; item[c]=new Array(&quot;logo.jpg&quot;,&quot;main/images/&quot;,&quot;Link Logo&quot;,&quot;link,image,logo,graphic&quot;,&quot;The logo.jpg is just a small image

which you can place on your site as a link to me. It's in a second level subdirectory.&quot;);

page=&quot;<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10

width=80%>&quot;;


function search(frm) {
win = window.open(&quot;&quot;,&quot;&quot;,&quot;scrollbars&quot;);
win.document.write(page);
txt = frm.srchval.value.split(&quot; &quot;);
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != &quot;&quot;)
fnd += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write(&quot;</table><br>Total found: &quot;+total+&quot;<br></body></html>&quot;);
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = &quot;<tr><td><a href='&quot;+link+&quot;'>&quot;+item[which][2]+&quot;</a> Score: &quot;+num+&quot;<br>&quot;;
line += item[which][4] + &quot;<br>&quot;+link+&quot;</td></tr>&quot;;
wind.document.write(line);
return 1;
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>

<form method=get action=&quot;javascript:void(0)&quot; onsubmit=&quot;search(this); return false;&quot;>
<tr><td><input type=text name=srchval value=&quot;&quot;><input type=submit value=&quot;Search&quot;></td></tr>
</form>

</center>

<p><center>
<font face=&quot;arial, helvetica&quot; size=&quot;-2&quot;>Free JavaScripts provided<br>
by <a href=&quot; JavaScript Source</a></font>
</center><p>

<!-- Script Size: 3.16 KB -->
 
The script checks an array of arrays for matches to the input string. There is a series of variables set for each page in the top section;-

item[c]=new Array(&quot;index.html&quot;,&quot;&quot;,&quot;DemoSite&quot;,&quot;index,main,start,home,front&quot;,&quot;Demonstration search engine data about an imagined but probable internet site.&quot;);

defines the index.html page and enters a set of keywords for it.

If you want to use this script for other searches, change it as follows:
item[c]=new Array(&quot;[file name]&quot;,&quot;[sub folder if used]&quot;,&quot;[title]&quot;,&quot;[keywords]&quot;,&quot;[description]&quot;);
after the last of these lines, beginnong c++; you can add new ones by copying and pasting the previous entry.

Andy %-)
 
sorry to ask you stupid Q's but if i do have filenaming convention which is month day and year (e.g. January 1, 2003 Report.doc) and this file is located on Reports folder what should be the string format? and i also need to enter the 12 months of the year and 1 to 31. on the keywords?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top