|
|
| Line 1: |
Line 1: |
| function loadsearchstuff() {
| |
| // If you're reading this, I'm sorry. Messy code lies ahead.
| |
|
| |
|
| if (document.implementation && document.implementation.createDocument)
| |
| xmlDoc=document.implementation.createDocument("","",null);
| |
| else
| |
| xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
| |
|
| |
| xmlDoc.async=false;
| |
| xmlDoc.load("/index.php?title=Template:Searchicons&action=raw");
| |
|
| |
| // Establishing the various fragments of the search box.
| |
| var randindex = Math.floor(Math.random()*xmlDoc.getElementsByTagName("item").length);
| |
| var searchicon = "<a href='/wiki/" + xmlDoc.getElementsByTagName("name")[randindex].childNodes[0].nodeValue + "'><img src='" + xmlDoc.getElementsByTagName("url")[randindex].childNodes[0].nodeValue + "' style='margin-left: -15px; margin-top:-6px;' /></a>";
| |
| var searchbox = document.getElementById('searchBody');
| |
|
| |
| // Throwing all the various fragments together.
| |
| var searchfieldentry = document.getElementById('searchInput').value;
| |
| searchbox.innerHTML = searchicon + searchbox.innerHTML;
| |
| document.getElementById('searchInput').value = searchfieldentry;
| |
|
| |
| // Finally, removing the redundant "search" title at the top.
| |
| searchbox.parentNode.removeChild(searchbox.parentNode.getElementsByTagName("h5")[0]);
| |
| }
| |
|
| |
| // This needs to be written from the ground up, since it doesn't work.
| |
| function advancedsearch(fulltext) {
| |
| // This is what drives the advanced search. The URL is rewritten, since the parameters
| |
| // do not actually match what the form expects. This should be fixed if there's a better
| |
| // way of doing it, and there probably is.
| |
|
| |
| var advancedform = document.realform;
| |
| var searchform = document.searchform;
| |
| advancedform.action = "/wiki/Special:Search";
| |
|
| |
| advancedform.action += "?search=" + searchform.search.value;
| |
|
| |
| if (fulltext) advancedform.action += "&fulltext=Search";
| |
| else advancedform.action += "&go=Go";
| |
|
| |
| if (searchform.all.checked || searchform.categories.checked || searchform.templates.checked || searchform.talk.checked) searchform.action += "&searchx=Search";
| |
| // This parameter isn't normally passed in the searchbox, but it seems to
| |
| // make the checkboxes retain their values on the advanced search page.
| |
|
| |
| if (searchform.all.checked)
| |
| for (var i=0; i<15; i++) advancedform.action += "&ns" + i + "=1";
| |
| else { // No need to look at the rest if "all" is checked
| |
| if (searchform.categories.checked) advancedform.action += "&ns14=1";
| |
| if (searchform.templates.checked) advancedform.action += "&ns10=1";
| |
| if (searchform.talk.checked) advancedform.action += "&ns1=1&ns3=1&ns5=1&ns7=1&ns9=1&ns11=1&ns13=1&ns15=1";
| |
| }
| |
|
| |
| advancedform.submit();
| |
|
| |
| return false;
| |
| }
| |
|
| |
| addOnloadHook(loadsearchstuff);
| |