User:Sinthorion/common.js

alert("Custom JS activated");

/* returns a CSS color that is the inverse of the current color */ function getInversedColor(color) { if (!color) { return 'inherit'; //default color }   rgb = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(\, *\d+.?\d*)?\)$/); var newcolor; if (rgb) { alert("rgb format"); newcolor = "rgba("+(255-rgb[1])+","+(255-rgb[2])+","+(255-rgb[3])+", 0.85)"; } else { // assume color is in hex format alert("hex format: "+color); var r = 255 - parseInt(color.substring(1, 3), 16); var g = 255 - parseInt(color.substring(3, 5), 16); var b = 255 - parseInt(color.substring(5, 7), 16); newcolor = "rgba("+r+","+g+","+b+", 0.85)"; }   return newcolor; }

var messages = $(".speech-bubble-message"); messages.each(function(message) {       var rgb = $(this).css('background-color');        var inverse = getInversedColor(rgb);        alert((typeof inverse) + inverse)        $(this).find("p").css('color', inverse); });