User:Furagaitas/vector.js

var hasClass = (function {    var reCache = {};    return function (element, className) {        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; });

//HIDDENCAT (mostra as categorías ocultas). function addClass(node, className) { if (hasClass(node, className)) { return false; }   node.className += ' '+ className; return true; } function eregReplace(search, replace, subject) { return subject.replace(new RegExp(search,'g'), replace); } function removeClass(node, className) { if (!hasClass(node, className)) { return false; } node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className); return true; } function isClass(element, classe) { return hasClass(element, classe); } function hiddencat { var cl = document.getElementById('catlinks');          if(!cl) return; var hc = document.getElementById('mw-hidden-catlinks'); if(!hc) return; var nc = document.getElementById('mw-normal-catlinks'); if(!nc) { var ahc = ' Categorías :&#32; [ amosar ]  '; document.getElementById('catlinks').innerHTML = ahc + cl.innerHTML; } else if( isClass(hc, 'mw-hidden-cats-hidden') ) { var ahc = ' | [ amosar ]'; document.getElementById('mw-normal-catlinks').innerHTML += ahc; } } function toggleHiddenCats { var hc = document.getElementById('mw-hidden-catlinks'); if( isClass(hc, 'mw-hidden-cats-hidden') ) { removeClass(hc, 'mw-hidden-cats-hidden'); addClass(hc, 'mw-hidden-cat-user-shown'); document.getElementById('mw-hidden-cats-link').innerHTML = '[ ocultar ]'; } else { removeClass(hc, 'mw-hidden-cat-user-shown'); addClass(hc, 'mw-hidden-cats-hidden'); document.getElementById('mw-hidden-cats-link').innerHTML = '[ amosar ]'; } } $(hiddencat);