MediaWiki:Gadget-RainbowHeaders.js
From Elwiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$('tr.rainbow').each(function(e){
var tr = $(this);
if(!(tr.css('position') in ['relative', 'absolute'])){
tr.css('position', 'relative');
}
var trWidth = tr.width();
$(this).children('th').each(function(e){
var th = $(this);
var startH = Math.floor(th.offset().left / trWidth * 360);
var endH = Math.floor((th.offset().left + th.width()) / trWidth * 360);
startH = Math.max(0, startH);
endH = Math.min(359, endH);
th.css('background-image', 'linear-gradient(to right, hsl(' + startH + ', 50%, 50%), hsl(' + endH + ', 50%, 50%))');
});
});