MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
var usesClass = (function() {
var usesClass = (function () {
     var reCache = {};
     var reCache = {};
     return function(element, className) {
     return function (element, className) {
         return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
         return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
     };
     };
Line 14: Line 14:
     isXHTML = /html\:/.test(document.getElementsByTagName('body')[0].nodeName);
     isXHTML = /html\:/.test(document.getElementsByTagName('body')[0].nodeName);
     if (Array.prototype.push == null) {
     if (Array.prototype.push == null) {
         Array.prototype.push = function() {
         Array.prototype.push = function () {
             this[this.length] = arguments[0];
             this[this.length] = arguments[0];
             return (this.length);
             return (this.length);
Line 263: Line 263:
genSetRandDARTNumber();
genSetRandDARTNumber();


$(function() {
$(function () {
     doRoundEdges();
     doRoundEdges();
     performIE();
     performIE();
Line 271: Line 271:
     if (window.location.pathname == '/w/Special:RecentChanges') $('#mw-site-navigation .sidebar-chunk a[href="/w/Special:RecentChanges"]').addClass('mw-has-selflink');
     if (window.location.pathname == '/w/Special:RecentChanges') $('#mw-site-navigation .sidebar-chunk a[href="/w/Special:RecentChanges"]').addClass('mw-has-selflink');
     $('#p-banner').html("<span><span class='main-accent'>El</span>wiki</span>");
     $('#p-banner').html("<span><span class='main-accent'>El</span>wiki</span>");
    $('table[cellpadding="5"][border="1"][style] tr').each(function () {
        let rgb = $(this).css('backgroundColor');
        let colors = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
        let o = Math.round(((parseInt(colors[1]) * 299) + (parseInt(colors[2]) * 587) + (parseInt(colors[3]) * 114)) / 1000);
        if (o < 125) {
            $(this).css('color', 'white');
        }
    });
});
});