📄 clone2.js
字号:
//FindClone version 1.05 --2001.09.28 ,Author:Wang Li
//Welcome to ues my javascript code ,no copyright,just please be sure to keep this message
var picnum=12; //avilable picture number
var totalnum=12; //used picture number
var timeout=120;//maximun time admitted
var pictype=".gif";//picture type
var shownum=0;
var isstart=0;
var seconds=0;
var clicknum=0;
var lastid=0;
var boxnum=totalnum*2;
var imgsrc=new Array(boxnum);
var imgshow=new Array(boxnum);
var imgval=new Array(boxnum);
function init()
{
for(j=0;j<boxnum;j++)
{imgsrc[j]="";imgshow[j]=0;imgval[j]=0;}
shownum=0;
lastid=0;
clicknum=0;
seconds=0;
var used=new Array(picnum);
var usenum=0;
var first=0;
var second,pos,step;
while(usenum<totalnum)
{
//document.write("|usenum="+usenum);
if (imgval[first]==0)
{
//document.write("|first="+first);
pos=Math.round(Math.random()*10);
step=Math.round(Math.random()*10);
if (pos>picnum)pos=1;if (pos<=0)pos=1;
//document.write("#"+pos+","+step+"#");
while((used[pos]==1)&&(usenum<totalnum)){pos++;if (pos>picnum)pos=1;}
//document.write("|pos="+pos);
used[pos]=1;usenum++;
imgval[first]=pos;
imgsrc[first]=pos+pictype;
imgshow[first]=0;
second=first+step;
if (second>=totalnum*2) second=0;
//document.write("|second="+second);
while (imgval[second]!=0)
{
//document.write("|imgval"+second+"="+imgval[second]);
second++;
if (second>totalnum*2) second=0;
}
//document.write("|second="+second);
imgval[second]=pos;
imgsrc[second]=pos+pictype;
imgshow[second]=0;
//document.write("|pos="+pos+"|"+picnum);
first++;
}//end if
else first++;
if (first>=totalnum*2) first=0;
}//end while
}
function startit()
{
if (isstart==0)
{
for(j=0;j<totalnum*2;j++)
{hideimg(j);}
listForm.control.value=" 停 止 ";
init();
listForm.counts.value=0;
listForm.clicks.value=0;
listForm.record.value=0;
isstart=1;
seconds=0;
counttime();
}
else
{ isstart=0; listForm.control.value=" 开 始 ";}
}
function doclick(id)
{
var jo,thisone,lastone;
if (isstart==1)
{
if(imgshow[id]==1) return;
else
{
clicknum++;
document.listForm.clicks.value=clicknum;
shownum++;
showimg(id);
imgshow[id]=1;
if (shownum<2) lastid=id;//the first one
else
{
jo=shownum%2;
if((shownum>1)&&(jo==0))//can compare the two showed imgs
{//alert("can compare");
thisone=parseInt(imgval[id]);
lastone=parseInt(imgval[lastid]);
//alert(thisone+"|"+lastone);
if (thisone!=lastone)//not same
{
hideimg(lastid);
imgshow[lastid]=0;//close the last img
shownum--;
lastid=id; //put this be the last for next click
}
//if same do nothing
}
else //cannot compare
{lastid=id;}
}
//alert(shownum);
if(shownum==totalnum*2)//all the imgs have been found out
{ isstart=0;clearTimeout("counttime()");
listForm.control.value=" 开 始 ";
showrecord();
}
}
}
}
function hideimg(id)
{
var v_img;
v_img=eval("img"+id);
v_img.src="hide"+pictype;
}
function showimg(id)
{
var v_img;
v_img=eval("img"+id);
v_img.src=imgsrc[id];
}
function counttime()
{
if (isstart==1)
{
seconds++;
document.listForm.counts.value=seconds;
if (seconds>=timeout)
{
alert("对不起,超时了!");
clearTimeout("counttime()");
}
else
{id=setTimeout("counttime()",1000);}
}
}
function showrecord()
{
var r1,r2,record;
r1=parseInt(listForm.counts.value);
r2=parseInt(listForm.clicks.value);
record=1000-(r1*3+r2*4);
listForm.record.value=record;
if (record>800)alert("好厉害呀!佩服佩服!");
else if (record>730)alert("高手高手,不是碰巧吧?");
else if (record>650)alert("不错不错,继续努力!");
else if (record>600)alert("还行吧,再加把油!");
else if (record>500)alert("不行啊,要努力呀!");
else alert("不会吧?这么...\n@#%*#@#....");
}
function JSClock()
{
var time = new Date()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var temp = "" + ((hour > 12) ? hour - 12 : hour)
temp += ((minute < 10) ? ":0" : ":") + minute
temp += ((second < 10) ? ":0" : ":") + second
temp += (hour >= 12) ? " P.M." : " A.M."
document.clockForm.digits.value = temp
id = setTimeout("JSClock()",1000)
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -