..:: MX Studio Fóruns ::..: Busca Interna sem banco de dados - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Busca Interna sem banco de dados Em JavaScript !!

#1 User is offline   parenti 

  • Group: Membros
  • Posts: 90
  • Joined: 06-October 05

  Posted 10 February 2006 - 11:26 AM

Pessoal, uma vez eu olhei em um site que tinha codigos em JavaScript.
um sitema de busca interna, só que sem precisar utilizar banco de dados, vc colocava o codigo fonte, e ele retornava com o title e descrition dos arquivos e não precisava criar nenhum banco de dados, se alguém tiver ou saber onde encontrar esse sistema de busca e quizer me dizer eu agraço !!!
0

#2 User is offline   sergiosperanza 

  • Group: Membros
  • Posts: 5
  • Joined: 04-March 06

  Posted 04 March 2006 - 07:42 PM

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Pesquisa de Produtos e Serviços&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dica</title>
</head>

<body>

<div style="position: absolute; left: 1; top: 2; width: 766; height: 92">
&nbsp;</div>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="763">
<tr>
<td width="763" align="left">
<div style="position: absolute; left: 1; top: 2; width: 766; height: 244">
<table width="766" height="56" id="table5" border="1" cellpadding="5">
<tr>
<td height="60" width="362">
<form method="GET">
<p align="left"><b>
<font face="Arial" style="font-size: 3pt" color="#000080"><br>
&nbsp;</font><font face="Arial" style="font-size: 9pt" color="#000080">&nbsp;
Pesquisa de Produtos e Serviços<a name="topo"></a><br>
</font><font face="Arial" color="#000080" style="font-size: 4pt">
<br>
&nbsp;&nbsp;&nbsp;&nbsp; </font></b>
<font color="#000080" face="Arial" style="font-size: 8pt"><b>Dica :
</b>Faça a pesquisa com uma palavra por vez<br>
&nbsp; Você pode abreviar a palavra : Exemplo : cozinha = cozi</font></p>
</form>
<form NAME="form1" onReset="alert('Dica: digite a palavra cozinha para fazer uma busca de exemplo inicial, depois abra o html e faça as adaptações para seu sistema')">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;<input TYPE="reset" NAME="padrao" VALUE="+ Dicas - clique aqui" style="color: #000080; font-size: 8 pt">
</p>
</form>
<form method="GET">
<p align="left"><font face="Arial" style="font-size: 9pt"><br>
</font><font face="Arial" style="font-size: 9pt" color="#FFFFFF"><b>
<span style="background-color: #999999">&nbsp;Campo de busca </span></b>
</font><b>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font><font face="Arial" style="font-size: 9pt" color="#000080">-</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
</font></b>
<font face="Arial" style="font-size: 9pt" color="#000080">Digite o
Produto ou Serviço</font><font face="Verdana, Arial, Helvetica, sans-serif"><br>
<font size="2">
<input type="text" name="query" size="26" style="font-size: 9 pt; color: #000000; font-family: Verdana; font-variant: small-; border: 1px solid #000000; ">
</font></font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="submit" value="Buscar" style="font-size: 8 pt; color: #000000; font-family: Verdana; font-variant: small-caps; border: 1px solid #000000; "><br>
</font><font face="Arial" style="font-size: 8pt">
<font color="#FF0000"><b>Obs: não utilize acentuação</b></font><b>
</b></font></p>
</form>
</td>
<td height="60" width="373">
<div style="position: absolute; left: 384; top: 3; width: 374; height: 180">
<table border="0" width="374" id="table6">
<tr>
<td width="368">
<p align="center"><b>
<font face="Arial" style="font-size: 3pt" color="#000080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
</font>
<font face="Arial" color="#000080" size="2">&nbsp;Aqui você
coloca um Banner de seu Site ou fotos<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
&nbsp;</font></b></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td height="10" width="748" colspan="2">
<p align="center">&nbsp;<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
</font><font face="Arial" color="#FFFFFF" style="font-size: 9pt">
<span style="background-color: #FF0000">&nbsp; </span></font><b>
<font face="Arial" style="font-size: 9pt; background-color: #FF0000" color="#FFFFFF">
Role a página para ver os resultados da pesquisa&nbsp; </font></b>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">&nbsp;<script language>

function kw_list ()

{

this.keywords = new Array ();

this.num_words = 0;

this.query = "";

this.original_query = "";

this.query_length = 0;

this.possible_points = 0;

this.multiple = points_title + points_keywords + points_description;

this.get_words = get_query;

this.no_query = no_query_found;

}



function get_query ()

