User:Tom-/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Tom-/monobook.css. |
document.attachEvent("onreadystatechange", function() {
var deleteItem = document.getElementById("ca-delete");
if (deleteItem)
{
var deleteLink = deleteItem.getElementsByTagName("a")[0]
if (deleteLink)
{
deleteLink.accessKey = "";
setTimeout(function(){ deleteLink.accessKey = ""; }, 500);
}
}
}
);
var typePause = 0;
var xmlHttp = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
var searchCache = {};
var searchStr;
var searchEl;
var searchTimeout;
var resultCount;
var resultsEl;
function getResults()
{
var encStr = escape(searchStr.replace(/ /g, '_'));
xmlHttp.open("GET", "/wiki/Special:Search?gen=titlematch&ns0=0&limit=10&search=" + encStr, true);
xmlHttp.onreadystatechange = parseResults;
xmlHttp.send(null);
}
function parseResults()
{
if (xmlHttp.readyState > 3)
{
var resultArr = xmlHttp.responseText.replace(/^$/gm, '').split("\n");
searchCache[searchStr.toLowerCase()] = resultArr;
showResults(resultArr);
}
}
function showResults(resultArr)
{
var returnStr = "";
var resultsEl = searchEl.suggestList;
if (resultArr.length < 1)
resultsEl.style.display = "none";
else
{
resultsEl.innerHTML = "";
for (var i=0; i < resultArr.length-1; i++)
{
var linkEl = document.createElement("a");
linkEl.style.display = "block";
linkEl.style.textDecoration = "none";
linkEl.style.color = "WindowText";
linkEl.style.padding = "1px 3px";
linkEl.href = "http://80.3.244.236/w/" + resultArr[i];
linkEl.onmouseover = function(e)
{
var srcEl = e ? e.target : event.srcElement;
srcEl.style.backgroundColor = "Highlight";
srcEl.style.color = "HighlightText";
}
linkEl.onmouseout = function(e)
{
var srcEl = e ? e.target : event.srcElement;
srcEl.style.backgroundColor = "Window";
srcEl.style.color = "WindowText";
}
if (resultsEl.curSel == i)
{
linkEl.style.backgroundColor = "Highlight";
linkEl.style.color = "HighlightText";
}
var textEl = document.createTextNode(resultArr[i].replace(/_/g, ' '));
var listItemEl = document.createElement("li");
listItemEl.style.padding = 0;
listItemEl.style.margin = 0;
listItemEl.appendChild(linkEl);
linkEl.appendChild(textEl);
resultsEl.appendChild(listItemEl);
}
resultsEl.style.display = "block";
resultsEl.style.top = searchEl.offsetHeight + "px";
resultsEl.style.left = 0;
searchEl.parentNode.style.position = "relative";
searchEl.onblur = function()
{
searchEl.suggestList.style.display = "none";
searchEl.suggestList.parentNode.style.position = "static";
}
}
// set width, top, left
}
function resultType()
{
searchStr = searchEl.value;
if (searchTimeout) clearTimeout(searchTimeout);
if (searchStr != "")
{
if (searchCache[searchStr.toLowerCase()])
showResults(searchCache[searchStr.toLowerCase()])
else
searchTimeout = setTimeout(getResults, typePause);
}
else
{
searchEl.suggestList.style.display = "none";
}
}
document.onkeyup = function(e)
{
var srcEl = e ? e.target : event.srcElement;
if (srcEl.tagName.toLowerCase() == "input" && srcEl.name == "search" && srcEl.type == "text")
{
if (!srcEl.wikiTransform)
{
srcEl.autocomplete = "off";
srcEl.wikiTransform = true;
var listEl = document.createElement("ul");
listEl.style.margin = 0;
listEl.style.padding = 0;
listEl.style.listStyleType = "none";
listEl.style.listStyleImage = "none";
listEl.style.display = "none";
listEl.style.position = "absolute";
listEl.style.border = "1px solid #000";
listEl.style.overflow = "hidden";
listEl.style.font = "menu";
listEl.style.color = "WindowText";
listEl.style.whiteSpace = "nowrap";
listEl.style.cursor = "default";
listEl.style.backgroundColor = "window";
listEl.style.zIndex = 500;
listEl.curSel = -1;
srcEl.parentNode.insertBefore(listEl, srcEl.nextSibling);
srcEl.suggestList = listEl;
/*var posEl = document.createElement("div");
posEl.style.position = "relative";
posEl.appendChild(srcEl);
srcEl.parentNode.replaceChild(posEl, srcEl);*/
}
searchEl = srcEl;
resultType();
}
}
document.onkeydown = function(e)
{
var srcEl = e ? e.target : event.srcElement;
var keyCode = e ? e.charCode : event.keyCode;
if (srcEl.tagName.toLowerCase() == "input" && srcEl.name == "search" && srcEl.type == "text")
{
switch (keyCode)
{
case 40 : // down
var allLinks = srcEl.suggestList.getElementsByTagName("a");
if (srcEl.suggestList.curSel < 0)
{
srcEl.suggestList.curSel = 0;
allLinks[0].style.backgroundColor = "Highlight";
allLinks[0].style.color = "HighlightText";
break;
}
else if (srcEl.suggestList.curSel + 1 < allLinks.length)
{
allLinks[srcEl.suggestList.curSel].style.backgroundColor = "";
allLinks[srcEl.suggestList.curSel].style.color = "";
allLinks[++srcEl.suggestList.curSel].style.backgroundColor = "Highlight";
allLinks[srcEl.suggestList.curSel].style.color = "HighlightText";
}
break;
case 38 : // up
var allLinks = srcEl.suggestList.getElementsByTagName("a");
if (srcEl.suggestList.curSel < 0)
{
srcEl.suggestList.curSel = allLinks.length - 1;
allLinks[allLinks.length - 1].style.backgroundColor = "Highlight";
allLinks[allLinks.length - 1].style.color = "HighlightText";
break;
}
else if (srcEl.suggestList.curSel - 1 >= 0)
{
allLinks[srcEl.suggestList.curSel].style.backgroundColor = "";
allLinks[--srcEl.suggestList.curSel].style.backgroundColor = "Highlight";
allLinks[srcEl.suggestList.curSel].style.color = "HighlightText";
}
break;
case 13 : // return
var allLinks = srcEl.suggestList.getElementsByTagName("a");
if (srcEl.suggestList.curSel > -1)
srcEl.value = allLinks[srcEl.suggestList.curSel].firstChild.nodeValue;
case 37 : // left
break;
case 39 : // right
break;
}
}
}