User:Lucideer/Scripts/more search boxes.js

/* ==================================================== */ /*   This replaces the searchbox in the left column    */ /*       with a seperate box for each namespace        */ /*        or a combination of some namespaces. */ /*                                                     */ /*        The function takes an array of objects. */ /*          Each object defines a searchbox. */ /* See User:Lucideer/monobook.js for an example of use */ /* ==================================================== */

function addSearchBoxes(searches){ document.getElementById('searchform').style.display='none'; var div=document.getElementById('searchBody'); for(var i=0,ii=searches.length;i<ii;++i){ var f=document.createElement('form'); f.setAttribute('action','/wiki/Special:Search'); var s=document.createElement('input'); s.setAttribute('type','text'); s.setAttribute('name','search'); s.setAttribute('title','Search '+searches[i].name+' namespace of Wikipedia'); s.setAttribute('rel',searches[i].name); s.setAttribute('value',searches[i].name); s.addEventListener('focus',function{if(this.value==this.getAttribute('rel')){this.value='';}},false); s.addEventListener('blur',function{if(this.value==''){this.value=this.getAttribute('rel');}},false); s.style.color='#666'; f.appendChild(s); for(var j=0,jj=searches[i].namespaces.length+1;j<=jj;++j){ var t=document.createElement('input'); t.setAttribute('type','hidden'); if(j!=jj){t.setAttribute('name',searches[i].namespaces[j]);t.setAttribute('value','1');} else{t.setAttribute('name','fulltext');t.setAttribute('value','Advanced+search');} f.appendChild(t); } div.appendChild(f); } }