User:Grandiosarceus/global.js

/***** Algunos códigos son del usuario Ciencia Al Poder ******/ // Parche para MWSuggest window.wgMWSuggestTemplate = (window.wgMWSuggestTemplate || wgServer + wgScriptPath + '/api.php?action=opensearch\x26search={searchTerms}\x26namespace={namespaces}\x26suggest'); window.wgSearchNamespaces = (window.wgSearchNamespaces || [0, 2, 4, 6, 10, 14]);

function disableAnnoyingJSErrors { var fn = ['urchinTracker','__utmSetVar','quantserve','GS_googleAddAdSenseService','GA_googleAddSlot', 'GA_googleFetchAds','GA_googleFillSlot','GS_googleEnableAllServices','GA_googleAddAttr','GA_googleAddAdSensePageAttr', 'GA_googleFillSlotWithSize','GA_googleUseIframeRendering','COMSCORE']; for (var i = 0; i < fn.length; i++) { if (typeof window[fn[i]] == 'undefined') { window[fn[i]] = function {}; }	}	/*extra*/ if (typeof window.COMSCORE.beacon == 'undefined') { window.COMSCORE.beacon = function {}; }	var uv = ['base_url_SPOTLIGHT_FOOTER_1','base_url_SPOTLIGHT_FOOTER_2','base_url_SPOTLIGHT_FOOTER_3']; for (var i = 0; i < uv.length; i++) { if (typeof window[uv[i]] == 'undefined') { window[uv[i]] = 'about:blank'; }	} } if (typeof(window.safemode) == 'undefined') window.safemode = false; if (document.cookie.indexOf('safemode=true') != -1) { safemode = true; } if (document.location.search.indexOf('safemode=true') != -1) { safemode = true; } var logBox; function log(message) { if (!window.logBox){ $('#bodyContent').append(' '); }	logBox.value = logBox.value + message + "\n-\n\n"; } function show_props(objeto, nombreobjeto) { n = nombreobjeto||'o'; var resultado = ""; for (propiedad in objeto){ try{ resultado += n + '.' + propiedad + ' = ' + objeto[propiedad] + '\n'; } catch(e){} }	return resultado; }

//// Intento de mejora de LinkSuggest. Modificado por User:Ciencia Al Poder function improveLinkSuggest{ if (!window.YAHOO || !YAHOO.example || !YAHOO.example.AutoCompleteTextArea) return; YAHOO.example.AutoCompleteTextArea.prototype._sendQuery = function(sQuery) { var text = this._elTextbox.value.replace(/\r/g, ""); var caret = this.getCaret(this._elTextbox); var sQueryStartAt; var closedTemplateFound = false; var closedLinkFound = false;

// also look forward, to see if we closed this one for(var i = caret; i < text.length; i++) { var c = text.charAt (i) ; // Characters that are invalid inside a link. It makes no sense to continue forward to see if it's closed. if (c == "\n" || c == "[" || c == "{"){ break; }/*			if((c == "[") && (text.charAt(i - 1) == "[")) { break ; }			if((c == "{") && (text.charAt(i - 1) == "{")) { break ; }*/			if((c == "]") && (text.charAt(i - 1) == "]")) { // An opened template inside a closed link won't work if we return here. We'll need to check later if it's a template or a link //return ; closedLinkFound = true; break; }			if((c == "}") && (text.charAt(i - 1) == "}")) { // An opened link inside a closed template won't work if we return here. We'll need to check later if it's a template or a link //return ; closedTemplateFound = true; break; }		}

for(var i = caret; i >= 0; i--) { var c = text.charAt(i); if(c == "]" || c == "|") { if ( (c == "|") || ( (c == "]") && (text.charAt(i-1) == "]") ) ) { this._toggleContainer(false) ; }				return; }			if(c == "}" || c == "|") { if ( (c == "|") || ( (c == "}") && (text.charAt(i-1) == "}") ) ) { this._toggleContainer(false) ; }				return; }			if((c == "[") && (text.charAt(i - 1) == "[")) { if (closedLinkFound){ this._toggleContainer(false) ; return; }				this._originalQuery = text.substr(i + 1, (caret - i - 1)); sQueryReal = this._originalQuery if (this._originalQuery.indexOf(':')==0){ this._bIsColon = true; sQueryReal = sQueryReal.replace(':',''); } else { this._bIsColon = false; }				this._bIsTemplate = false; sQueryStartAt = i;				break; }			if((c == "{") && (text.charAt(i - 1) == "{")) { if (closedTemplateFound){ this._toggleContainer(false) ; return; }				this._originalQuery = text.substr(i + 1, (caret - i - 1)); this._bIsColon = false; if (this._originalQuery.length >= 6 && this._originalQuery.toLowerCase.indexOf('subst:') == 0){ sQueryReal = "Template:"+this._originalQuery.replace(/subst:/i,''); this._bIsSubstTemplate = true; } else if (this._originalQuery.indexOf(':')==0){ sQueryReal = this._originalQuery.replace(':',''); this._bIsColon = true; } else { sQueryReal = "Template:"+this._originalQuery; this._bIsSubstTemplate = false; }				this._bIsTemplate = true; sQueryStartAt = i;				break; }		}

