Name to Hex color conversion
Please include the name-to-hex color conversion in the native library:
// Here is the solution tied together as a native String native extension using
// MooTools, though you can implement the same thing in whatever framework you prefer:
(function(String){
var valueMatch = {
'rgb(0,0,0)': { 'black': ' ', 'rgb(0,0,0)': ' ' },
'rgba(0,0,0,0)': { 'transparent': ' ', 'rgba(0,0,0,0)': ' ' },
'#ffffff': { 'transparent': ' ' },
'transparent': { 'transparent': ' ' }
},
colorFromProbe = function(color){
color = color.toString();
if(!color.match(/^#.+$|^[^0-9]+$/)) return color;
var probe = ($('moocolorprobe') || new Element('textarea', {
'id': 'moocolorprobe',
'styles': {
'display': 'none',
'color': 'transparent'
}
}).inject(document.body, 'after'));
try{ probe.setStyle('color', color) } catch(e){ return color } //IE throws an error instead of defaulting the style to some color or transparent when the value is unrecognized
var computed = (Browser.ie) ? ieColorToHex(probe) : (Browser.opera) ? probe.style.color : probe.getComputedStyle('color'),
match = valueMatch[computed.replace(/ /g, '')];
probe.setStyle('color', 'transparent');
if((!Browser.ie || Browser.ie9) && color == 'transparent' && (match && match['transparent'])) return 'rgba(0, 0, 0, 0)';
return (computed == 'transparent' || match && !match[color.replace(/ /g, '')]) ? color : computed;
},
ieColorToHex = function(probe){ // Special IE mojo, thanks to Dean Edwards for the inspiration, his code used a pop-up window to test the color, I found you can simply use a textarea instead ;)
var value = probe.set('value', '').createTextRange().queryCommandValue("ForeColor");
value = (((value & 0x0000ff) << 16) | (value & 0x00ff00) | ((value & 0xff0000) >>> 16)).toString(16);
return "#000000".slice(0, 7 - value.length) + value;
};
String.implement({
colorToRgb: function(){
var color = colorFromProbe(this);
return (color.charAt(0) == '#') ? color.hexToRgb() : color;
},
colorToHex: function(){
var color = colorFromProbe(this);
return (color.test('rgb')) ? color.rgbToHex() : color;
}
});
})(String);
Taken from: http://stackoverflow.com/a/3892864/863980
More read: http://www.backalleycoder.com/2010/10/05/converting-css-named-colors-to-rgb-and-hex/
-
Luthfia Syakira commented
Duniaslot777 merupakan login alternatif situs Duniaslot 777 terbaru dengan 10 permainan slot gacor Pragmatic Play, Pg Soft, Habanero, Slot88, Ionslot, Joker
-
Sima Batinah commented
Royal88 menyediakan rtp slot terpercaya Royal 88 dengan nilai kemenangan paling tinggi untuk provider pragmatic play, pg soft, habanbero, slot88, microgaming
-
Zuhyar Halimun commented
Prada4d merupakan daftar situs prada 4d slot gacor pragmatic play dapat menyediakan fitur deposit pulsa Rp 20.000 tanpa adanya potongan sedikitpun
-
Bella Benjawan commented
Thanks for sharing the post https://super-pgslot.com/
-
Bella Benjawan commented
Thanks for sharing the post https://tgabet65.com/
-
Bella Benjawan commented
Thanks for sharing the post https://gd-slot.net/
-
Bella Benjawan commented
Thanks for sharing the post https://pgslot-game.io/
-
Bella Benjawan commented
Thanks for sharing the post https://all4slot.com/
-
dena mutiara commented
Royal88 merupakan situs judi Royal 88 slot online resmi dan terpercaya serta sudah terbukti sebagai salah satu situs judi online pragmatic berlisensi resmi
-
nbkk newgen commented
https://joker99s.com/ ce is not quite the same. Who is playing casino games? If he game is not fun enough to play right n
-
nbkk newgen commented
Please include the name-to-hex color conversion in the native library https://jokerauto.net/%e0%b9%80%e0%b8%a5%e0%b9%88%e0%b8%99%e0%b8%aa%e0%b8%a5%e0%b9%87%e0%b8%ad%e0%b8%95%e0%b8%ad%e0%b8%ad%e0%b8%99%e0%b9%84%e0%b8%a5%e0%b8%99%e0%b9%8c-%e0%b8%9c%e0%b9%88%e0%b8%b2%e0%b8%99%e0%b9%82%e0%b8%97/
-
SexyPG1688 commented
SexyPG1688 777ww เว็บออนไลน์ที่ให้ได้มากกว่า
https://sexypg1688.com/777ww/ -
SexyPG1688 commented
SexyPG1688 <a href="https://sexypg1688.com/wyn168/">777ww</a>เว็บออนไลน์ที่ให้ได้มากกว่า
-
weera chotiwat commented
สล็อต บาคาร่าออนไลน์ <a href="m.fhm789.com"> m.fhm789.com</a>
-
weera chotti commented
Online casino games At present, this is known as having to play with each other dazzled. Until the choice is not quite the same. Who is playing casino games? If he game is not fun enough to play right now. Today we will introduce the most interesting casino games to play. and the most popular If anyone has tried and can't stop for sure. If anyone who likes to win already like the excitement You have to play these games.
Let's go see. https://m.fhm789.com/ -
weera chotti commented
No deposit required is something that online gambling sites. free credit slots There is a reward for the members of the web. free credit https://m.fhm789.com no deposit will be able to play free slots all within the web.
-
weera chotti commented
Very informative post There is a lot of information here that can help any business and game slot online https://m.fhm789.com get started with a successful social networking campaign.
-
weera chotti commented
https://fhm789.com/ FHM789 Online game a new style of slot games. Trends in raising future rewards How to make money for gamblers in bulk and received a lot of attention
-
Weewit Chotiwat commented
https://fhm789.com/ FHM789 is a modern online gambling website. that comes with a complete service There are many camps to serve everyone.
-
jyoti kumari commented
Thanks for sharing this! If you are looking for a great site, https://www.modelescortsindelhi.com/ please visit my website for more information.