Jump to content

Java Search Engine


eaglelegend

Recommended Posts

Ugh, I have this great search engine, created using Java, however the issiue I am having it is not working with Firefox (unsure if it works with anything else) but I know for definately that it works on IE any advise?

 

var SearchWord;
var FindWord;
var result = 0;
var Final = new Array();
var WritePage;
var ShowPage;
var search = new Array();
var site = new Array();

// This is where you can edit the colors and the font along with some other things in order for the script to fit your site.
var websitetitle="Title";
var websiteurl="site";
var objectbg="#dddddd";
var tableborder="#000000";
var tablewidth="75%";
var resultbg="#eeeeee";
var headerbg="#eeeeee";
var objecttext="#000000";
var headertitle="#000080";
var searchtext="#000080";
var searchborder="#000000";
var searchbg="#ffffff";
var searchsitetext="#000000";
var buttonbg="#c0c0c0";
var buttontext="#000000";
var buttonborder="#000000";
var resulttext="#000000";
var fortext="#000000";
var font="Verdana";
var linecolor="#808080";


document.write("<div align='center'><center>\n" +
               "<table border='0' cellpadding='5' cellspacing='0' width='" + tablewidth + "' height='50' style='border: 1px solid " + tableborder + "' bgcolor='" + headerbg + "'>\n" +
               "<tr>\n" +
               "<td width='50%'><font face='" + font + "' color='" + headertitle + "'><big><strong><big>" + websitetitle + "</big></strong></big></font></td>\n" +
               "<td width='50%'><div align='right'><table border='0' cellpadding='0' cellspacing='0'>\n" +
               "<tr>\n" +
               "<td colspan='3'><strong><small><small><font face='" + font + "'>Search " + websiteurl + ": </font></small></small></strong></td>\n" +
               "</tr>\n" +
               "<tr>\n" +
               "<td><input type='text' name='searchbox' size='20' style='font-family: " + font + "; font-size: xx-small; background-color: " + searchbg + "; color: " + searchtext + "; font-weight: bold; border-left: 2px solid " + searchborder + "; border-right: 1px solid " + searchborder + "; border-top: 2px solid " + searchborder + "; border-bottom: 1px solid " + searchborder + "'></td>\n" +
               "<td width='3'></td>\n" +
               "<td><input type='button' value='Ok' onclick='SearchSite(searchbox.value.toLowerCase())' style='font-family: " + font + "; font-size: xx-small; background-color: " + buttonbg + "; color: " + buttontext + "; font-weight: bold; border: 1px solid " + buttonborder + "'></td>\n" +
               "</tr>\n" +
               "</table>\n" +
               "</div></td>\n" +
               "</tr>\n" +
               "</table>\n" +
               "</center></div><div id='searchresult'></div>")


// This is where you add your own links and keywords. As for now you are limited to 15 keywords. and the number(#) in
//brackets must begin with 0 and count from there. When creating your keywords you do not have to have exactly 15 words you
//may have less in the event that you do have less then make sure you add extra "|" to the end as if there were 15 words.

// search[#]="word1|word2|word3|word4|word5|word6|word7|word8|word9|word10|word11|word12|word13|word14|word15"
// site[#]="title|url|description"

search[0]="home|main|ablazen|ablazen.com|art|programming|software|tutorials|web|design|||||"
site[0]="Ablazen Art & Software : Enter|http://www.ablazen.com|Art, programming, and web design all in one place. What more could you ask for?"

search[1]="home|main|ablazen|ablazen.com|art|programming|software|tutorials|web|design|||||"
site[1]="Ablazen Art & Software : A4|http://www.ablazen.com/index2.htm|Art, programming, and web design all in one place. What more could you ask for?"

search[2]="resources|links|affiliates|webpages|web|sites|pages||||||||"
site[2]="Resources|http://www.ablazen.com/links|Check out links to other great sites where you can find stuff similar to whats on the Ablazen site."

search[3]="tshirts|shirts|t|gear|ablazen|stuff|buy|t-shirt|t-shirts|shirt|||||"
site[3]="Ablazen Gear!|http://www.cafepress.com/ablzn_gear1|Buy Ablazen gear and show your support for Ablazen.com, help fund the site so we can keep bringing you cool programs, tutorials, and art."

search[4]="forums|bulletin|boards|message|question|join|sign|up|help|questions|answers|members|member|forum|answer"
site[4]="Ablazen Forums|http://www.ablazen.com/cgi-bin/bbs/ikonboard.cgi|Join the Ablazen forums and get all the answers to your questions."

search[5]="site|map|list|site|||||||||||"
site[5]="Site Map|http://www.ablazen.com/sitemap|View a complete list of everything on the Ablazen site."

search[6]="contact|tainted|e|mail|e-mail|send|message|tainted@ablazen.com|||||||"
site[6]="Contact tainted@ablazen.com|http://www.ablazen.com/contact/index.htm?tainted@ablazen.com|Contact tainted@ablazen.com."

search[7]="contact|help|e|mail|e-mail|send|message|help@ablazen.com|questions|answers|answer|question|||"
site[7]="Contact help@ablazen.com|http://www.ablazen.com/contact/index.htm?help@ablazen.com|Contact help@ablazen.com and ask questions about programs, tutorials, or just about anything else."

search[8]="contact|webmaster|e|mail|e-mail|send|message|webmaster@ablazen.com|questions|answers|answer|question|web|master|site"
site[8]="Contact webmaster@ablazen.com|http://www.ablazen.com/contact/index.htm?webmaster@ablazen.com|Contact webmaster@ablazen.com and ask any questions that may pertain to the site, report errors, broken links, make suggestions."

search[9]="affiliates|link|exchange|trade|links|affiliate|advertise||||||||"
site[9]="Become an Affiliate|http://www.ablazen.com/affiliates.htm|Submit your site to become one of the Ablazen.com affiliates."


function SearchSite(wrd){

  for (i = 0; i < search.length; i++){
    for (a = 0; a < 14; a++){ // If you need to use more keywords for each site change the number to one less than how many you need in this case we use 15 keywords so we use the number 14
      FindWord = search[i].split("|")[a]
      for (n = 0; n < wrd.length; n++){
        SearchWord = wrd.split(" ")[n]
        if(FindWord == SearchWord){
          Final[i] = "<tr>\n<td bgcolor='" + objectbg + "' colspan='2'><font face='" + font + "' size='2'><a href='" + site[i].split("|")[1] + "' target='_top'><b>" + site[i].split("|")[0] + "</b></a> : " + site[i].split("|")[1] + "<br><hr size='1' color='" + linecolor + "'><font face='" + font + "' size='1'>" + site[i].split("|")[2] + "</font></td>\n</tr>\n";
        }
      }
    }
  }

  WritePage = "<center><table width='" + tablewidth + "' cellpadding='5' cellspacing='1' bgcolor='" + tableborder + "'><tr>\n<td bgcolor='" + resultbg + "'>\n<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n<tr>\n<td><p align='left'><font face='" + font + "' size='2'>Searched " + websiteurl + " for <b>" + wrd + "</b>.</font></p></td>\n<td><p align='right'><font face='" + font + "' size='2'><span id='pagecount'></span></font></p></td>\n</tr></table></td></tr>"

  for (i = 0; i < Final.length; i++){
    if(Final[i] != null) { 
      WritePage= WritePage + Final[i];
      result=result+1;
    }
  }

  WritePage = WritePage + "</table></center>"
  searchresult.innerHTML=WritePage;
  pagecount.innerHTML = "Results <b>" + result + "</b> of <b>" + site.length + "</b> pages."

  SearchWord = null;
  FindWord = null;
  result = 0;
  for(i = 0; i < search.length; i++){
    Final[i] = null;
  }

}

Link to comment
Share on other sites

Try this code:

 

var SearchWord;
var FindWord;
var result = 0;
var Final = new Array();
var WritePage;
var ShowPage;
var search = new Array();
var site = new Array();

