| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 670 人关注过本帖
标题:测试功能,后后
只看楼主 加入收藏
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
结帖率:100%
收藏
 问题点数:0 回复次数:2 
测试功能,后后
程序代码:
 
<style>
BODY {FONT-SIZE:9pt;}
TD {FONT-SIZE:9pt; LINE-HEIGHT:11pt;}
input {FONT-SIZE:9pt;}
SELECT {FONT-SIZE:9pt; TEXT-ALIGN:center; WIDTH:100px;}
span {FONT-SIZE:12pt;}
</style>
<script language="JavaScript">
window.onload = function(){

 var color_list = new Array();

 var hex = new Array(6);

 var CurColor;

 var CurIndex;

 hex[0] = "FF"

 hex[1] = "CC"

 hex[2] = "99"

 hex[3] = "66"

 hex[4] = "33"

 hex[5] = "00"

 for(var x=0;x<6;x++){
  for(var y=0;y<6;y++){
   for(var z=0;z<6;z++){
    CurColor = hex[x] + hex[y] + hex[z];
    CurIndex = color_start.options.length;
    color_start.options[CurIndex] = new Option("",CurColor);
    color_start.options[CurIndex].style.backgroundColor = "#"+ CurColor;
    CurIndex = color_end.options.length;
    color_end.options[CurIndex] = new Option("",CurColor);
    color_end.options[CurIndex].style.backgroundColor = CurColor;
   }
  }

 }
}
function Dec2Any(str,num){

 if(!/\d+/.test(str)) return NaN;

 if(!/\d+/.test(num)) return NaN;

 var num=eval(num);

 if(num>36 || num<2)  return NaN;

 var the_str="0123456789abcdefghijklmnopqrstuvwxyz";

 var str=eval(str);

 var residue=0;

 var result="";

 while(true){
  residue=str%num;
  result = the_str.charAt(residue) + result;
  if(str<num) break;
  str=Math.floor(str/num);

 }

 return(result);
}
function get_color(the_num){

 if(the_num > 255) the_num = 255;

 if(the_num < 0)   the_num = 0;

 var the_color = Dec2Any(the_num,16);

 if(the_color.length==1) the_color = "0" + the_color;

 return the_color;
}
function build_text(str,C_start,C_end){

 var the_len = str.length;

 var R_start = eval("0x" + C_start.substr(0,2));

 var R_end = eval("0x" + C_end.substr(0,2));

 var R_unit = Math.floor((R_start - R_end)/the_len);

 var G_start = eval("0x" + C_start.substr(2,2));

 var G_end = eval("0x" + C_end.substr(2,2));

 var G_unit = Math.floor((G_start - G_end)/the_len);

 var B_start = eval("0x" + C_start.substr(4,2));

 var B_end = eval("0x" + C_end.substr(4,2));

 var B_unit = Math.floor((B_start - B_end)/the_len);

 var CurColorStr = "";

 var ResultStr = "";

 var tmp;

 show.value  = "";

 for(var i=0;i<the_len;i++){
  CurColorStr = "#";
  CurColorStr += get_color(R_start - i * R_unit);
  CurColorStr += get_color(G_start - i * G_unit);
  CurColorStr += get_color(B_start - i * B_unit);
  ResultStr   += "<font color='"+CurColorStr+"'>"+str.substr(i,1)+"</font>";
  show.value  += "<font color='"+CurColorStr+"'>"+str.substr(i,1)+"</font>\n";

 }

 return ResultStr;
}
function BuildIt(){

 clearInterval(flash_timer);

 ShowText.innerHTML = build_text(the_text.value,color_start.value,color_end.value);

 if(flash.checked) Flash_text();
}
var flash_timer = null;
var color_list  = null;
function Flash_text(){

 var obj_list = ShowText.children;

 color_list   = new Array();

 for(var i=0;i<obj_list.length;i++){
  color_list[color_list.length] = ShowText.children[i].color;

 }

 flash_timer = setInterval("FlashIt()",50);
}
function FlashIt(){

 var tmp_arr = new Array();

 for(var i=0;i<color_list.length-1;i++){
  tmp_arr[i+1] = color_list[i];

 }

 tmp_arr[0] = color_list[i];

 color_list = tmp_arr;

 for(var i=0;i<color_list.length;i++){
  ShowText.children[i].color = color_list[i];

 }
}
</script>
<table>
<tr>

 <td colspan="3">显示文字: <input id="the_text" type="text" size="50" value="彩虹文字彩虹文字彩虹文字彩虹文字彩虹文字"></td>
</tr>
<tr>

 <td>起始颜色: <select id="color_start" onchange="BuildIt();the_text.focus()"></select></td>

 <td>---- </td>

 <td>结束颜色: <select id="color_end" onchange="BuildIt();the_text.focus()"></select></td>
</tr>
<tr>

 <td colspan="3"><input id="flash" type="checkbox" onclick="this.checked?Flash_text():clearInterval(flash_timer)"><label for="flash">闪烁</label></td>
</tr>
</table>
<span id="ShowText" style></span><br>
<textarea id="show" rows="15" cols="50"></textarea>


[ 本帖最后由 hmhz 于 2007-11-22 16:08 编辑 ]
搜索更多相关主题的帖子: 测试 function center 
2007-11-22 16:01
3314969
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-11-22
收藏
得分:0 
啥东西来的???
2007-11-23 13:50
xiapi
Rank: 1
等 级:新手上路
威 望:2
帖 子:305
专家分:0
注 册:2006-10-11
收藏
得分:0 
:loveliness: :funk: :(

没有什么能够阻挡,我对自由的向往,天马行空的生涯一颗心了无牵挂。
2007-11-24 14:36
快速回复:测试功能,后后
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032435 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved