MediaWiki:Gadget-GradientHeaders.js: Difference between revisions
From Elwiki
mNo edit summary |
mNo edit summary |
||
Line 7: | Line 7: | ||
var bgimage = th.css('background-image'); | var bgimage = th.css('background-image'); | ||
if(bgcolor != 'Rainbow' && bgimage == 'none'){ | if(bgcolor != 'Rainbow' && bgimage == 'none'){ | ||
th.css('background-image', 'linear-gradient(to bottom, | var Pc = bgcolor.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+,\s*(0?\.\d+|1(.0*)?)\s*\)/); | ||
Pc = Math.min(Math.max(0, Pc[1]), 1); | |||
Pc = Math.round(255 * Pc); | |||
var grayscale = 'rgb(' + [Pc, Pc, Pc].join() + ')'; | |||
th.css('background-image', 'linear-gradient(to bottom, ' + grayscale + ', ' + bgcolor + ')'); | |||
} | } | ||
}); | }); | ||
} | } | ||
}); | }); |
Revision as of 18:40, 4 June 2016
$('tr').each(function(){
var tr = $(this);
if(!tr.hasClass('rainbow')){
tr.children('th').each(function(){
var th = $(this);
var bgcolor = th.css('background-color');
var bgimage = th.css('background-image');
if(bgcolor != 'Rainbow' && bgimage == 'none'){
var Pc = bgcolor.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+,\s*(0?\.\d+|1(.0*)?)\s*\)/);
Pc = Math.min(Math.max(0, Pc[1]), 1);
Pc = Math.round(255 * Pc);
var grayscale = 'rgb(' + [Pc, Pc, Pc].join() + ')';
th.css('background-image', 'linear-gradient(to bottom, ' + grayscale + ', ' + bgcolor + ')');
}
});
}
});