Year of the Dragon: Through May 28th, claim free Expansion Pack (excluding Vecna Unleashed) or a Greater Elixir of Discovery! Speak to Xatheral in the Hall of Heroes. edit

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


Please create an account or log in to build a reputation and unlock more editing privileges, and then visit DDO wiki's IRC Chat/Discord if you need any help!

MediaWiki:Gadget-codeColours.js

From DDO wiki
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes, you can click here or try one of the methods below..

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+r ( Command+r on a Mac)
  • Google Chrome: Press Ctrl+ Shift+R ( Command+ Shift+R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: Click Reload or press F5
  • Opera: Clear the cache in Tools ‣ Preferences
//<nowiki>
const hexKey = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];
const hexColour = new RegExp( '#([0-9A-F]{1,2}){3}', 'i' );
$( 'span.mh' ).each( function() {
  var thisColour = $( this ).text();
  if ( hexColour.test( thisColour ) ) {
    var thisRGB = thisColour.match( /#([0-9A-F]{1,2})([0-9A-F]{1,2})([0-9A-F]{1,2})/ );
    var r = ( hexKey.indexOf( thisRGB[ 1 ][ 0 ] ) * 16 ) + hexKey.indexOf( thisRGB[ 1 ][ 1 ] );
    var g = ( hexKey.indexOf( thisRGB[ 2 ][ 0 ] ) * 16 ) + hexKey.indexOf( thisRGB[ 2 ][ 1 ] );
    var b = ( hexKey.indexOf( thisRGB[ 3 ][ 0 ] ) * 16 ) + hexKey.indexOf( thisRGB[ 3 ][ 1 ] );
    var thisFont = ( Math.sqrt( ( 0.299 * r * r ) + ( 0.587 * g * g ) + ( 0.114 * b * b ) ) > 127.5 ? '#000' : '#FFF' );
    $( this ).css( { 'background-color': thisColour, 'color': thisFont, 'padding': '1px 4px' } );
  }
} );
//</nowiki>[[Category:Gadgets]]