MediaWiki:Common.js: Difference between revisions

mNo edit summary
m (removed more duplicate scripts)
Line 143: Line 143:
                 InterwikiLinks[i].className += " FA";
                 InterwikiLinks[i].className += " FA";
                 InterwikiLinks[i].title = "This is a featured article in another language.";
                 InterwikiLinks[i].title = "This is a featured article in another language.";
            /*
             } else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
             } else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
                 InterwikiLinks[i].className += " GA";
                 InterwikiLinks[i].className += " GA";
                 InterwikiLinks[i].title = "This is a good article in another language.";
                 InterwikiLinks[i].title = "This is a good article in another language.";
            */
             }
             }
         }
         }
Line 554: Line 556:
     }
     }
}
}
/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
})();
/** Interwiki links to featured articles ***************************************
*
*  Description: Highlights interwiki links to featured articles (or
*              equivalents) by changing the bullet before the interwiki link
*              into a star.
*  Maintainers: [[User:R. Koot]]
*/
function LinkFA()
{
    if ( document.getElementById( "p-lang" ) ) {
        var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
            if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
                InterwikiLinks[i].className += " FA"
                InterwikiLinks[i].title = "This is a featured article in another language.";
            }
        }
    }
}
addOnloadHook( LinkFA );