// This is where you can edit the colors and the font along with some other things in order for the script to fit your site.
var websitetitle="Title";
var websiteurl="site";
var objectbg="#dddddd";
var tableborder="#000000";
var tablewidth="75%";
var resultbg="#eeeeee";
var headerbg="#eeeeee";
var objecttext="#000000";
var headertitle="#000080";
var searchtext="#000080";
var searchborder="#000000";
var searchbg="#ffffff";
var searchsitetext="#000000";
var buttonbg="#c0c0c0";
var buttontext="#000000";
var buttonborder="#000000";
var resulttext="#000000";
var fortext="#000000";
var font="Verdana";
var linecolor="#808080";


document.write("<div align='center'><center>\n" +
               "<table border='0' cellpadding='5' cellspacing='0' width='" + tablewidth + "' height='50' style='border: 1px solid " + tableborder + "' bgcolor='" + headerbg + "'>\n" +
               "<tr>\n" +
               "<td width='50%'><font face='" + font + "' color='" + headertitle + "'><big><strong><big>" + websitetitle + "</big></strong></big></font></td>\n" +
               "<td width='50%'><div align='right'><table border='0' cellpadding='0' cellspacing='0'>\n" +
               "<tr>\n" +
               "<td colspan='3'><strong><small><small><font face='" + font + "'>Search " + websiteurl + ": </font></small></small></strong></td>\n" +
               "</tr>\n" +
               "<tr>\n" +
               "<td><input type='text' name='searchbox' id='searchbox' size='20' style='font-family: " + font + "; font-size: xx-small; background-color: " + searchbg + "; color: " + searchtext + "; font-weight: bold; border-left: 2px solid " + searchborder + "; border-right: 1px solid " + searchborder + "; border-top: 2px solid " + searchborder + "; border-bottom: 1px solid " + searchborder + "'></td>\n" +
               "<td width='3'></td>\n" +
               "<td><input type='button' value='Ok' onclick=\"SearchSite('searchbox');\" style='font-family: " + font + "; font-size: xx-small; background-color: " + buttonbg + "; color: " + buttontext + "; font-weight: bold; border: 1px solid " + buttonborder + "'></td>\n" +
               "</tr>\n" +
               "</table>\n" +
               "</div></td>\n" +
               "</tr>\n" +
               "</table>\n" +
               "</center></div><div id='searchresult'></div>")


// This is where you add your own links and keywords. As for now you are limited to 15 keywords. and the number(#) in
//brackets must begin with 0 and count from there. When creating your keywords you do not have to have exactly 15 words you
//may have less in the event that you do have less then make sure you add extra "|" to the end as if there were 15 words.

// search[#]="word1|word2|word3|word4|word5|word6|word7|word8|word9|word10|word11|word12|word13|word14|word15"
// site[#]="title|url|description"

search[0]="home|main|ablazen|ablazen.com|art|programming|software|tutorials|web|design|||||"
site[0]="Ablazen Art & Software : Enter|http://www.ablazen.com|Art, programming, and web design all in one place. What more could you ask for?"

search[1]="home|main|ablazen|ablazen.com|art|programming|software|tutorials|web|design|||||"
site[1]="Ablazen Art & Software : A4|http://www.ablazen.com/index2.htm|Art, programming, and web design all in one place. What more could you ask for?"

search[2]="resources|links|affiliates|webpages|web|sites|pages||||||||"
site[2]="Resources|http://www.ablazen.com/links|Check out links to other great sites where you can find stuff similar to whats on the Ablazen site."

search[3]="tshirts|shirts|t|gear|ablazen|stuff|buy|t-shirt|t-shirts|shirt|||||"
site[3]="Ablazen Gear!|http://www.cafepress.com/ablzn_gear1|Buy Ablazen gear and show your support for Ablazen.com, help fund the site so we can keep bringing you cool programs, tutorials, and art."

