User:Ivancillo/wikiajumpES.js

//-// // BEGIN: Wikia Jump for WikiSwich // //-//

var wikiaDomainList; var WikiSwitchSelf = undefined;

var wikiajump = { renderWikiaJump: function { function modesListOn { var modes = document.getElementById('jump_modes'); document.getElementById('jump_mode_icon').style.backgroundColor = '#FFF'; modes.style.display = 'block'; clearTimeout( modes.timer ); }		function modesListTimeOff { document.getElementById('jump_modes').timer = setTimeout( function {				document.getElementById('jump_mode_icon').style.backgroundColor = 'transparent';				document.getElementById('jump_modes').style.display = 'none';			}, 1000 ); }		var nav = document.getElementById('navigation_widget'); var search = document.getElementById('search_box'); if( !nav || !search ) return false; var jump = document.createElement('div'); jump.id = 'jump_box'; jump.className = 'color1'; var form = document.createElement('form'); form.onsubmit = wikiajump.doSwitch; var modeIcon = document.createElement('div'); modeIcon.id = 'jump_mode_icon'; modeIcon.className = 'jump_mode jump_mode_go'; modeIcon.onmouseover = modesListOn; modeIcon.onmouseout = modesListTimeOff; form.appendChild( modeIcon ); var modes = document.createElement('ul'); modes.id = 'jump_modes'; function makeModeButton( mode, title ) { var modeButton = document.createElement('li'); modeButton.id = 'jump_mode_'+mode; modeButton.className = 'jump_mode_'+mode; modeButton.type = mode; modeButton.appendChild( document.createTextNode( title ) ); modeButton.onclick = function { var modes = document.getElementById('jump_modes'); var modeField = document.getElementById('jump_mode'); var modeIcon = document.getElementById('jump_mode_icon'); modeField.value = this.type; modeIcon.className = 'jump_mode jump_mode_'+this.type; modeIcon.style.backgroundColor = 'transparent'; modes.style.display = 'none'; };			modeButton.onmouseover = modesListOn; modeButton.onmouseout = modesListTimeOff; return modeButton; }		modes.appendChild( makeModeButton( 'go', 'Cambiar a una página paralela' ) ); modes.appendChild( makeModeButton( 'edit', 'Editar una página paralela' ) ); modes.appendChild( makeModeButton( 'view', 'Ver una página paralela' ) ); if( addWikiSwitchPageDiff ) modes.appendChild( makeModeButton( 'diff', 'Ver una cruce-wiki diferencia' ) ); if( addWikiSwitchPageClone ) modes.appendChild( makeModeButton( 'clone', 'Cruz-wiki ' ) ); form.appendChild( modes ); var input = document.createElement('input'); input.id = 'jump_field'; input.name = 'Cambiar'; input.type = 'text'; input.title = 'Cambio de wiki'; input.value = 'Nombre de el wiki'; input.jumpactive = false; input.onfocus = function { if( !this.jumpactive ) { this.jumpactive = true; this.style.color = 'black'; this.value = ''; }		};		input.onblur = function { if( this.jumpactive && this.value == '' ) { this.jumpactive = false; this.style.color = 'gray'; this.value = 'Cambiar de wiki'; }		};		input.setAttribute( 'autocomplete', 'off' ); input.onkeyup = wikiajump.listWikis; input.maxlength = 200; form.appendChild( input ); var input = document.createElement('input'); input.id = 'jump_id'; input.name = 'jump_id'; input.type = 'hidden'; input.value = ''; form.appendChild( input ); var input = document.createElement('input'); input.id = 'jump_mode'; input.name = 'mode'; input.type = 'hidden'; input.value = 'go'; form.appendChild( input ); var input = document.createElement('input'); input.id = 'jump_button'; input.type = 'submit'; input.title = 'Jump'; form.appendChild( input ); jump.appendChild( form ); nav.insertBefore( jump, search.nextSibling ); },	listWikis: function { if( this.value == '' ) { wikiajump.setWikiSuggest( new Array ); return true; }		wikiajump.setWikiSuggest(switchlib.getFromPrefixN(this.value, false)); },	setWikiSuggest: function( ids ) { var suggest = document.getElementById('jump_suggest'); if( !suggest ) { var jump = document.getElementById('jump_box'); suggest = document.createElement('div'); suggest.id = 'jump_suggest'; jump.appendChild( suggest ); }		if( !suggest ) return false; var nodes = suggest.childNodes; for( var n = 0; n < nodes.length; n++ ) { suggest.removeChild( nodes[n] ); }		var ul = document.createElement('ul'); for( var i = 0; i < ids.length; i++ ) { if( wikiaDomainList[ids[i]] == null ) continue; var li = document.createElement('li'); /* See http://www.howtocreate.co.uk/referencedvariables.html#scope for more info on this trick */ li.onclick = (function(id) {				return function {					wikiajump.setWiki(id)				}			})(ids[i]) li.appendChild( document.createTextNode(wikiaDomainList[ids[i]].name) ); li.title = wikiaDomainList[ids[i]].title; ul.appendChild(li); }		suggest.appendChild(ul); },	setWiki: function( id ) { var name = document.getElementById('jump_field'); var idField = document.getElementById('jump_id'); idField.value = id; name.value = wikiaDomainList[id].name; var suggest = document.getElementById('jump_suggest'); if( !suggest ) return false; var nodes = suggest.childNodes; for( var n = 0; n < nodes.length; n++ ) { suggest.removeChild( nodes[n] ); }	},	doSwitch: function { var id = document.getElementById('jump_id').value; var name = document.getElementById('jump_field').value; var mode = document.getElementById('jump_mode').value; if( name == '' ) return false; if( !id ) { id = switchlib.getFromText(name); }		if( !id || !wikiaDomainList[id] ) { alert( 'Error: Lo sentimos, WikiaJump no es compatible con los nombres de wiki arbatrary' ); return false; }		if( mode == 'clone' ) { switchlib.pageClone( id ); } else if( mode == 'diff' ) { switchlib.pageCloneAction( id, 'diff' ); } else { window.location = switchlib.convertTitle( id, window.location.href, mode ); }		return false; } } addOnloadHook(wikiajump.renderWikiaJump);

//