neilbradford
08-14-2006, 01:49 PM
There is a script that does act like a search engine.
If.... you don't mind typing in all the keywords that each file relates to, ie:
javascript.htm :: java, script, javascript, scripts, dynamic
html.htm :: html, htm, hyperlink, text etc, etc
If that's OK with you....
You can see the structure where you add the page url and then a header description following it. You then enter keywords/keyword phrases. The secret is not adding too many keywords to each line.
The automatically generated page created when the person clicks the generated button will show a list of relevant pages/files (as would Google). It also has a points score out of 10 showing the highest number being the most relevant.
I've added random page names and random keywords to suit as I've used this script on a number of websites but it will work off-line which is what you want. You will of course, need to craete html documents named as they are named in the code below but obviously altered to what you want.
Just create a basic web page and insert the first lot of code into the HEAD.
Here's the code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var item = new Array();
/* Enter additional pages
fill in the additional listings for each page.
*/
// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
c=0; item[c]=new Array("OurServices.html","","Our Services","services,our services,fencing,consultation,brickwork,planting,plan,plans,patio,patios,paving,turfing,decking,driveways,pergolas,lighting,water features,fountains,waterfalls,paths,garden clearance,garden,gardens,maintenance","An overview of the services we at Oakwood Landscapes provide.");
c++; item[c]=new Array("GardenDesign.htm","","Garden Design - The Design Process","garden design,landscape design,design,design process,designing,process,visit,site visit,home visit,consultation,outline,master,layout,planting,plan,project monitoring,customer feedback,feedback","Our Garden Design page illustrates the actual design process from the initial first contact through consultation, planning, design, construction, planting, right up to aftercare.");
c++; item[c]=new Array("Landscaping.htm","","Landscaping","landscaping,landscape construction,soft,hard,soft landscaping,hard landscaping,design and build,design & build,grounds maintenance,show home gardens,showhome gardens,semi-mature shrubs,semi-mature trees,shrubs,trees,semi mature,semi-mature,stone,wood,brick,buildings,garden buildings","The range of services we provide within our Landscaping section.");
c++; item[c]=new Array("Planting.htm","","Planting","planting,plants,semi-mature plants,semi-mature,semi mature,mature,plants,flowers,trees,shrubs","A brief description of our Planting once your garden has been designed and built.");
c++; item[c]=new Array("Aftercare.htm","","Our Aftercare Service","aftercare,after care,maintenance,consultants,consultancy,garden management,weed control,development.","Garden Maintenance and our Aftercare Services.");
c++; item[c]=new Array("Consultation.htm","","Our Consultancy Service","consultant,consultancy,consultantsy,consultation,meeting,home visit,home visits,planning,consultancy service.","Whether we are building and/or planting your garden or not, we provide consultancy service based on an hourly rate. This can be a one-off visit or a series of visits over months or even years.");
c++; item[c]=new Array("RacingFixtures.htm","","UK Racing Fixtures 2004","flat meetings,mh meetings,racing,horse racing,horse racing events,racing events,ascot,aintree,newmarket,stratford on avon,stratford upon avon,epsom,epsom downs,goodwood,sandown park,doncaster,haydock park,redcar,york","Racing Fixtures throughout the UK 2004 with Flat Meetings and MH Meetings all listed by region and dates.");
c++; item[c]=new Array("findingconferencevenue.htm","","Finding a Conference Venue","events in january,events in february,events in march,events in april,events in may,events in june,events in july,events in august,events in september,events in october,events in november,events in december,events in 2004,corporate days out,venue dates,event dates,football,rugby,rugby union,concerts,bands","Our UK Events Calendar 2004 contains everything from football, rugby and rugby union matches to bands, live music and concerts. You can search for your ideal venue by location and date.");
c++; item[c]=new Array("contact.htm","","Contact Your Company","email,e-mail,email your company,e-mail your company,address,postal address,jester events address,telephone,tel,phone,contact,contact jester events,fax,fax number,telephone number","Please use this page to contact us by post, phone, fax, email or by completing the form.");
page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=80%>";
function search(frm) {
win = window.open("","","");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (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("</table><br>Total found: "+total+"<br></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
// End -->
</script>
---------------------------------------------------------------------
Then insert this code into the BODY:
<hr>
<font color="#FFFFFF" size="2" face="Geneva, Arial, Helvetica, san-serif">Simply
type in a keyword or keywords relevant to what you are searching for and click
search <br>
On the 'Results Page' - The higher the score, the higher the relevancy to your
search<br>
<b>Please use lowercase only, NO capitals in the search box below</b></font></div>
<form method=get action="javascript:void(0)" onsubmit="search(this); return false;">
<tr>
<td align="left">
<div align="left">
<input type=text name=srchval value="">
<input type=submit value="Search this CD using keywords or phrases">
</div>
</td>
</tr>
</form>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.