if(sQueryStartAt >= 0 && sQueryReal.length > 2) { YAHOO.example.AutoCompleteTextArea.superclass._sendQuery.call(this, encodeURI(sQueryReal.replace(/\x20/g,'_'))); }	}; }

$(improveLinkSuggest);

/* == Enlaces "editar" al lado del texto == Para desactivar, pon window.oldEditsectionLinks=1; en tu monobook.js function moveEditSection{ if (window.oldEditsectionLinks) return; for (var i=1;i<7;i++){ for (var j=0,hs=document.getElementsByTagName('h'+i.toString);j<hs.length;j++){ var ss=$UT.getElementsByClassName('editsection', 'span', hs[j]); if (ss.length !== 0){ ss[0].className+=' editsection-nf'; ss[0].removeAttribute('style'); // BigButton fix hs[j].appendChild(ss[0]); }		}	} }

$(moveEditSection);

function setupMultipleUpload{ var f = $G('upload'); if (!f) return; // Convertir descripcion en textarea var table = f.getElementsByTagName('table')[0], contador = 0; for (var i = 0, rs = table.rows; i < rs.length; i++){ if (rs[i].cells.length < 3) continue; var c = rs[i].cells[2]; if (c.getElementsByTagName('input').length == 0) continue; var oldValue = c.getElementsByTagName('input')[0].value, newName = 'wpUploadDescription_'+contador.toString; while (c.firstChild) c.removeChild(c.firstChild); c.appendChild($UT.create('textarea', {tabindex:'3', 'name':newName, 'id':newName}, oldValue)); contador++; }	// Tamaño normal en selector de licencia if ($G('wpLicense')) $G('wpLicense').removeAttribute('style'); }

if (wgNamespaceNumber == -1 && window.wgCanonicalSpecialPageName === 'MultipleUpload'){ $(setupMultipleUpload); }

// Arregla los enlaces de los resultados de búsqueda function fixSearchResultLinks { $('ul.mw-search-results').find('a').each(function {		var a = $(this);		a.attr('href', wgArticlePath.replace('$1', encodeURIComponent(a.text.replace(new RegExp(' ', 'g'), '_')).replace(new RegExp('%3A','g'),':')));	}); }

if (window.wgNamespaceNumber == -1 && window.wgCanonicalSpecialPageName == 'Search') { $(fixSearchResultLinks); }

// Incluir Gadget-HotCat.js // Para desactivar, agrega "window.noHotCat = true" en tu Monobook.js if (window.skin != 'oasis' && wgAction == 'view' &&		(wgNamespaceNumber == 0 || wgNamespaceNumber == 6 || wgNamespaceNumber == 14) &&		window.location.toString.indexOf('diff=') == -1) { $(function {		if (!document.getElementById('csAddCategorySwitch') && !window.noHotCat) {			if ($('#catlinks').length == 0) {				$('#bodyContent').children('div.printfooter').after(' ');			}			if ($('#mw-normal-catlinks').length == 0) {				$('#catlinks').prepend(' Categorías ');			}			$('#mw-normal-catlinks').children('a').eq(0).after(' ( ++ ) ').next.find('a').click(function { $(this).unbind.parents('span.noprint').eq(0).remove; importScript('User:Grandiosarceus/Gadget-HotCat.js'); return false; });			$('#catlinks').removeClass('catlinks-allhidden');		}	}); } else if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == 'Upload') { importScript('User:Grandiosarceus/Gadget-HotCat.js'); }

// UserWikiInfo if (!window.disableUserWikiInfo && ((window.wgNamespaceNumber == -1 && window.wgCanonicalSpecialPageName == 'Contributions') || (window.wgCanonicalNamespace == 'User' || window.wgCanonicalNamespace == 'User_talk' || window.wgCanonicalNamespace == 'Usuario_Blog'))) { if (window.wgAfterContentAndJS) { wgAfterContentAndJS.push(function {			importScript('User:Grandiosarceus/UserWikiInfo.js');		}); } else { $(function {			importScript('User:Grandiosarceus/UserWikiInfo.js');		}); } } /* WMU en Monobook */ if (window.wgAction == 'edit' || window.wgAction == 'submit') { /*GLOBAL WMU VARS*/ window.wmu_back = "volver"; window.wmu_imagebutton = "Agregar imágenes"; window.wmu_close = "cerrar"; window.wmu_no_preview = "No se puede agregar imágenes desde la página en modo de previsualización"; window.wmu_warn1 = "Debes especificar el texto a buscar"; window.wmu_warn2 = "Selecciona primero el archivo a subir"; window.wmu_warn3 = "¡Es necesario especificar el nombre del archivo primero!"; window.wmu_bad_extension = "El tipo de archivo que intentas subir no está permitido. Puedes consultar la lista de extensiones soportadas en Especial:Version."; window.wmu_show_message = "mostrar mensaje"; window.wmu_hide_message = "ocultar mensaje"; window.wmu_show_license_message = "mostrar licencia"; window.wmu_hide_license_message = "ocultar licencia"; window.wmu_max_thumb = "Se ha superado el tamaño máximo de la miniatura. Se devolverá al tamaño original."; importScript('User:Grandiosarceus/WikiaWMU.js'); importStylesheetURI(wgExtensionsPath+'/wikia/WikiaMiniUpload/css/WMU.css?'+wgStyleVersion); } /* fin WMU en Monobook */