{

this.query = top.location.search.substring (top.location.search.indexOf ('=') + 1);

while ((the_plus = (this.query.indexOf ("+", 0))) != -1)

{

this.query_length = this.query.length;

this.query = this.query.substring (0, the_plus) + " " + this.query.substring (the_plus + 1);

}

this.original_query = unescape (this.query);

this.query = this.original_query.toLowerCase ();

this.query_length = this.query.length;

if (this.query != "")

{

var query_pointer = 0;

var end_word = 0;

var at_end = 0;

while ((this.num_words <= (max_keywords - 1)) && (! at_end))

{

end_word = this.query.indexOf (" ", query_pointer);

if (end_word == query_pointer)

query_pointer++;

else

{

if (end_word >= (this.query_length - 1))

at_end = 1;

if (end_word != -1)

this.keywords[this.num_words] = (this.query.substring (query_pointer, end_word)).toLowerCase ();

else

{

this.keywords[this.num_words] = this.query.substring (query_pointer, this.query_length);

at_end = 1;

}

this.num_words++;

if (query_pointer != -1)

query_pointer = end_word + 1;

if (query_pointer > (this.query_length - 1))

at_end = 1;

}

}

if (this.num_words == 0)

return (0);

else

{

this.possible_points = this.multiple * this.num_words;

return (1);

}

}

else

return (0);

}



function no_query_found ()

{

document.writeln ('<link rel="stylesheet" href="gp.css">');

document.writeln ('<CENTER><P>Pesquisa em branco.</P></CENTER>');

}

function entry (url, title, keywords, description)

{

this.url = url;

this.title = title;

this.keywords = keywords;

this.description = description;

this.points = 0;

this.search_entry = find_keyword;

this.print_entry = print_result;

}

function find_keyword (the_word)

{

var the_title = this.title.toLowerCase ();

var the_keywords = this.keywords.toLowerCase ();

var the_description = this.description.toLowerCase ();

if ((the_title.indexOf (the_word)) != -1)

this.points += points_title;

if ((the_keywords.indexOf (the_word)) != -1)

this.points += points_keywords;

if ((the_description.indexOf (the_word)) != -1)

this.points += points_description;

}



function print_result (possible_points)

{

document.writeln ('<A HREF="' + this.url + '" target="meio">' + this.title + '</A> - ' + this.description + '<br>');

}



function no_entry_printed (the_query)

{

document.writeln ('<link rel="stylesheet" href="gp.css">');

document.writeln ("<CENTER><P> Não há ocorrencia da palavra <U><B>" + the_query + "</B></U>.</P></CENTER>");

}



function print_intro (the_query)

{

document.writeln ("<CENTER><P>Os resultados da pesquisa por <U><B>" + the_query + "</B></U> são:</P></CENTER>");

}

function begin_search ()

{

var key_list = new kw_list;

var entry_printed = 0;

if (! key_list.get_words ())

key_list.no_query ();

else

{

var counter = 0;

var counter2 = 0;

for (counter = 0; counter < entry_num; counter++)

for (counter2 = 0; counter2 <= (key_list.num_words - 1); counter2++)

the_entries[counter].search_entry (key_list.keywords[counter2]);

for (counter = key_list.possible_points; counter > 0; counter--)

{

for (counter2 = 0; counter2 < entry_num; counter2++)

{

if (counter == the_entries[counter2].points)

{

if (entry_printed != 1)

{

entry_printed = 1;

print_intro (key_list.original_query);

}

the_entries[counter2].print_entry (key_list.possible_points);

}

}

}

if (! entry_printed)

no_entry_printed (key_list.original_query);

}

}

the_entries = new Array ();

//aqui vai as entradas para a pesquisa

the_entries[0] = new entry ("http://www.foodserviceonline.com.br", "Food Service On Line", "culinaria,chef,cozinha,forno", "Site sobre Culinária Empresarial<br>");
the_entries[1] = new entry ("w", "N", "p1,p2,p3", "p<br>");
the_entries[2] = new entry ("w", "N", "p1,p2,p3", "p<br>");

// the entries[0] é sempre obrigatório o valor zero
// "w" = http://www.site..... você coloca o site
// "N" = nome da empresa que vai ter o link de direcionamento
// "p<br>" onde p= complemento da descrição da empresa ou serviço
// veja o exemplo na linha [0] acima

//abaixo vai o número de entradas existentes, voce deve ir mudando essas entradas conforme for acrescentando linhas the_entries acima

var entry_num = 3; //no caso = [0]+[1]+[2] = 3 aumenta de acordo com as opcoes de busca no caso 3 ate agora

var max_keywords = 20; //aumenta de acordo com as opcoes de busca

var points_title = 3; //no caso = [0]+[1]+[2] = 3 aumenta de acordo com as opcoes de busca no caso 3 ate agora

var points_keywords = 3; //no caso = [0]+[1]+[2] = 3 aumenta de acordo com as opcoes de busca no caso 3 ate agora

var points_description = 1;

begin_search ();

</script>&nbsp;<br>
<br>
&nbsp;</font><font face="Arial" style="font-size: 9pt; background-color: #FF0000">
<b><a href="#topo"><font color="#FFFFFF">topo da página</font></a> </b>
</font></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td width="763">&nbsp;</td>
</tr>
<tr>
<td width="763">&nbsp;</td>
</tr>
<tr>
<td width="763">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>
0

#3 User is offline   LeonardoBehnck 

  • Group: Membros
  • Posts: 479
  • Joined: 14-October 05

Posted 04 March 2006 - 08:42 PM

o código é grande mas eu testei ele aqui e funcionou direitinho thumbsup.gif
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)