Post by Chris on Jun 18, 2011 12:57:09 GMT -8
Code might need an update since CAPTCHA was added to search form if guest, haven't checked yet.
Edit:
If your forum uses the sphinx search engine rather than the standard then you now get a CAPTCHA if searching as guest
The code no longer operates as intended in that situation so here is a modified version
I've added a couple of variables to make the code more customizable
Edit:
If your forum uses the sphinx search engine rather than the standard then you now get a CAPTCHA if searching as guest
The code no longer operates as intended in that situation so here is a modified version
<script type="text/javascript">
<!--
(function(){ /* Collapsible Search Page (CAPTCHA compat)(main Footer)*/
var startValues = {"days":"150", "maxresults":"50"}
var hiddenSections = ['Boards to Search',"Search in", "posted within the last", 'maximum results', "view results as"]
var a,b,c,d
if((a=document.searchForm) && /search|sphinx/.test(pb_action)){
b=a.whattosearch.offsetParent.parentNode;
for(c in startValues){ if(/^-/.test(c)){try{d=c.substr(1);a[d].disabled=true;}catch(e){}}else d= c;
if(d in a){ if(a[d].item){a[d].item(parseInt(startValues[c])-1).checked = true;}else if("checkbox" == a[d].type){a[d].checked = startValues[c];}else{a[d].value = startValues[c];}}}
b.firstChild.firstChild.innerHTML = 'Show <a href="#" style="font-weight:bold;" onclick="return false;" class="searchcollapse" >Less</a> Options:';
b = b.firstChild.firstChild.getElementsByTagName('a')[0]; b.onclick = function(){
var a,ac = arguments.callee;
for(a=0;a<ac.sections.length;a++)ac.sections[a].style.display = ac.sections[a].style.display == "none"?"":"none";
this.innerHTML = this.innerHTML.replace(/^(More|Less)/,function(m,ip){return {More:'Less',Less:'More'}[ip];});
return false;
}
b.onclick.sections = [];
c = a.whattosearch.offsetParent.parentNode; d = RegExp(">"+hiddenSections.join("|").replace(/\|{2,}/g,"|")+":","i")
while(c=c.nextSibling && c.nextSibling){if(d.test(c.cells[0].innerHTML))b.onclick.sections.push(c)}
b.onclick.call( b );
}
})()
// -->
</script>
I've added a couple of variables to make the code more customizable
- var startValues = {"days":"150", "maxresults":"50"}
Here you can set a start value for any named input on the search form, the value specified will be applied as following- inputs of type text or hidden will have its value property affected
- inputs of type checkbox will have its checked property affected
- inputs of type radio will be checked according to index specified in value e.g "1" will be first, "2" second..)
In addition you could disable an input by putting a minus sign (-) in front of it, so if I wanted days set to 365 and make it so it can't be changed I would put "-days":"365". Another example would be if I had a spoiler board I wanted to exclude from searches I would put "-board-spoiler":false - var hiddenSections = ['Boards to Search',"Search in", "posted within the last", 'maximum results', "view results as"]
Name the sections you want collapsed here. There are three sections that however should never be collapsed: "search for", "more options" and the section containing the search button.