js测试点击数速度的源码.docx
《js测试点击数速度的源码.docx》由会员分享,可在线阅读,更多相关《js测试点击数速度的源码.docx(15页珍藏版)》请在冰豆网上搜索。
js测试点击数速度的源码
1动脑小游戏
游戏篇--动脑小游戏
游戏篇--动脑小游戏
--案例代码1开始-->
--[Step1]:
这里能够设置网格的大小-->
varsize=5
varmoves=0
varon=0
varoff=size*2
varcurrent=null
functionStartGame(){
size=document.all.gameSize.value
if(size<3)size=3
if(size>10)size=10
document.all.gameSize.value=size
document.all.board.outerHTML=BuildTable()
moves=0
document.all.moves.innerText=moves
CountTable()
}
functionBuildTable(){
varstr=""
for(varx=0;xstr+="
"for(vary=0;y"}
str+="
"}
str+=""
returnstr
}
functionWhenClick(){
SetTableColor(current)
varcellIdx=current.cellIndex
varrowIdx=current.parentElement.rowIndex
if(rowIdx>0)SetTableColor(board.rows[rowIdx-1].cells[cellIdx])
if(rowIdxif(cellIdx>0)SetTableColor(board.rows[rowIdx].cells[cellIdx-1])
if(cellIdxmoves++
document.all.moves.innerText=moves
if(CountTable()){
board.onclick=null
board.onmouseover=null
current.style.background="#990066"}
}
functionWhenOver(){
if((event.srcElement.tagName=="TD")&&(current!
=event.srcElement)){
if(current!
=null)current.style.backgroundColor=current._background
event.srcElement._background=event.srcElement.style.backgroundColor
event.srcElement.style.backgroundColor="lightgrey"
current=event.srcElement}
}
functionSetTableColor(el){
if((el._background=="")||(el._background==null)){
el.style.backgroundColor="#990066"
el._background="#990066"}
else{
el.style.backgroundColor=""
el._background=""}
}
functionCountTable(){
off=0;on=0
for(varx=0;xfor(vary=0;yvarp=board.rows[x].cells[y]
if(p._background=="#990066")on++
elseoff++}
document.all.on.innerText=on
if(off!
=0)document.all.off.innerText=off
elsedocument.all.off.innerText="0"
return(off==0)
}
--案例代码1结束-->
--案例代码2开始-->
A.cOn{text-decoration:
none;font-weight:
bolder}
#article{font:
12ptVerdana,geneva,arial,sans-serif;background:
white;color:
black;padding:
10pt15pt05pt}
#articleP.start{text-indent:
0pt}
#articleP{margin-top:
0pt;font-size:
10pt;text-indent:
12pt}
#article#author{margin-bottom:
5pt;text-indent:
0pt;font-style:
italic}
#pageListP{padding-top:
10pt}
#articleH3{font-weight:
bold}
#articleDL,UL,OL{font-size:
10pt}
#board{cursor:
default}
#boardTD{width:
25px;height:
25px;}
| 大小: | --[Step2]: 在此可以更改文本框的初始值和列长度--> | |
|
--案例代码2结束-->