Tout est dans le titre !!!
Source / Exemple :
< ============= game.html ==============>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
<BODY text=#000000>
<BR>
<BLOCKQUOTE>
<H1>Démineur en JavaScript !</H1>
<H1>Bonne partie !</H1>
<P></P></BLOCKQUOTE></BODY></HTML>
<============== side.html ================>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<SCRIPT language=JavaScript>
<!--
/*
Script written in November 1996 by VBP
Contact: vbp@via.ecp.fr or http://www.via.ecp.fr/~vbp/
mark = false
function LoadGame(nbCols, nbRows, nbMines) {
cols = nbCols
rows = nbRows
mines = nbMines
document.init_form.columns.value = cols
document.init_form.rows.value = rows
document.init_form.mines.value = mines
unmarked_mines = mines
left = cols*rows - mines
stat = document.init_form.status
stat.value = 'Lancement...'
doc = parent.game.document
doc.close()
doc.open('text/html')
doc.bgColor = "#FDEAB9"
doc.write('<H1>Lancement, veuillez patienter...</H1>')
doc.close()
field = new MineField()
for (var k = 0; k < mines; k++) AddMine()
doc.open('text/html')
doc.bgColor = "#FFFFFF"
doc.write(Table())
doc.close()
RefreshStatus()
first = true
mark = false
HandsOff()
}
function Personalized(form) {
nbCols = form.columns.value
nbRows = form.rows.value
nbMines = form.mines.value
if ( nbMines > nbCols*nbRows/2) {
alert('Trop de mines')
}
else LoadGame(nbCols, nbRows, nbMines)
}
function format(n) {
if ( n < 10 )
var strg = '0'
else
var strg = ''
return strg + n
}
function Table() {
var strg = '<CENTER>\n\n<P><FORM NAME="mineField">\n\n</P>\n\n<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">\n'
for (var i = 0; i < rows ; i++) {
strg += '<TR>\n'
for (var j = 0; j < cols; j++)
strg += '<TD><INPUT TYPE="button" VALUE=" " NAME="' + format(i) + format(j) + '" onClick="parent.init.Check(this)"></TD>\n'
strg += '</TR>\n'
}
strg += '</TABLE>\n\n</FORM>\n'
return strg
}
function HandsOff() {
document.init_form.columns.focus()
}
function ChangeMark(box) {
mark = !mark
box.focus()
}
function MineField() {
for (var i = 0; i < rows; i++) {
this[i] = new Array(cols)
for (var j = 0; j < cols; j++) this[i][j] = false
}
return this
}
function AddMine() {
var i_r = Math.floor(Math.random()*rows)
var j_r = Math.floor(Math.random()*cols)
while ( field[i_r][j_r] ) {
i_r = Math.floor(Math.random()*rows)
j_r = Math.floor(Math.random()*cols)
}
field[i_r][j_r] = true
}
function RefreshStatus() {
if ( unmarked_mines == 1 || unmarked_mines == 0)
stat.value = unmarked_mines + ' Mines Restantes'
else
stat.value = unmarked_mines + ' Mines Restantes'
}
function Check(button) {
if ( mark ) {
if ( button.value == ' ' ) {
button.value = 'M'
unmarked_mines--
RefreshStatus()
}
else if ( button.value == 'M' ) {
button.value = ' '
unmarked_mines++
RefreshStatus()
}
}
else if ( button.value == ' ' ) {
var ci = eval(button.name.substring(0, 2))
var cj = eval(button.name.substring(2, 4))
if ( first ) {
if ( field[ci][cj] ) {
AddMine()
field[ci][cj] = false
}
first = false
}
if ( field[ci][cj] ) {
stat.value = 'Tu as perdu! :-('
ShowMines(ci, cj)
alert('BOOM! TU AS PERDU!')
}
else {
button.value = Count(ci, cj)
if ( button.value == 0 ) with (Math) {
for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
Check(parent.game.document.mineField.elements[i*cols+j])
}
left--
if ( left == 0 ) {
stat.value = 'TU AS GAGNÉ! :-)'
ShowMines(-1, -1)
alert('BRAVO! TU AS GAGNÉ!')
}
}
}
mark = false
HandsOff()
}
function Count(ci, cj) {
var k = 0
with (Math) {
for (var i = max(0, ci-1); i < min(rows, ci+2); i++)
for (var j = max(0, cj-1); j < min(cols, cj+2); j++)
if ( field[i][j] ) k++
}
return k
}
function ShowMines(ci, cj) {
for (var i = 0; i < rows; i++)
for (var j = 0; j < cols; j++)
if ( field[i][j] )
parent.game.document.mineField.elements[i*cols+j].value = 'M'
else if ( parent.game.document.mineField.elements[i*cols+j].value == ' ' )
parent.game.document.mineField.elements[i*cols+j].value = ' '
else if ( parent.game.document.mineField.elements[i*cols+j].value == 'M' )
parent.game.document.mineField.elements[i*cols+j].value = 'E'
if ( ci != -1 )
parent.game.document.mineField.elements[ci*cols+cj].value = 'K'
}
// -->
</SCRIPT>
<META content="MSHTML 6.00.2800.1515" name=GENERATOR><title>Démineur</title></HEAD>
<BODY>
<FORM name=init_form>
<CENTER>
<INPUT onfocus=ChangeMark(document.init_form.columns) size=15
value=Bienvenue ! name=status>
<BR>
<STRONG><FONT
size=+2>Choisissez:</FONT></STRONG>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(8, 4, 4)" type=button value=Débutant>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(14, 8, 20)" type=button value=Moyen>
<HR>
<INPUT onfocus=HandsOff() onclick="LoadGame(20, 12, 50)" type=button value=Expert>
<HR>
<TABLE border=0>
<TBODY>
<TR>
<TH colSpan=2><INPUT onfocus=HandsOff() onclick=Personalized(this.form) type=button value=Personalisé></TH>
<TR>
<TD>Colones :</TD>
<TD><INPUT maxLength=2 size=2 name=columns></TD></TR>
<TR>
<TD>Rangée :</TD>
<TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2 name=rows></TD></TR>
<TR>
<TD>Mines :</TD>
<TD><INPUT onfocus=ChangeMark(this) maxLength=2 size=2
name=mines></TD></TR></TBODY></TABLE>
</CENTER></FORM></BODY></HTML>
<============= demineur.html ============>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML><HEAD><TITLE>Démineur</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR></HEAD><FRAMESET
cols=140,*><FRAME name=init marginWidth=0 marginHeight=0
src="side.html" noresize><FRAME name=game
marginWidth=0 marginHeight=0
src="game.html" noresize></FRAMESET><noframes></noframes></HTML>
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.