Jump to content

Streamlined Quick Search


Dominic

Recommended Posts

We found having to click 'Quick search' and then alter the second column to do a search frustrating as I don't think we've ever searched on a client's ID or a hosting/domain ID. Always on the first name or domain name. Well, 99% of the time.

 

The following mod to the quick search javascript file shows the quick search menu by default with Clients/First Name selected, and then automatically selects Domain for the Hosting and Domains group :)

 

File: /admin/javascript/searchbox.js

 

function togglequicksearch() {
if (document.getElementById('searchbox').style.visibility=="hidden") {
document.getElementById('searchbox').style.visibility="";
} else {
document.getElementById('searchbox').style.visibility="hidden";
}}

togglequicksearch();
document.getElementById('searchfield').selectedIndex = 1;

function populate(o) {
 d=document.getElementById('searchfield');
 v=o.options[o.selectedIndex].value;
 if(!d){return;}
 var mitems=new Array();
 mitems['clients']=['ID','First Name','Last Name','Company Name','Email Address','Address 1','Address 2','City','State','Postcode','Country','Phone Number'];
 mitems['orders']=['Order ID','Order #','Order Date','Amount'];
 mitems['hosting']=['ID','Domain','Client Name','Package','Billing Cycle','Status','Username'];
 mitems['domains']=['ID','Domain','Client Name','Registrar','Status'];
 mitems['invoices']=['Invoice #','Client Name','Invoice Date','Amount','Status'];
 d.options.length=0;
 cur=mitems[v];
 if(!cur){return;}
 d.options.length=cur.length;
 for(var i=0;i<cur.length;i++) {
   d.options[i].text=cur[i];
   d.options[i].value=cur[i];
 }

 if(v == 'hosting' || v == 'domains' || v == "clients") {
   document.getElementById('searchfield').selectedIndex = 1;
 }
}

:)

Link to comment
Share on other sites

Neat :)

 

Another enhancement I thought of - why should I need to click in the search box? 7/10 times when I'm loading the system it's to do a search, so why not add this to the bottom of searchbox.js for focus to be set to the quick search query box:

 

document.forms[0].elements[2].focus();

:)

 

Edit: If you'd prefer the first drop-down to be selected, use "elements[0]", and likewise "elements[1]" to select the second drop-down :)

Link to comment
Share on other sites

  • 2 months later...

How can I mak the domain the default?

I think you should change this part:

 

document.getElementById('searchfield').selectedIndex = 1;

To this:

 

document.getElementById('searchtype').selectedIndex = 3;
document.getElementById('searchfield').selectedIndex = 1;

 

:)

 

How does this differ from the way it works in 3.2.2?

 

John

Wonder where 3.2.2 got the idea from :P

 

Mine is better since it draws focus on page load ;)

Link to comment
Share on other sites

I think you should change this part:

 

document.getElementById('searchfield').selectedIndex = 1;

To this:

 

document.getElementById('searchtype').selectedIndex = 3;
document.getElementById('searchfield').selectedIndex = 1;

 

Thanks Dominic the 1st field is on domain but the second is not on the domain choices?, it's on the name choices

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
Cool! Thank you for sharing. :D

 

I changed the style.visibility=="hidden" to "visible", so now it's visible in all pages all the time. No need to click Quick Search anymore. ;)

 

this no longer works. does anyone have a solution to making the search visible ALL the time.

 

FIXED:

 

added in the line:

togglequicksearch(); 
document.getElementById('searchfield').selectedIndex = 1; 

as shown in the code on the first page and it works.

Link to comment
Share on other sites

  • 3 months later...

Amazing guys. I was racking my brain trying to figure this out and figured it'd be here! :)

 

I also made a little addition of my own. I changed this:

 

  if(v == 'hosting' || v == 'domains' || v == "clients") { 
   document.getElementById('searchfield').selectedIndex = 1;
}

to this:

 

  if(v == 'hosting' || v == 'domains') { 
   document.getElementById('searchfield').selectedIndex = 1; 
 } else if(v == "clients") { 
   document.getElementById('searchfield').selectedIndex = 2; 
 }

 

So that if I selected Clients, it would default to Last Name since 9/10 times that's what I'm searching under anyway.

Link to comment
Share on other sites

  • 2 weeks later...

Tweaked it a bit more using code from this thread... defaults to Domains with domain selected. If you pick Client, then Last name is default:

 

function togglequicksearch() {
if (document.getElementById('searchbox').style.visibility=="hidden") {
	document.getElementById('searchbox').style.visibility="";
} else {
	document.getElementById('searchbox').style.visibility="hidden";
}
}

togglequicksearch(); 
document.getElementById('searchtype').selectedIndex = 3;
populate(document.getElementById('searchtype'));
document.getElementById('searchfield').selectedIndex = 1;

function populate(o) {
 d=document.getElementById('searchfield');
 v=o.options[o.selectedIndex].value;
 if(!d){return;}            
 var mitems=new Array();
 mitems['clients']=['ID','First Name','Last Name','Company Name','Email Address','Address 1','Address 2','City','State','Postcode','Country','Phone Number','CC Number'];
 mitems['orders']=['Order ID','Order #','Order Date','Amount'];
 mitems['hosting']=['ID','Domain','Client Name','Package','Billing Cycle','Status','Username','Dedicated IP','Subscription ID'];
 mitems['domains']=['ID','Domain','Client Name','Registrar','Status','Subscription ID'];
 mitems['invoices']=['Invoice #','Client Name','Invoice Date','Amount','Status'];
 mitems['tickets']=['Ticket #','Subject','Email Address'];
 d.options.length=0;
 cur=mitems[o.options[o.selectedIndex].value];
 if(!cur){return;}
 d.options.length=cur.length;
 for(var i=0;i<cur.length;i++) {
   d.options[i].text=cur[i];
   d.options[i].value=cur[i];
 }
 if(v == 'hosting' || v == 'domains') { 
   document.getElementById('searchfield').selectedIndex = 1; 
 } else if(v == "clients") { 
   document.getElementById('searchfield').selectedIndex = 2; 
 }
}

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated