IIS Index Server - Hilary Cotter's SearchPage.htm???

This is Interesting: Free IT Magazines  
Home > Archive > IIS Index Server > February 2004 > Hilary Cotter's SearchPage.htm???





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Hilary Cotter's SearchPage.htm???
gully

2004-02-11, 10:34 pm

Hello,

I found the coding (see below) in the newsgroup. I tried coping and pasting
(and fixing the line breaks etc) into a new htm document to see how it
worked. Unfortuantely I have had no luck with it. Could someone explain what
it does and what I might be doing wrong. Thanks.

PS Obviously I am a javascript newbie. :-)

<HTML>
<HEAD>
<TITLE>Bedwetters Anonymous</TITLE>
<STYLE TYPE="text/css">
BODY {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
..heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt;
font-weight:bold}
..cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
..document {font-size:10pt; font-weight:bold; background-color:lightgrey;
width:100%}
</STYLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

var letterexp = /[a-z09]/i;
function hasLetter(str) {return letterexp.test(str)};

function checkform(form)
{

if (!hasLetter(form.target.value))
{
alert("Invalid search string");
form.target.focus();
return false;
}
else
{
test=remove_noise(form.target.value);
if(!test.length)
{
alert("invalid string - too many noise words");
form.target.focus();
return false;
}
else
{
form.target.value=test;
return true;
}
}
}

function remove_noise(phrase)
{
//dimensionalizing variables
noisearray=new Array();
array_phrase=new Array();
array_pruned=new Array();
alert(phrase);

var noisearray=new Array
("0","1","2","3","4","5","6","7","8","9","$","a","about","after","all","also
","an","and","another","any","are","as","at","b","be","because","been","befo
re","being","between","both","but","by","c","came","can","come","could","d",
"did","do","does","e","each","else","f","for","from","g","get","got","h","ha
d","has","have","he","her","here","him","himself","his","how","i","if","in",
"into","is","it","its","j","just","k","l","like","m","make","many","me","mig
ht","more","most","much","must","my","n","never","now","o","of","on","only",
"or","other","our","out","over","p","q","r","re","s","said","same","see","sh
ould","since","so","some","still","such","t","take","Test","than","that","th
e","their","them","then","there","these","they","this","those","through","to
","too","u","under","up","use","v","very","w","want","was","way","we","well"
,"were","what","when","where","which","while","who","will","with","would","x
","y","you","your","z");
var array_pruned_length=0;
var counter=0;
var counter1=0;
var counter2=0;
var phrase1;
var length=0;
var noise_array_counter=0;
var search_phrase="";
var phrase1;
phrase1=phrase;

//spliting the search phrase into an array
array_pruned=phrase.split(" ");
array_pruned_length=array_pruned.length;

for (counter=0;counter <array_pruned_length;counter++)
{
counter2=0;
counter1=0;

for (counter1=0;counter1<noisearray.length;counter1++)
{

if(array_pruned[counter]==noisearray[cou
nter1])
{
search_phrase= " " + array_pruned[counter] + " ";
search_phrase_first_position= array_pruned[counter] + " ";
counter2 = phrase.indexOf(search_phrase,0);
counter3 = phrase. indexOf(search_phrase_first_position,0);

if(counter3<counter2)
counter2=counter3;
while (counter2>= 0)
{
temp_string=array_pruned[counter];
length=temp_string.length;
phrase = phrase.substr(0,counter2) +
phrase.substr(counter2+length+1);
counter2=phrase.indexOf(search_phrase,0);
}
}
}
}
//-- comment the below in production from here
document.write("parsed<BR><P>");
document.write(phrase)
document.write("<BR><P>");
document.write("original<BR><P>");
document.write(phrase1)
alert("click on OK to submit search");
//-- to here
return phrase;
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="LIME">
<form name="searchForm" action="search.asp" method=post>
<b>Search:</b>
<INPUT TYPE="text" NAME="target" SIZE="45" MAXLENGTH="100" VALUE="">
<INPUT TYPE="submit" NAME="goButton" VALUE=" Search " onclick = "return
checkform(this.form)">
<input type="hidden" name="navEvent" value="Top">
</form>
<br>
</html>


gully



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com