<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>前端之路 &#187; color</title>
	<atom:link href="http://www.simcn.com/tag/color/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simcn.com</link>
	<description>网站开发, 前端开发, 高性能前端开发</description>
	<lastBuildDate>Thu, 03 Nov 2011 02:08:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>同事提供的题目(Taobao)</title>
		<link>http://www.simcn.com/javascript-taobao-color-chang</link>
		<comments>http://www.simcn.com/javascript-taobao-color-chang#comments</comments>
		<pubDate>Sat, 10 Oct 2009 08:10:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[默认分类]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[转化]]></category>

		<guid isPermaLink="false">http://www.simcn.com/2009/10/%e5%90%8c%e4%ba%8b%e6%8f%90%e4%be%9b%e7%9a%84%e9%a2%98%e7%9b%aetaobao/</guid>
		<description><![CDATA[alert(toRGB("#0000FF")); //返回rgb(0,0,255) alert(toRGB("#00F")); //返回rgb(0,0,255) alert(toRGB("#FF0000")); //返回rgb(255,0,0) alert(toRGB("taobao")); //返回rgb(taobao) alert(toRGB("#G00")); //返回rgb(#G00) function toRGB(color){ //第有一字符有#号 if(color.indexOf('#')==0){ //判断长度 if(color.length==4){ //取出字母 r = color.match(/([\da-z])/ig); }else{ //取出字母 r = color.match(/([\da-z]{2})/ig); } //返回 return 'rgb('+formatHEX(r) +')'; }else{ return 'rgb('+color+')'; } } //转化色彩数组转为10进制 function formatHEX(x){ var html=[]; for(i in x){ html[i] = parseInt(x[i], 16); if(isNaN(html[i])){ return '#'+x.join(''); } } return html.join(','); }]]></description>
			<content:encoded><![CDATA[<pre name="code" class="brush:javascript">
alert(toRGB("#0000FF"));     //返回rgb(0,0,255)
alert(toRGB("#00F"));     //返回rgb(0,0,255)
alert(toRGB("#FF0000"));     //返回rgb(255,0,0)
alert(toRGB("taobao"));     //返回rgb(taobao)
alert(toRGB("#G00"));     //返回rgb(#G00)

function toRGB(color){

    //第有一字符有#号
    if(color.indexOf('#')==0){

        //判断长度
        if(color.length==4){
            //取出字母
            r = color.match(/([\da-z])/ig);
        }else{
            //取出字母
            r = color.match(/([\da-z]{2})/ig);
        }
        //返回
        return 'rgb('+formatHEX(r) +')';
    }else{
        return 'rgb('+color+')';
    }
}
//转化色彩数组转为10进制
function formatHEX(x){

    var html=[];
    for(i in x){
        html[i] = parseInt(x[i], 16);
        if(isNaN(html[i])){
            return '#'+x.join('');
        }
    }
    return html.join(',');
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.simcn.com/javascript-taobao-color-chang/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

