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/
-
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.
-
here Ole commented
ทางเข้าเล่น joker ผ่านลิ้งเว็ปไซต์ตรง <a href=" http://www.jokerslot.ninja/login-joker/">jokerslot.ninja</a> แหล่งรวบรวมความสนุกที่ส่งตรงมาให้ทุกท่านได้สัมผัสความสนุกแบบ ไม่หยุดยั้ง ล่าเงินรางวัลโบนัสแบบไม่มีจำกัดได้แบบ ตลอดทั้ง 24 ชั่วโมง และหากเข้ามาเป็นสมาชิกก็มีโอกาสในการได้รับเครดิตฟรี สูงสุดมากถึง 150 เครดิตฟรีเพื่อเป็นทุนเริ่มต้นในการเล่นได้อีกด้วย.
-
Santi Jumpla commented
ทั้งนี้ หลายคนก็อาจจะเกิดความสงสัยว่า “ฟรีเครดิต” หรือจำนวนเงินฝากต่าง ๆ นี้ https://sites.google.com/view/fun88asia1/fun88-%E0%B8%A5%E0%B8%AD%E0%B8%81%E0%B8%AD%E0%B8%99
-
suthat kaewtunkum commented
https://kingroyal88.com/ kingroyal 88 is a modern online gambling website. that comes with a complete service There are many camps to serve everyone.
-
suthat kaewtunkum commented
https://gclubvip89.com/ Club, the best online football betting website, online slots and online casinos nowadays.
-
suthat kaewtunkum commented
v
-
suthat kaewtunkum commented
https://slotxoautobet.com/ Online slots games are considered to be the number 1 most popular game that today, a lot of people are paying a lot of attention.