User:Telford/monobook.js

var previousBlockFocus = []; var rootBlocks = []; var ticks = 0; var intervalStarted = false; var intervalId = 0; function inArray (value, arr) { for(var s = 0; s < arr.length; s++) if(value == arr[s]) return true; return false; }

function beginMenu { ticks = new Date.getTime + 1499; }

function closeMenu { if(!intervalStarted) { intervalId = setInterval ( function{			if (ticks < new Date.getTime ) {				for(var i = 0; i < previousBlockFocus.length; i++)					document.getElementById('navBlock'+previousBlockFocus[i]).style.display='none';				clearInterval(intervalId);				intervalStarted = false;			}		}, 500 ); intervalStarted = true; } }

function pinMenu(block) { ticks += 2; var currentBlock = document.getElementById('navBlock'+block); var parentId = (currentBlock.parentNode.id).replace(/^navBlock/, '');

if(previousBlockFocus.length > 0 && inArray(parentId, rootBlocks)) {		previousBlockFocus = previousBlockFocus.reverse; for(var i = 0; i < previousBlockFocus.length; i++) document.getElementById('navBlock'+previousBlockFocus[i]).style.display='none'; previousBlockFocus = []; } else if(inArray(block, previousBlockFocus)) { var closeLeaf = previousBlockFocus.pop; document.getElementById('navBlock'+closeLeaf).style.display="none"; }		currentBlock.style.display = "block"; if(previousBlockFocus.length>0) { var lastOpen = previousBlockFocus.pop; if(parentId != lastOpen) document.getElementById('navBlock'+lastOpen).style.display="none"; else previousBlockFocus.push(parentId); }		if(!inArray(block, rootBlocks)) previousBlockFocus.push(block); }

function forwardSeek(linkArray, block, iteration, htmlResult) { if(linkArray.length > 2) htmlResult.push(''); else htmlResult.push(''); htmlResult.push(' '+linkArray[0]+''); htmlResult.push(' '); if(typeof(linkArray[2]) != 'undefined') { htmlResult.push(''); for(var c = 0; c < linkArray[2].length; c++) block = forwardSeek(linkArray[2][c], block, 0, htmlResult); htmlResult.push(' '); }	return block; }

var linkId = 0; var blockId = 0; var htmlResult = []; htmlResult.push(' '); for (var i = 0; i < navigationLinksArray.length; i++) { var link = navigationLinksArray[i]; htmlResult.push(''); for(var r = 0; r < link.length; r++) { rootBlocks.push(blockId-1); blockId = forwardSeek(link[r], blockId, 0, htmlResult); }		htmlResult.push(' '); }	htmlResult.push(' '); navigationPanel.innerHTML = htmlResult.join('\n'); } function searchInputChangeAndGo(text) { var searchInput = document.getElementById('searchInput'); var goButton = document.getElementById('searchGoButton'); if(typeof(searchInput)=='object'&&typeof(goButton)=='object') { searchInput.value = unescape(text); goButton.click; } } function searchInputChange(searchBox) { if(typeof(searchBox)=='object') { if(searchBox.value!='') { if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest; else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.onreadystatechange=function {				if (xmlhttp.readyState==4 && xmlhttp.status==200) { var searchSuggest = document.getElementById('searchSuggest'); if(typeof(searchSuggest)=='object') { searchSuggest.innerHTML = ''; var response = eval('('+xmlhttp.responseText+')'); var suggestions = response.suggestions; var buffer = []; for(var suggestion in suggestions) { var text = suggestions[suggestion]; buffer.push(''+text+' '); }						searchSuggest.innerHTML=buffer.join('\n'); searchSuggest.style.display='block'; }				}			}			xmlhttp.open("GET","http://wiki.ffxiclopedia.org/index.php?action=ajax&rs=getLinkSuggest&format=json&query="+searchBox.value,true); xmlhttp.send; }	} } function searchInputHide { var searchSuggest = document.getElementById('searchSuggest'); if(typeof(searchSuggest)=='object') setTimeout(function {			searchSuggest.style.display = 'none';		}, 500); } function loadSearchSuggest { var searchContainer = document.getElementById('p-search'); if(typeof(searchContainer)=='object') { searchContainer.innerHTML = ' 	 Search ' + '\n' + '	 ' + '\n' + '		 ' + '\n' + '			' + '\n' + '			' + '\n' + '			 ' + '\n' + '			' + '\n' + '		 ' + '\n' + '	 ' + '\n' + '	 '+'\n'; }	} window.onload=function { loadNavigationLinks; loadSearchSuggest };