?? 01c.htm
字號:
<html>
<head>
<title>涂格子</title>
<meta http-equiv="目錄類型" content="文本/html; 字符集=gb2312">
<style type="text/css">
<!--
a{font-style:normal;text-decoration:none;color:white}
a:hover {BACKGROUND:red;font-style:normal;text-decoration:none;color:yellow}
a:active {font-style:normal;text-decoration:none;color:yellow;}
.white { color: #FFFFFF}
table { font-size: 9pt}
-->
</style>
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="#009900" topmargin="0" leftmargin="0">
<form name="form">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#009900">
<td colspan="3" height="18"> </td>
</tr>
<tr>
<td bgcolor="#009900" width="18"></td>
<td align="center" bgcolor="#FFFFFF" valign="top"> <br>
<table width="56%" border="0" cellspacing="0" cellpadding="0" height="355">
<tr>
<td rowspan="2" width="16" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="white" style="FONT-SIZE: 11pt;">
<tr bgcolor="#336699" bordercolor="#336699">
<td style="BORDER-RIGHT: double; BORDER-TOP: double; BORDER-LEFT: double; BORDER-BOTTOM: double;" height="70"><strong><a href="01.htm">演<br>
<br>
示</a></strong></td>
</tr>
<tr bordercolor="#009900" bgcolor="#009900">
<td style="BORDER-RIGHT: double; BORDER-TOP: double; BORDER-LEFT: double; BORDER-BOTTOM: double" height="70"><strong><a href="01c.htm">源<br>
代<br>
碼</a></strong></td>
</tr>
</table>
</td>
<td rowspan="2" width="8" bgcolor="#009900"> </td>
<td align="center" style="BORDER-RIGHT: double; BORDER-TOP: double; FONT-SIZE: 12pt; BORDER-LEFT: double; BORDER-BOTTOM: double" bordercolor="#009900" valign="top">
<b> </b><br>
<b>涂格子</b>
<hr width="92%" size="1" align="center">
<table cellspacing="0" cellpadding="0" width="81%">
<tr>
<td colspan="2" height="25">注釋:放在<head>與</head>之間</td>
</tr>
<tr>
<td colspan="2">
<p>
<textarea name="head" onFocus="this.select()" onMouseOver="this.focus()" cols="50" style="BACKGROUND-COLOR: #009900;" wrap="VIRTUAL" class="pt9" rows="7"><script>
function ShowMenu(bMenu) {
document.all.idFinder.style.display = (bMenu) ? "none" : "block"
document.all.idMenu.style.display = (bMenu) ? "block" : "none"
idML.className = (bMenu) ? "cOn" : "cOff"
idRL.className = (bMenu) ? "cOff" : "cOn"
return false
}
</script>
<style>
<!--
A.cOn {text-decoration:none;font-weight:bolder}
#article {font: 12pt Verdana, geneva, arial, sans-serif; background: white; color: black; padding: 10pt 15pt 0 5pt}
#article P.start {text-indent: 0pt}
#article P {margin-top:0pt;font-size:10pt;text-indent:12pt}
#article #author {margin-bottom:5pt;text-indent:0pt;font-style: italic}
#pageList P {padding-top:10pt}
#article H3 {font-weight:bold}
#article DL, UL, OL {font-size: 10pt}
-->
</style>
<script>
<!--
function addList(url,desc) {
if ((navigator.appName=="Netscape") || (parseInt(navigator.appVersion)>=4)) {
var w=window.open("","_IDHTML_LIST_","top=0,left=0,width=475,height=150,history=no,menubar=no,status=no,resizable=no")
var d=w.document
if (!w._init) {
d.open()
d.write("<TITLE>Loading...</TITLE><EM>Loading...</EM>")
d.close()
d.location.replace("/assist/listing.asp?url="+escape(url)+"&desc="+escape(desc))
w.opener=self
window.status="Personal Assistant (Adding): " + desc
} else {
window.status=w.addOption(url,desc)
w.focus()
}
}
else
alert("Your browser does not support the personal assistant.")
return false
}
// -->
</script>
<style>
#board {cursor: default}
#board TD {width: 25px; height: 25px; }
</style>
</textarea>
</td>
</tr>
<tr>
<td height="25" colspan="2">注釋:放在<body>與</body>之間</td>
</tr>
<tr>
<td colspan="2">
<textarea name="Code" onFocus="this.select()" onMouseOver="this.focus()" cols="50" wrap="VIRTUAL" style="BACKGROUND-COLOR: #009900;" class="pt9" rows="7"><table border="1" width="90%">
<tr>
<td width="50%" height="27">
<div align="right">
<table id="score" border="0" width="250">
<tr>
<td width="45" align="center">移動: </td>
<td id="moves" width="37">0</td>
<td width="45" align="center">燈滅:</td>
<td id="off" width="37">100</td>
<td width="45" align="center">燈亮:</td>
<td id="on" width="37">0</td>
</tr>
</table>
</div>
</td>
<td width="50%" height="27">
<div align="left">
<table width="185">
<tr>
<td width="54">大小: </td>
<td width="31">
<input id="gameSize" type="text" value="10" size="2" name="text">
</td>
<td width="97">
<input onClick="newGame()" type="button" value="開始游戲" name="button">
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2" height="27" align="center">
<script>
var size=10
var moves = 0
var off = size*2
var on = 0
var current = null
function doOver() {
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
}
}
function setColor(el) {
if ((el._background=="") || (el._background==null)) {
el.style.backgroundColor = "yellow"
el._background = "yellow"
} else {
el.style.backgroundColor = ""
el._background = ""
}
}
function countLights() {
off = 0; on = 0
for (var x=0; x < size; x++)
for (var y=0; y < size; y++) {
var p = board.rows[x].cells[y]
if (p._background=="yellow")
on++
else
off ++
}
document.all.on.innerText = on
if (off!=0)
document.all.off.innerText = off
else
document.all.off.innerText = "You Win!"
return (off==0)
}
function doClick() {
setColor(current)
var cellIdx = current.cellIndex
var rowIdx = current.parentElement.rowIndex
if (rowIdx>0)
setColor(board.rows[rowIdx-1].cells[cellIdx])
if (rowIdx<size-1)
setColor(board.rows[rowIdx+1].cells[cellIdx])
if (cellIdx>0)
setColor(board.rows[rowIdx].cells[cellIdx-1])
if (cellIdx<size-1)
setColor(board.rows[rowIdx].cells[cellIdx+1])
moves++
document.all.moves.innerText = moves
win = countLights()
if (win) {
board.onclick = null
board.onmouseover = null
current.style.background = "yellow"
}
}
function buildBoard() {
var str = "<TABLE ID=board ONSELECTSTART=\"return false\" ONCLICK=\"doClick()\" ONMOUSEOVER=\"doOver()\" cellspacing=0 cellpadding=0 border=5>"
for (var x=0; x < size; x++) {
str+="<TR>"
for (var y=0; y < size; y++) {
str+="<TD>&nbsp;</TD>"
}
str+="</TR>"
}
str+="</TABLE>"
return str
}
function newGame() {
size = document.all.gameSize.value
if (size<3)
size=3
if (size>15)
size=15
document.all.gameSize.value = size
document.all.board.outerHTML = buildBoard()
moves=0
document.all.moves.innerText = moves
countLights()
}
</script>
<script>
document.write(buildBoard())
</script>
</td>
</tr>
<tr>
<td colspan="2" height="27">游戲提示:你能將方格全部填成綠色嗎??開動腦筋,看看有什么規(guī)律和技巧吧。</td>
</tr>
</table></textarea>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="20" class="white" bgcolor="#009900">當(dāng)前位置:<a href="../../index.htm">首
頁</a>→<a href="../index.htm">JavaScript</a>→<a href="index.htm#1">智力游戲</a>→涂格子</td>
</tr>
</table>
<br>
</td>
<td bgcolor="#009900" width="18"></td>
</tr>
<tr bgcolor="#009900">
<td></td>
<td align="center" height="35"> <font color="#FFFFFF"></font> <font color="#FFFFFF">··萬旭網(wǎng)站工作室
設(shè)計(jì)發(fā)布··</font> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -