Here's what I have so far. I'd appreciate it if people would beef-up the
database with information contained in the interface sub-directory.
FWIW, the new help system looks nice & spiffy.
Dom
Title: AbiSource Xsearch
| ');
}
function templateEnd(){
document.write(' |
');
}
function bannerCode() {
document.write(
'
');
}
// ---- END OF CONFIGURATION BLOCK ---- //
//-----------------------------------------------------------------------------------------------
//
// Initialise some variables
//
var finds =0; // This will count the maximum of hits found
var sites =0; // This will count the amount of different sites found (site-matches)
var version = "v4.3" // version number of XSearch
var andresult = false; // do AND search (if not it's an OR)
var SortResults = true; // Sort the results
var display_start = 1;
var displast = 10;
// This is the main start of the script
// it's called by the HTML code
//-----------------------------------------
function searchAll(keyword){
// first we initialise some variables
//------------------------------------
var nw=1;
finds=0;
sites=0;
clearSearch();
// abort on failed parse
//-----------------------
var x = parseIt(keyword);
if(x == -1) {
return;
}
total_keywords=x;
// prepare the output document
//----------------------------
document.open();
document.clear();
AddBody();
// if keywords are to long display an ending ...
//------------------------------------------------
if (keyword.length>50){
keyword=keyword.substring(0,60)+"...";
}
results=new makeArray(records_count,1);
order=new makeArray(records_count,1);
for (q=1; q<=results.length; q++){
results[q]=0;
order[q]=q;
}
data="new" makeRecordLinks(records_count);
foundwords=new makeArray(records_count,0);
while(keywords[nw].length > 1) {
search(data,keywords[nw]);
nw++;
}
if (andresult){
for (a=1; a<=results.length;){
if (results[a]>0){
if (results[a]<=(total_keywords-1)*2){
results[a]=0;
sites=sites-1;
}
}
a++;
}
}
// sort the results, so most hits comes first
//-------------------------------------------
var temp =0;
if ((SortResults==true)&&(keywords!='[all]')){
for (a=results.length; a>=2;){
for (b=1; b
results[order[b]]){
temp=order[b];
order[b]=order[a];
order[a]=temp;
}
b++;
}
a--;
}
} else {
b=0;
for (a=results.length; a>=2;){
if (results[a]>0){
order[b]=a;
b++
}
a--;
}
}
//
// Now we build the output page
//-------------------------------
// display any other search engines we know of
//--------------------------------------------
if ((displaysearchengines==true) && (finds!=0)){
document.write("");
var i =0;
var j =sites;
for (q=0; q<=sites;) {
if (v3[order[q]]=='searchengine') {
pos=data[order[q]].v1.indexOf('href=');
tmpurl=data[order[q]].v1.substring(pos+5,data[order[q]].v1.indexOf(' ',pos+5));
pos=data[order[q]].v1.indexOf(' ',pos);
tmp=data[order[q]].v1.substring(0,pos)+'?'+findw.substring(1,findw.length)+data[order[q]].v1.substring(pos,data[order[q]].v1.length);
document.write("
"+tmp+"
found at: "+tmpurl+"");
i++;
j=j-1;
}
q++;
}
if (i==0){
document.write("
No search engines found.");
}
sites=j;
}
displast=display_start;
displast=displast+10;
if (displast>sites){
displast=sites+1;
}
document.write("
| Search results for: " +keyword +" |
"+
"
Showing results: "+display_start+" - "+(displast-1)+" out of "+sites+""+
"
");
if (finds==0){
document.write("| "+
"Try to use other keywords for a better result"+
"Use multiple keywords if possible"+
"Don't use words like AND, OR, because XSearch doesn't recognise them."+
" |
");
DisplayXSearch();
document.close();
return
}
q2=display_start;
q3=displast;
for (q=display_start; q
0){
if ((v3[order[q]]!='searchengine') || (findw.indexOf('searchengine')>-1)) {
if ((data[order[q]].v1.indexOf('';
data[order[q]].v1=tmp;
}
document.write(""+q2+". "+data[order[q]].v1);
if (v1[order[q]].indexOf("mailto:")!=-1){
document.write("| "+EmailPicture+" | ");
} else if (v1[order[q]].indexOf("ftp:")!=-1){
document.write("| "+FTPPicture+" | ");
} else {
document.write("| "+HTMLPicture+" | ");
}
document.write(""+v3[order[q]]+" found word(s): "+foundwords[order[q]]+" |
");
q2++;
}
else {
q3++;
}
}
q=q+1;
}
if (finds>10){ // sites
document.write(" ");
pages=Math.round(finds/10); //sites
if (finds%10<6) { // sites
pages++;
}
// Create the parameter string
paramstring=searchname+"?keywords="+keyword+"&and="+andresult+"&sort="+SortResults;
if (display_start>1){
document.write("Previous page  |  ");
} else {
document.write("Previous page  |  ");
}
if (displast<=sites){
document.write("Next page  |   Page: ");
} else {
document.write("Next page  |   Page: ");
}
for (i=1; i<=pages;){
if ((((i-1)*10)+1)<=sites) {
document.write(""+i+"   ");
}
i++;
}
document.write('');
}
document.write(" | " +"");
DisplayXSearch();
document.close();
}
// Show all categories in the database
//-------------------------------------
function cat(){
document.open();
document.clear();
AddBody();
if (displaycategories) {
var cats=0;
var singleword="";
var pos = 0;
var match = 0;
data="new" makeRecordLinks(records_count);
results=new makeArray(records_count,0);
order=new makeArray(records_count,0);
for (q=1; q<=records_count; q=q+1){
match=-1;
singleword=data[q].v2;
phrase=data[q].v1;
pos=singleword.indexOf(" ");
singleword=singleword.substring(0,pos);
if (singleword!='searchengine') {
for (b=1; b<=cats; b=b+1){
if (results[b]==singleword){
match=b;
}
}
if (match<0){
cats++;
results[cats]=singleword;
order[cats]=phrase;
} else {
if (order[match].length<80) {
order[match]=order[match]+', '+phrase;
}
}
}
}
document.writeln("");
}
DisplayXSearch();
document.close();
}
// function that will create an array for us
//----------------------------------------------
function makeArray(n,vartype) {
this.length = n;
for (var k = 1; k <= n; k++) {
if (vartype==0){
this[k] = "";
} else {
this[k] = 0;
}
}
return this;
}
// oldArray function
//==================================
function oldArray() {
this.length = oldArray.arguments.length
for (var i = 0; i < this.length; i++) {
this[i] = oldArray.arguments[i]
}
return this;
}
function stripInput(key) {
while(key.substring(0,1) == "," || key.substring(0,1) == " " ) {
key = key.substring(1,key.length);
}
while(key.substring(key.length-1,key.length) == "," || key.substring(key.length-1,key.length) == " ") {
key = key.substring(0,key.length-1);
}
return key;
}
function parseIt(key) {
key = stripInput(key);
key+=" ";
var y = 1;
while(key.indexOf(" ") > 0) {
if (key.substring(0,1)=='"') {
var pos=key.indexOf('"',2);
keywords[y]=key.substring(1,pos);
keywords[y]=stripInput(keywords[y]);
y++;
key=key.substring(pos+1,key.length);
} else {
var pos=key.indexOf(' AND ');
if ((pos>0) && (key.indexOf(' ')>=pos)) {
pos=key.indexOf(' ',pos+5);
keywords[y]=key.substring(0,pos);
keywords[y]=stripInput(keywords[y]);
y++;
key=key.substring(pos+1,key.length);
if (key.substring(0,4)=='AND ') {
pos=keywords[y-1].indexOf(' ')+5;
key=keywords[y-1].substring(pos,keywords[y-1].length)+' '+key;
}
} else {
var pos=key.indexOf(' OR ');
if ((pos>0) && (key.indexOf(' ')>=pos)) {
pos=key.indexOf(' ');
keywords[y]=key.substring(0,pos);
keywords[y]=stripInput(keywords[y]);
if (keywords[y]!=keywords[y-1]) {
y++;
}
key=key.substring(pos+1,key.length);
pos=key.indexOf('OR ');
key=key.substring(pos+3,key.length);
pos=key.indexOf(' ');
keywords[y]=key.substring(0,pos);
keywords[y]=stripInput(keywords[y]);
y++;
key=key.substring(pos+1,key.length);
if (key.substring(0,3)=='OR ') {
key=keywords[y-1]+' '+key;
}
} else {
var pos = key.indexOf(" ");
keywords[y]=key.substring(0,pos);
keywords[y] = stripInput(keywords[y]);
y++;
if(y > 50) {
alert("too many search words");
return -1;
}
key=key.substring(pos+1,key.length);
}}}
}
return y-1;
}
var keywords = new makeArray(50,0);
var results;
var foundword;
var data;
var order;
var total_keywords;
function clearSearch() {
for(var x=1;x <= 25; x++) {
keywords[x]="";
}
}
function dataEntry (){
this.v1="";
this.v2="";
return this;
}
function makeRecordLinks(size) {
this.length = size;
for (var r=1; r<= size; r++) {
this[r] = new dataEntry();
this[r].v1 = v1[r];
this[r].v2 = v2[r];
}
return this;
}
function AddBody(){
var keytext='"'+searchname+'?keywords="+';
var andtext='"&and="+';
document.write('
|
|