பயனர்:Shrikarsan/SearchNamespace.js
குறிப்பு - சேமித்த பின்னர், நீங்கள் செய்த மாற்றங்களைக் காண்பதற்கு உங்கள் உலவியின் இடைமாற்று அகற்றப்பட வேண்டும்.
- மொஸில்லா பயர்பாக்ஸ் / சபாரி: Shift+Reload, அல்லது Ctrl-F5 அல்லது Ctrl-R (⌘-R Mac ல்)
- கூகிள் குரோம் Ctrl-Shift-R அழுத்தவும். (⌘-Shift-R Mac ல்) ;
- இண்டர்நெட் எக்ஸ்ப்ளோரர்: Ctrl-Refresh அல்லது Ctrl-F5 ஐ அழுத்தவும்.
- ஒபேரா: Tools → Preferences இல் இடைமாற்றை அகற்றவும்;
// Allows the user to select a namespace to search in from the corner search bar
prefixString =
"<option >Article:</option>\n <option>Article talk:</option>\n <option>Wikipedia:</option>\n <option>Wikipedia talk:</option>\n <option>User:</option>\n <option>User talk:</option>\n<option>WikiProject:</option>\n <option>WikiProject talk:</option>\n<option>Category:</option>\n <option>Category talk:</option>\n<option>Template:</option>\n <option>Template talk:</option>\n <option>Help:</option>\n <option>Special:</option>";
$(addNSSearch);
function addNSSearch()
{
//retrieve existing elements that we're going to use
searchBar = document.getElementById("searchInput");
searchButton = document.getElementById("searchButton");
searchForm = document.getElementById("searchform");
searchDiv = document.getElementById("simpleSearch");
//create new elements that we're going to insert
prefixList = document.createElement("select");
hiddenInput = document.createElement("input");
//initialize new elements
prefixList.id = "prefixList";
prefixList.innerHTML = prefixString;
hiddenInput.id = "hiddenInput";
hiddenInput.name = "search";
hiddenInput.type = "hidden";
//insert new elements
searchDiv.insertBefore(hiddenInput, searchBar);
searchForm.insertBefore(prefixList, searchDiv);
//modify old ones
searchForm.onsubmit = createSearchTerm;
searchForm.style.marginTop = "0px";
searchBar.removeAttribute("name"); //since we're no longer using the search bar to submit the search terms directly
searchDiv.style.display = "inline-block";
prefixList.style.marginTop = ".8em";
prefixList.tabIndex = searchBar.tabIndex;
}
//onsubmit handler; concatenates prefixList and searchBar and inserts into hidden input prior to submission
function createSearchTerm(e)
{
//retrieve used elements
hiddenInput = document.getElementById("hiddenInput");
prefixList = document.getElementById("prefixList");
searchBar = document.getElementById("searchInput");
//do the work (handling special cases)
if(prefixList.value == "Article:")
{
hiddenInput.value = "" + searchBar.value;
}
else if(prefixList.value == "Article talk:")
{
hiddenInput.value = "" + "Talk:" + searchBar.value;
}
else if(prefixList.value == "WikiProject:")
{
hiddenInput.value = "" + "Wikipedia:WikiProject " + searchBar.value;
}
else if(prefixList.value == "WikiProject talk:")
{
hiddenInput.value = "" + "Wikipedia talk:WikiProject " + searchBar.value;
}
else
{
hiddenInput.value = "" + prefixList.value + searchBar.value;
}
}