search[4]="forums|bulletin|boards|message|question|join|sign|up|help|questions|answers|members|member|forum|answer"
site[4]="Ablazen Forums|http://www.ablazen.com/cgi-bin/bbs/ikonboard.cgi|Join the Ablazen forums and get all the answers to your questions."

search[5]="site|map|list|site|||||||||||"
site[5]="Site Map|http://www.ablazen.com/sitemap|View a complete list of everything on the Ablazen site."

search[6]="contact|tainted|e|mail|e-mail|send|message|tainted@ablazen.com|||||||"
site[6]="Contact tainted@ablazen.com|http://www.ablazen.com/contact/index.htm?tainted@ablazen.com|Contact tainted@ablazen.com."

search[7]="contact|help|e|mail|e-mail|send|message|help@ablazen.com|questions|answers|answer|question|||"
site[7]="Contact help@ablazen.com|http://www.ablazen.com/contact/index.htm?help@ablazen.com|Contact help@ablazen.com and ask questions about programs, tutorials, or just about anything else."

search[8]="contact|webmaster|e|mail|e-mail|send|message|webmaster@ablazen.com|questions|answers|answer|question|web|master|site"
site[8]="Contact webmaster@ablazen.com|http://www.ablazen.com/contact/index.htm?webmaster@ablazen.com|Contact webmaster@ablazen.com and ask any questions that may pertain to the site, report errors, broken links, make suggestions."

search[9]="affiliates|link|exchange|trade|links|affiliate|advertise||||||||"
site[9]="Become an Affiliate|http://www.ablazen.com/affiliates.htm|Submit your site to become one of the Ablazen.com affiliates."


function SearchSite(wrd){
wrd = document.getElementById(wrd).value.toLowerCase();
for (i = 0; i < search.length; i++){
    for (a = 0; a < 14; a++){ // If you need to use more keywords for each site change the number to one less than how many you need in this case we use 15 keywords so we use the number 14
      FindWord = search[i].split("|")[a]
      for (n = 0; n < wrd.length; n++){
        SearchWord = wrd.split(" ")[n]
        if(FindWord == SearchWord){
          Final[i] = "<tr>\n<td bgcolor='" + objectbg + "' colspan='2'><font face='" + font + "' size='2'><a href='" + site[i].split("|")[1] + "' target='_top'><b>" + site[i].split("|")[0] + "</b></a> : " + site[i].split("|")[1] + "<br><hr size='1' color='" + linecolor + "'><font face='" + font + "' size='1'>" + site[i].split("|")[2] + "</font></td>\n</tr>\n";
        }
      }
    }
  }

  WritePage = "<center><table width='" + tablewidth + "' cellpadding='5' cellspacing='1' bgcolor='" + tableborder + "'><tr>\n<td bgcolor='" + resultbg + "'>\n<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n<tr>\n<td><p align='left'><font face='" + font + "' size='2'>Searched " + websiteurl + " for <b>" + wrd + "</b>.</font></p></td>\n<td><p align='right'><font face='" + font + "' size='2'><span id='pagecount'></span></font></p></td>\n</tr></table></td></tr>"

  for (i = 0; i < Final.length; i++){
    if(Final[i] != null) {
      WritePage= WritePage + Final[i];
      result=result+1;
    }
  }

  WritePage = WritePage + "</table></center>"
  searchresult.innerHTML=WritePage;
  pagecount.innerHTML = "Results <b>" + result + "</b> of <b>" + site.length + "</b> pages."

  SearchWord = null;
  FindWord = null;
  result = 0;
  for(i = 0; i < search.length; i++){
    Final[i] = null;
  }

}

 

The code is using very out-dated methods of referencing elements on the page.

Link to comment
Share on other sites

The code seems to work fine, however I think I have found an issiue, although what users search for comes up, it dont seem to keep the users logged in ie. if you search home, you will come accross the main page, yet if you click on it, it logs you out or if you search or click on other links through the java search engine, it sayhs "you cannot access this page, you must be logged in" etc. I am wondering if the java needs to use any kind of info to tell it that the user is logged in, and allow the site to let you on.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.