MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 304: Line 304:
     $('table[cellpadding="5"][border="1"][style] tr[style*="rgb(68, 68, 68)"] th').css('border-color', 'black');
     $('table[cellpadding="5"][border="1"][style] tr[style*="rgb(68, 68, 68)"] th').css('border-color', 'black');


    $('table[cellpadding="5"][border="1"][style] tr:not(.dungeon-page-fields tr), .segment-header:not(.job-change-collapsible .segment-header)').each(function () {
    function matchHeaderText() {
        var rgb = $(this).css('backgroundColor');
        $('table[cellpadding="5"][border="1"][style] tr:not(.dungeon-page-fields tr), .segment-header:not(.job-change-collapsible .segment-header)').each(function () {
        var colors = rgb.match(/\d+/g);
            var rgb = $(this).css('backgroundColor');
        var o = Math.round(((parseInt(colors[0]) * 299) + (parseInt(colors[1]) * 587) + (parseInt(colors[2]) * 114)) / 1000);
            var colors = rgb.match(/\d+/g);
        if (o < 155 && rgb != 'rgba(0, 0, 0, 0)') {
            var o = Math.round(((parseInt(colors[0]) * 299) + (parseInt(colors[1]) * 587) + (parseInt(colors[2]) * 114)) / 1000);
            $(this).css('color', 'white').css('text-shadow', '1px 1px 1px #000');
            if (o < 155 && rgb != 'rgba(0, 0, 0, 0)') {
        } else if ($(this).parents('.instance-page').length) {
                $(this).css('color', 'white').css('text-shadow', '1px 1px 1px #000');
            $(this).css('color', 'black').css('text-shadow', 'none');
            } else if ($(this).parents('.instance-page').length) {
        }
                $(this).css('color', 'black').css('text-shadow', 'none');
    });
            }
setTimeout(function() {
        });
$('.segment-partial .mw-collapsible-text').each(function() {
        setTimeout(function () {
var color = $(this).parents('.segment').find('.segment-header:eq(0)').css('color');
            $('.segment-partial .mw-collapsible-text').each(function () {
    var shadow = $(this).parents('.segment').find('.segment-header:eq(0)').css('text-shadow');
                var color = $(this).parents('.segment').find('.segment-header:eq(0)').css('color');
    $(this).css({color: color, textShadow: shadow})
                var shadow = $(this).parents('.segment').find('.segment-header:eq(0)').css('text-shadow');
});
                $(this).css({ color: color, textShadow: shadow })
}, 50);
            });
        }, 50);
    }
 
    matchHeaderText();


});
});
Line 423: Line 427:
     $('#dark-mode-switch').after('<div id="dark-mode-notif"></div>');
     $('#dark-mode-switch').after('<div id="dark-mode-notif"></div>');


     $('#dark-mode-switch').click(function() {
     $('#dark-mode-switch').click(function () {
         $('body').toggleClass('dark-mode');
         $('body').toggleClass('dark-mode');
        matchHeaderText();
         if ($('body').hasClass('dark-mode')) {
         if ($('body').hasClass('dark-mode')) {
             setCookie('elwiki-dark-mode', 'true');
             setCookie('elwiki-dark-mode', 'true');