User:Ciencia Al Poder-fduser/global.js

// http://lists.wikia.com/pipermail/wikia-tech-l/2009-May/000196.html if (!window.$G) { window.$G = YAHOO.util.Dom.get; }

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'];

for (var i = 0; i < fn.length; i++) { if (typeof window[fn[i]] != 'function') { window[fn[i]] = function {}; }	} }

if (typeof(window.safemode) == 'undefined') window.safemode = false;

if (YAHOO.util.Cookie.get('safemode') == 'true') { safemode = true; } if (document.location.search.indexOf('safemode=true') != -1) { safemode = true; }

var logBox;

function log(message) { if (!window.logBox){ logBox = document.createElement('textarea'); logBox.id = 'logBox'; $G('bodyContent').appendChild(logBox); }	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; }

/* Evita el envío del formulario al pulsar 'enter' en el resumen */ function anulaSubmitOnEnter { var input = $G('wpSummary'); if (!input) return; $E._simpleAdd(input, 'keypress', escapeEnterInput, 0); }

function escapeEnterInput(e) { if (e.keyCode == 13) { if (e.preventDefault) e.preventDefault; else e.returnValue = false; } }

function addZeroEditSectionLink { if (wgNamespaceNumber == -1 || wgAction != 'view') return; var s = $T.create('span', {'class':'editsection',style:'float:none;position:absolute;'}, [		'[',		$T.create('a', {href: wgScript+'?title='+wgPageName+'&action=edit&section=0', title:'Editar la sección inicial'}, 'editar'),		']'	]); $('#content h1,#article h1,#user_masthead_head h2').eq(0).append(s); }

function restoreEditSaveButtons { var ehTb = $G('edit_enhancements_toolbar'); var eoDiv = $G('editOptions'); if (!ehTb || !eoDiv) return; var ebDiv = $G('wpDiff').parentNode; ebDiv.insertBefore($G('wpSave'),$G('wpDiff')); ebDiv.insertBefore($G('wpPreview'),$G('wpDiff')); $T.makeChildren($G('wpMinoredit').parentNode.childNodes,eoDiv); $T.makeChildren($G('wpWatchthis').parentNode.childNodes,eoDiv); $T.makeChildren([ebDiv],eoDiv); $G('wpSummary').setAttribute('style', 'width: 80% ! important'); ehTb.appendChild(eoDiv); ehTb.removeChild(ehTb.getElementsByTagName('ul')[0]); ehTb.setAttribute('class', 'color1 clearfix'); ehTb.removeAttribute('style'); $G('editpage-copywarn').removeAttribute('style'); var tb = $G('wpTextbox1'); if (tb) { $G('wpTextbox1').setAttribute('style', 'width: 100%;'); } }

// Blame Wikia developers for making so DIRTY code!!! using "this" inside an object (not a class) function nullifyEditEnhancements { window.EditEnhancementsLoad = function{}; 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); }	$E.removeListener(window, 'load', EditEnhancementsLoad); $E.removeListener(window, 'resize', EditEnhancements); }

// Ejecutar aquí try { if (!window.safemode) { disableAnnoyingJSErrors; if (wgAction == 'edit' || wgAction == 'submit') { nullifyEditEnhancements; $(nullifyEditEnhancements); $(restoreEditSaveButtons); $(anulaSubmitOnEnter); }		$(addZeroEditSectionLink); } } catch(e) { alert('Casque en el onload Global.js'); }