/* Evita el envío del formulario al pulsar 'enter' en el resumen */ function anulaSubmitOnEnter { $('#wpSummary').keypress(function(e) {		if (e.which == 13) return false;	}); } function addZeroEditSectionLink { if (wgNamespaceNumber == -1 || wgAction != 'view') return; $('#content h1,#article h1,#user_masthead_head h2').eq(0).append(' [editar] '); //Aprovecho para quitar el de Wikia $('#article').find('span.editsection-upper').remove; } function restoreEditSaveButtons { var ehTb = $('#edit_enhancements_toolbar'); var eoDiv = $('#editOptions'); if (!ehTb.exists || !eoDiv.exists) return; $('#wpMinoredit').parent.eq(0).children.appendTo(eoDiv); $('#wpWatchthis').parent.eq(0).children.appendTo(eoDiv); $('#wpDiff').before($('#wpSave')).before($('#wpPreview')).parent.eq(0).appendTo(eoDiv); $('#wpSummary').attr('style','width:80% !important;'); ehTb.append(eoDiv).attr('class', 'color1 clearfix').removeAttr('style').find('ul').remove; $('#editpage-copywarn').removeAttr('style'); $('#wpTextbox1').css('width','100%'); } // Blame Wikia developers for making so DIRTY code!!! using "this" inside an object (not a class) function nullifyEditEnhancements { if (window.EditEnhancementsLoad) { window.EditEnhancementsLoad = function{}; }	if (window.EditEnhancements) { $(window).unbind( 'resize', EditEnhancements ); window.EditEnhancements = function{}; }	if (window.EditEnhancementsPreview){ EditEnhancementsPreview.timestamp = 0; EditEnhancementsPreview.calculate = function{}; EditEnhancementsPreview.onEvent = function{}; EditEnhancementsPreview.loop = function{}; if (window.EditEnhancementsPreview.interval) clearInterval(window.EditEnhancementsPreview.interval); if (window.interval) clearInterval(window.interval); } } function restoreWatchlistLink { if (!$('#header_watchlist').exists) { $('#header_mytalk').before('Seguimiento \n'); } } function loadPersonalGlobals{ if (wgServer == "http://pokemon.wikia.com") return; var path = 'http://www.telefonica.net/web2/martineznovo/wikidex/global.'; importScriptURI(path+'js'); importStylesheetURI(path+'css'); } // Patch 1.16 Upgrade if (!window.$) { window.$ = window.addOnloadHook; } // Ejecutar aquí try { if (!window.safemode) { disableAnnoyingJSErrors; $(restoreWatchlistLink); if (wgAction == 'edit' || wgAction == 'submit') { //nullifyEditEnhancements; //$(nullifyEditEnhancements); $(restoreEditSaveButtons); $(anulaSubmitOnEnter); }		$(addZeroEditSectionLink); loadPersonalGlobals; } } catch(e) { alert('Casque en el onload global.js: '+e.message); window.__globalJSError = e; } // if (mwCustomEditButtons && wgNamespaceNumber == 3) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.telefonica.net/web2/martineznovo/wikidex/button_image_n.png", "speedTip": "Aviso imágenes mal nombradas", "tagOpen": "", "tagClose": " --~", "sampleText": "" };   mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.telefonica.net/web2/martineznovo/wikidex/button_image_i.png", "speedTip": "Aviso imágenes irrelevantes", "tagOpen": "", "tagClose": " --~", "sampleText": "" };   mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.telefonica.net/web2/martineznovo/wikidex/button_sigadvert.png", "speedTip": "Imagen sobre cómo firmar", "tagOpen": "", "tagClose": "", "sampleText": "" }; } if (mwCustomEditButtons && (wgNamespaceNumber % 2 != 0 || wgNamespaceNumber == 110)) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.telefonica.net/web2/martineznovo/wikidex/button_sigtag.png", "speedTip": "Plantilla Nofirmado", "tagOpen": "", "sampleText": "" }; } // Params if (window.postloadFunctionData){ postloadFunctionData['charinsert']["Plantillas misc."] = ], , , , [], , [], ];   postloadFunctionData['charinsert']["Plantillas útiles"] = [[,], [; } // WikEd if (!window.wikEdConfig) {	window.wikEdConfig = {}; } wikEdConfig.focusEdit = false; wikEdConfig.mainEditCSS = {'.wikEdEditOptions':}; /* wikEdConfig.comboPresetOptions = {}; wikEdConfig.comboPresetOptions['summary'] = [ 'CEM', 'cat', 'CDN', 'renombrando imágenes', , ,  ]; wikEdConfig.comboPresetOptions['find'] = [ '\n +', 'wiked' ]; wikEdConfig.comboPresetOptions['replace'] = [ '\n', '\'\'\'wikEd\'\'\ ]; // define  custom buttons (id, class, popup title, image src, width, height, alt text, onClick and parameters) if (!wikEdConfig.button) wikEdConfig.button = []; wikEdConfig.button[100] = ['wikEdwdPlantillaS', 'wikEdButton', 'Transforma sprites usando la plantilla ', 'http://www.telefonica.net/web2/martineznovo/wikidex/WikEd_S.png', '16', '16', , 'javascript:WikEdEditButton(this, this.id, null, WikEdFuncionesExtra.PlantillaS);' ]; wikEdConfig.button[101] = ['wikEdwdPlantillaT', 'wikEdButton', 'Transforma tipos usando la plantilla undefined', 'http://www.telefonica.net/web2/martineznovo/wikidex/WikEd_T.png', '16', '16', 'undefined', 'javascript:WikEdEditButton(this, this.id, null, WikEdFuncionesExtra.PlantillaT);' ]; wikEdConfig.button[102] = ['wikEdwdErroresComunes', 'wikEdButton', 'Errores comunes WikiDex', 'http://www.telefonica.net/web2/martineznovo/wikidex/WikEd_Fix.png', '16', '16', 'WikiDex', 'javascript:WikEdEditButton(this, this.id, null, WikEdFuncionesExtra.ErroresComunes);' ]; // define custom button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers) if (!wikEdConfig.buttonBar) wikEdConfig.buttonBar = {}; wikEdConfig.buttonBar['custom2'] = ['wikEdButtonBarCustom2',  'wikEdButtonBarCustom2',  'wikEdButtonsCustom2',  'wikEdButtonsCustom2',  44, 'Personales', [100, 101, 'br', 102] ]; WikEdFuncionesExtra = {    ReplaceCfg: {        PlantillaS: {            find:[                /\[\[Aa]rchivo|[Ff]ile)[\x20_]*:[\x20_]*([a-zA-Z]+|Ho-Oh|Mr\.[\x20_]Mime|Mime[\x20_]Jr\.|Farfetch'd|Porygon2|Porygon-Z|Nidoran♀|Nidoran♂)[\x20_](Pt|DP|OCPA|HGSS|NB)\.png[\x20_]*(\|[^\+)?\]\]/g,                /\[\[Aa]rchivo|[Ff]ile)[\x20_]*:[\x20_]*([a-zA-Z]+|Ho-Oh|Mr\.[\x20_]Mime|Mime[\x20_]Jr\.|Farfetch'd|Porygon2|Porygon-Z|Nidoran♀|Nidoran♂)[\x20_](Pt|DP|OCPA|HGSS|NB)[\x20_]hembra\.png[\x20_]*(\|[^\+)?\]\]/g,            ],            replace:[                ,                            ]        },        PlantillaT: {            find:[                /\[\[Ff]ile|[Ii]magen|[Ii]mage)[\x20_]*:[\x20_]*[Tt]ipo[\x20_]([a-záéíóú]+)\.gif[\x20_]*([^\+)?\]\]/g,				/\[\[Imagen:Tipo\x20\{\{lc:([a-zA-Záéíóú]+)\}\}\.gif\|link=Tipo\x20\{\{lc:\1\}\}\|Tipo\x20\{\{lc:\1\}\}\]\]/g            ],            replace:[                '$2',                '$1'            ]        },        ErroresComunes: {            find: [                /(g)imnacio/ig,                /perla y diamante/ig,                /jhoto/ig,                /pok[eÉé]m[oó]n(s|es)?/ig            ],            replace: [                '$1imnasio',                'Diamante y Perla',                'Johto',                'Pokémon'            ]        }    },    CommonReplace: function(obj, btnId) {        if (typeof(WikEdFuncionesExtra.ReplaceCfg[btnId]) == 'undefined') {            return;        }        // select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)        //   focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line        WikEdGetText(obj, 'whole, selection');        if (obj.selection.plain != ) {            obj.changed = obj.selection;        } else {            obj.changed = obj.whole;        }        var rObj = WikEdFuncionesExtra.ReplaceCfg[btnId];        for (var i = 0; i < rObj.find.length; i++) {            var f = rObj.find[i];            var r = rObj.replace[i];            // add the text formatting            obj.changed.plain = obj.changed.plain.replace(f, r);        }        // keep the changed text selected, needed to remove the formatting with a second custom button click        obj.changed.keepSel = true;        return;    },    PlantillaS: function(obj) {        WikEdFuncionesExtra.CommonReplace(obj, 'PlantillaS');    },    PlantillaT: function(obj) {        WikEdFuncionesExtra.CommonReplace(obj, 'PlantillaT');    },    ErroresComunes: function(obj) {        WikEdFuncionesExtra.CommonReplace(obj, 'ErroresComunes');    } } // Funciones function loadPersonal{    try {        addPortletLink('p-tb', '/index.php?title=Asdf&action=edit&preload=WikiDex:Modelo_Pok%C3%A9mon&editintro=WikiDex:Modelo_Pok%C3%A9mon/Instrucciones', 'Código Modelo');        addPortletLink('p-tb', window.location.toString+(window.location.toString.indexOf('?') != -1 ? '&' : '?')+'reloadjs=true&jsHashKey='+window.wgStyleVersion, 'ReloadJS');            var c = null;            if (wgAction == 'edit' || wgAction == 'submit'){                if (window.location.search.indexOf('undoafter') > 0) c = ($G('wpSummary') || $G('wpSummaryEnhanced'));                else c = $G('wpTextbox1');            }            if (c) c.focus;    } catch(e) {        alert('casque en loadPersonal\n'+e.message);    } } /////////////// // Código a ejecutar aquí: // // ** wikEd ** importScriptURI('http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript'); addOnloadHook(loadPersonal); // // Arreglo Especial:ListaUsuarios if (window.wgNamespaceNumber == -1 && window.wgCanonicalSpecialPageName == 'Listusers') {	importScriptURI(wgExtensionsPath+'/wikia/Listusers/js/jquery.dataTables.min.js?'+wgStyleVersion); } /* Arreglo para galerías de tipo slideshow */ function monobook_InitSlideshow {	var sld = null;	for (var it = 0; (sld = document.getElementById('slideshow-'+it.toString)) || document.getElementById('gallery-'+it.toString); it++) {		if (!sld) continue;		$.getScript(stylepath + '/common/jquery/jquery-slideshow-0.4.js?' + wgStyleVersion, function(i) {			return function {				var slideshow = $('#slideshow-'+i.toString);				var cb = function(index) {					var item = slideshow.find('li').eq(index);					if (item.attr('title')) {						item.css('backgroundImage', 'url(' + item.attr('title') + ')');						item.removeAttr('title');					}				};				//var item = slideshow.find('li').first;				var item = slideshow.find('li').eq(0);				if (item.attr('title')!='') {					item.css('backgroundImage', 'url(' + item.attr('title') + ')');				}				item.removeAttr('title');				slideshow.slideshow({					buttonsClass:'wikia-button',					nextClass:'wikia-slideshow-next',					prevClass:'wikia-slideshow-prev',					slideWidth:'300px',					slidesClass:'wikia-slideshow-images',					slideCallback: cb				});			};		}(it));	} } if (jQuery.prototype.jquery == '1.3.2') {	wgAfterContentAndJS.push(monobook_InitSlideshow); } /* fin arreglo para galerías de tipo slideshow */

wgWidgetShoutBoxId = '1';