Welcome to Wars Wiki!
Welcome, new users! For help on where to start, look at our getting started page and our manual of style. Need more help? Ask a staff member!

MediaWiki talk:Common.js

From Wars Wiki
Jump to navigationJump to search

can some one add the "hasClass" function.[edit source]

//grabbed from [http://wikibound.info/MediaWiki:Common.js] on June 6th, 2011. 

// --------------------------------------------------------
// 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);
        };
})();

It is needed in order for the function "Collapsible tables" to work. Thank you, Tacopill 00:07, 5 June 2011 (BST).