[QUOTE]
Серб Григорий написал:
Добрый день, почитайте, что такое экранирование и синтаксис вывода строк в javascript
Код Вашей страницы должен выглядеть примерно так (редактируйте файл как php):[CODE] <?
require ( $_SERVER [ "DOCUMENT_ROOT" ]. "/bitrix/header.php" );
$APPLICATION ->SetTitle( "Шашки" );
?>
<sc ript>
function preload () {
this.length = preload.arguments.length;
for ( var i = 0 ; i < this.length; i++) {
this[i] = new Image();
this[i].src = preload.arguments[i];}}
var pics = new preload( "black.gif" , "gray.gif" ,
"you1.gif" , "you2.gif" , "you1k.gif" , "you2k.gif" ,
"me1.gif" , "me2.gif" , "me1k.gif" , "me2k.gif" );
var black = - 1 ; var red = 1 ; var square_dim = 45 ; var piece_toggled = false ; var my_turn = false ;
var double_jump = false ; var comp_move = false ; var game_is_over = false ; var safe_from = safe_to = null ;
var toggler = null ; var togglers = 0 ;
<!-- web-mastery.info -->
function Board () {
board = new Array ();
for ( var i= 0 ;i< 8 ; i++) {
board[i] = new Array ();
for ( var j= 0 ;j< 8 ;j++)
board[i][j] = Board.arguments[ 8 *j+i];}
board[- 2 ] = new Array ();
board[- 1 ] = new Array ();
board[ 8 ] = new Array ();
board[ 9 ] = new Array (); }
var board;
Board( 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 ,- 1 , 0 ,- 1 , 0 ,- 1 , 0 ,- 1 ,- 1 , 0 ,- 1 , 0 ,- 1 , 0 ,- 1 , 0 , 0 ,- 1 , 0 ,- 1 , 0 ,- 1 , 0 ,- 1 );
function message (str) {
if (!game_is_over)
document.disp.message.value = str;}
function moveable_space (i,j) {
return (((i% 2 )+j)% 2 == 0 );}
function Coord (x,y) {
this.x = x;
this.y = y;}
function coord (x,y) {
c = new Coord(x,y);
return c;}
document.write( "<table border=0 cellspacing=0 cellpadding=0 width=" +(square_dim* 8 + 8 )+ "<tr><td><img data-lazyload class='lazyload' src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-src='black.gif' width=" +(square_dim* 8 + 8 )+ " height=4><br></td></tr>" );
for ( var j= 0 ;j< 8 ;j++) {
document.write( "<tr><td><img data-lazyload class='lazyload' src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-src='black.gif' width=4 height=" +square_dim+ ">" );
for ( var i= 0 ;i< 8 ;i++) {
if (moveable_space(i,j))
document.write( "<a href='jav * ascript:clicked(" +i+ "," +j+ ")'>" );
document.write( "<img data-lazyload class='lazyload' src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-src='" );
if (board[i][j]== 1 ) document.write( "you1.gif" );
else if (board[i][j]==- 1 ) document.write( "me1.gif" );
else if (moveable_space(i,j)) document.write( "gray.gif" );
else document.write( "black.gif" );
document.write( "' width=" +square_dim+ " height=" +square_dim
+ " name='space" +i+ "" +j+ "' border=0>" );
if (moveable_space(i,j)) document.write( "</a>" );}
document.write( "<img data-lazyload class='lazyload' src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-src='black.gif' width=4 height=" +square_dim+ "></td></tr>" );}
document.write( "<tr><td><img data-lazyload class='lazyload' src='data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' data-src='black.gif' width=" +(square_dim* 8 + 8 )+ " height=4><br></td></tr></table><br>" + "<fo rm name='disp'><input type=text readonly style='border-style:solid; border-width:0;' size=40 name='message' value=''><br><br><input type=button value=\" Новая игра \" onCl ick=\"location.href+=''\" st yle=\"font-weight: bold\"></form>" );
function clicked (i,j) {
if (my_turn) {
if (integ(board[i][j])== 1 ) toggle(i,j);
else if (piece_toggled) move(selected,coord(i,j));
else message( ":)" );
} else { message( ":)!" );}}
function toggle (x,y) {
if (my_turn) {
if (piece_toggled)
draw(selected.x,selected.y, "you1" +((board[selected.x][selected.y]== 1.1 )? "k" : "" )+ ".gif" );
if (piece_toggled && (selected.x == x) && (selected.y == y)) {
piece_toggled = false ;
if (double_jump) { my_turn = double_jump = false ; computer(); } } else {
piece_toggled = true ;
draw(x,y, "you2" +((board[x][y]== 1.1 )? "k" : "" )+ ".gif" );}
selected = coord(x,y); } else {
if ((piece_toggled) && (integ(board[selected_c.x][selected_c.y])==- 1 ))
draw(selected_c.x,selected_c.y, "me1" +((board[selected_c.x][selected_c.y]==- 1.1 )? "k" : "" )+ ".gif" );
if (piece_toggled && (selected_c.x == x) && (selected_c.y == y)) {
piece_toggled = false ; } else {
piece_toggled = true ;
draw(x,y, "me2" +((board[x][y]==- 1.1 )? "k" : "" )+ ".gif" );}
selected_c = coord(x,y);}}
function draw (x,y,name) {
document.images[ "space" +x+ "" +y].src = name;}
function integ (num) {
if (num != null )
return Math.round(num);
else
return null ;}
function abs (num) {
return Math.abs(num);}
function sign (num) {
if (num < 0 ) return - 1 ;
else return 1 ;}
function concatenate (arr1,arr2) {
for ( var i= 0 ;i<arr2.length;i++)
arr1[arr1.length+i] = arr2[i];
return arr1;}
function legal_move (from,to) {
if ((to.x < 0 ) || (to.y < 0 ) || (to.x > 7 ) || (to.y > 7 )) return false ;
piece = board[from.x][from.y];
distance = coord(to.x-from.x,to.y-from.y);
if ((distance.x == 0 ) || (distance.y == 0 )) {
message( "Шашки двигаются только по диагонали!" );
return false ;}
if (abs(distance.x) != abs(distance.y)) {
message( "Так нельзя..." );
return false ;}
if (abs(distance.x) > 2 ) {
message( "Так нельзя..." );
return false ;}
if ((abs(distance.x) == 1 ) && double_jump) {
return false ;}
if ((board[to.x][to.y] != 0 ) || (piece == 0 )) {
return false ;}
if ((abs(distance.x) == 2 )
&& (integ(piece) != -integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
return false ;}
if ((integ(piece) == piece) && (sign(piece) != sign(distance.y))) {
return false ;}
return true ;}
function move (from,to) {
my_turn = true ;
if (legal_move(from,to)) {
piece = board[from.x][from.y];
distance = coord(to.x-from.x,to.y-from.y);
if ((abs(distance.x) == 1 ) && (board[to.x][to.y] == 0 )) {
swap(from,to);
} else if ((abs(distance.x) == 2 )
&& (integ(piece) != integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
double_jump = false ;
swap(from,to);
remove(from.x+sign(distance.x),from.y+sign(distance.y));
if ((legal_move(to,coord(to.x+ 2 ,to.y+ 2 )))
| (legal_move(to,coord(to.x+ 2 ,to.y- 2 )))
| (legal_move(to,coord(to.x- 2 ,to.y- 2 )))
| (legal_move(to,coord(to.x- 2 ,to.y+ 2 )))) {
double_jump = true ;
message( "You may complete the double jump or click on your piece to stay still." );}}
if ((board[to.x][to.y] == 1 ) && (to.y == 7 )) king_me(to.x,to.y);
selected = to;
if (game_over() && !double_jump) {
setTimeout( "toggle(" +to.x+ "," +to.y+ ");my_turn = double_jump = false;computer();" , 1000 );}}
return true ;}
function king_me (x,y) {
if (board[x][y] == 1 ) {
board[x][y] = 1.1 ;
draw(x,y, "you2k.gif" );
} else if (board[x][y] == - 1 ) {
board[x][y] = - 1.1 ;
draw(x,y, "me2k.gif" );}}
function swap (from,to) {
if (my_turn || comp_move) {
dummy_src = document.images[ "space" +to.x+ "" +to.y].src;
document.images[ "space" +to.x+ "" +to.y].src = document.images[ "space" +from.x+ "" +from.y].src;
document.images[ "space" +from.x+ "" +from.y].src = dummy_src;}
dummy_num = board[from.x][from.y];
board[from.x][from.y] = board[to.x][to.y];
board[to.x][to.y] = dummy_num;}
function remove (x,y) {
if (my_turn || comp_move)
draw(x,y, "gray.gif" );
board[x][y] = 0 ;}
function Result (val) {
this.high = val;
this.dir = new Array ();}
function move_comp (from,to) {
toggle(from.x,from.y);
comp_move = true ;
swap(from,to);
if (abs(from.x-to.x) == 2 ) {
remove(from.x+sign(to.x-from.x),from.y+sign(to.y-from.y));}
if ((board[to.x][to.y] == - 1 ) && (to.y == 0 )) king_me(to.x,to.y);
setTimeout( "selected_c = coord(" +to.x+ "," +to.y+ ");piece_toggled = true;" , 900 );
setTimeout( "bak=my_turn;my_turn=false;toggle(" +to.x+ "," +to.y+ ");my_turn=bak;" , 1000 );
if (game_over()) {
setTimeout( "comp_move = false;my_turn = true;togglers=0;" , 600 );
message( ":)" );}
return true ;}
function game_over () {
comp = you = false ;
for ( var i= 0 ;i< 8 ;i++) {
for ( var j= 0 ;j< 8 ;j++) {
if (integ(board[i][j]) == - 1 ) comp = true ;
if (integ(board[i][j]) == 1 ) you = true ;}}
if (!comp) message( "Вы у меня выигрываете!" );
if (!you) message( "Вы проиграли!" );
game_is_over = (!comp || !you)
return (!game_is_over);}
var jump_priority = 10 ;
function computer () {
for ( var j= 0 ;j< 8 ;j++) {
for ( var i= 0 ;i< 8 ;i++) {
if (integ(board[i][j]) == 1 ) {
if ((legal_move(coord(i,j),coord(i+ 2 ,j+ 2 ))) && (prevent(coord(i+ 2 ,j+ 2 ),coord(i+ 1 ,j+ 1 )))) {
return true ;
} if ((legal_move(coord(i,j),coord(i- 2 ,j+ 2 ))) && (prevent(coord(i- 2 ,j+ 2 ),coord(i- 1 ,j+ 1 )))) {
return true ;}
} if (board[i][j] == 1.1 ) {
if ((legal_move(coord(i,j),coord(i- 2 ,j- 2 ))) && (prevent(coord(i- 2 ,j- 2 ),coord(i- 1 ,j- 1 )))) {
return true ;
} if ((legal_move(coord(i,j),coord(i+ 2 ,j- 2 ))) && (prevent(coord(i+ 2 ,j- 2 ),coord(i+ 1 ,j- 1 )))) {
return true ;}}}}
for ( var j= 7 ;j>= 0 ;j--) {
for ( var i= 0 ;i< 8 ;i++) {
if (jump(i,j))
return true ;}}
safe_from = null ;
for ( var j= 0 ;j< 8 ;j++) {
for ( var i= 0 ;i< 8 ;i++) {
if (single(i,j))
return true ;}}
if (safe_from != null ) {
move_comp(safe_from,safe_to); } else {
message( "Вы выграли! Сыграем еще?" );
game_is_over = true ;}
safe_from = safe_to = null ;
return false ;}
function jump (i,j) {
if (board[i][j] == - 1.1 ) {
if (legal_move(coord(i,j),coord(i+ 2 ,j+ 2 ))) {
move_comp(coord(i,j),coord(i+ 2 ,j+ 2 ));
setTimeout( "jump(" +(i+ 2 )+ "," +(j+ 2 )+ ");" , 500 );
return true ;
} if (legal_move(coord(i,j),coord(i- 2 ,j+ 2 ))) {
move_comp(coord(i,j),coord(i- 2 ,j+ 2 ));
setTimeout( "jump(" +(i- 2 )+ "," +(j+ 2 )+ ");" , 500 );
return true ;}
} if (integ(board[i][j]) == - 1 ) {
if (legal_move(coord(i,j),coord(i- 2 ,j- 2 ))) {
move_comp(coord(i,j),coord(i- 2 ,j- 2 ));
setTimeout( "jump(" +(i- 2 )+ "," +(j- 2 )+ ");" , 500 );
return true ;
} if (legal_move(coord(i,j),coord(i+ 2 ,j- 2 ))) {
move_comp(coord(i,j),coord(i+ 2 ,j- 2 ));
setTimeout( "jump(" +(i+ 2 )+ "," +(j- 2 )+ ");" , 500 );
return true ;}}
return false ;}
function single (i,j) {
if (board[i][j] == - 1.1 ) {
if (legal_move(coord(i,j),coord(i+ 1 ,j+ 1 ))) {
safe_from = coord(i,j);
safe_to = coord(i+ 1 ,j+ 1 );
if (wise(coord(i,j),coord(i+ 1 ,j+ 1 ))) {
move_comp(coord(i,j),coord(i+ 1 ,j+ 1 ));
return true ;}
} if (legal_move(coord(i,j),coord(i- 1 ,j+ 1 ))) {
safe_from = coord(i,j);
safe_to = coord(i- 1 ,j+ 1 );
if (wise(coord(i,j),coord(i- 1 ,j+ 1 ))) {
move_comp(coord(i,j),coord(i- 1 ,j+ 1 ));
return true ;}}
} if (integ(board[i][j]) == - 1 ) {
if (legal_move(coord(i,j),coord(i+ 1 ,j- 1 ))) {
safe_from = coord(i,j);
safe_to = coord(i+ 1 ,j- 1 );
if (wise(coord(i,j),coord(i+ 1 ,j- 1 ))) {
move_comp(coord(i,j),coord(i+ 1 ,j- 1 ));
return true ;}
} if (legal_move(coord(i,j),coord(i- 1 ,j- 1 ))) {
safe_from = coord(i,j);
safe_to = coord(i- 1 ,j- 1 );
if (wise(coord(i,j),coord(i- 1 ,j- 1 ))) {
move_comp(coord(i,j),coord(i- 1 ,j- 1 ));
return true ;}}}
return false ;}
function possibilities (x,y) {
if (!jump(x,y))
if (!single(x,y))
return true ;
else
return false ;
else
return false ;}
function prevent (end,s) {
i = end.x;
j = end.y;
if (!possibilities(s.x,s.y))
return true ;
else if ((integ(board[i- 1 ][j+ 1 ])==- 1 ) && (legal_move(coord(i- 1 ,j+ 1 ),coord(i,j)))) {
return move_comp(coord(i- 1 ,j+ 1 ),coord(i,j));
} else if ((integ(board[i+ 1 ][j+ 1 ])==- 1 ) && (legal_move(coord(i+ 1 ,j+ 1 ),coord(i,j)))) {
return move_comp(coord(i+ 1 ,j+ 1 ),coord(i,j));
} else if ((board[i- 1 ][j- 1 ]==- 1.1 ) && (legal_move(coord(i- 1 ,j- 1 ),coord(i,j)))) {
return move_comp(coord(i- 1 ,j- 1 ),coord(i,j));
} else if ((board[i+ 1 ][j- 1 ]==- 1.1 ) && (legal_move(coord(i+ 1 ,j- 1 ),coord(i,j)))) {
return move_comp(coord(i+ 1 ,j- 1 ),coord(i,j));
} else {
return false ;}}
function wise (from,to) {
i = to.x;
j = to.y;
n = (j> 0 );
s = (j< 7 );
e = (i< 7 );
w = (i> 0 );
if (n&&e) ne = board[i+ 1 ][j- 1 ]; else ne = null ;
if (n&&w) nw = board[i- 1 ][j- 1 ]; else nw = null ;
if (s&&e) se = board[i+ 1 ][j+ 1 ]; else se = null ;
if (s&&w) sw = board[i- 1 ][j+ 1 ]; else sw = null ;
eval (((j-from.y != 1 )? "s" : "n" )+((i-from.x != 1 )? "e" : "w" )+ "=0;" );
if ((sw== 0 ) && (integ(ne)== 1 )) return false ;
if ((se== 0 ) && (integ(nw)== 1 )) return false ;
if ((nw== 0 ) && (se== 1.1 )) return false ;
if ((ne== 0 ) && (sw== 1.1 )) return false ;
return true ;
}
message( "Интернет шашки. Вы играете красными." );
my_turn = true ;
var ie4 = (document.all) ? true : false ; var nn4 = (document.layers) ? true : false ;
</sc ript>
<? require ( $_SERVER [ "DOCUMENT_ROOT" ]. "/bitrix/footer.php" ); ?>
[/CODE]и не забывайте про картинки, на которые ссылается скрипт[/QUOTE]
Да, Вы правы. на данный момент код страницы пхп у меня такой:
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Игры");
?><div style="text-align: center;">
</div>
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
".default",
array(
"AREA_FILE_SHOW" => "file",
"AREA_FILE_SUFFIX" => "inc",
"EDIT_TEMPLATE" => "/shashki/game.html",
"PATH" => "/shashki/game.html",
"COMPONENT_TEMPLATE" => ".default",
"COMPOSITE_FRAME_MODE" => "A",
"COMPOSITE_FRAME_TYPE" => "AUTO",
"AREA_FILE_RECURSIVE" => "Y"
),
false
);?> <br><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
Попробую посмотреть экранирование и синтаксис вывода строк в javascript (ибо я перебробовал разнообразие до безобразия в ТП битриксе сразу писали, что все делаю правильно (то есть вставка данных в пхп страницу и прочее, в итоге мне проще сделать отдельную от сайта страницу (разумеется без хедера и футера). В плане картинок, у меня все просто (ссылаются они в корень папки, в корень сайта также их скину (временно без директории) . И еще удивительная вещь, например если игра шашки не хочет работать, то вот такой код, работает))) по ссылке:[URL=https://bukvaeshka.by/luchshee.php]https://bukvaeshka.by/luchshee.php[/URL], а сам код такой:
<title>Крестики-Нолики</title>
<style>
.tbl, .tbl td {border:1px solid #82817D;}
</style>
<script>
var x = "x.gif";var o = "o.gif";
var blank = "z.gif";var pause = 0;var all = 0;var a = 0;var b = 0;
var c = 0;var d = 0;var e = 0;var f = 0;var g = 0;var h = 0;var i = 0;var temp="";var ok = 0;
var cf = 0;var choice=9;var aRandomNumber = 0;var comp = 0; var t = 0;var wn = 0;var ls = 0;var ts = 0;
function logicOne() {
if ((a==1)&&(b==1)&&(c==1)) all=1;if ((a==1)&&(d==1)&&(g==1)) all=1;if ((a==1)&&(e==1)&&(i==1)) all=1;
if ((b==1)&&(e==1)&&(h==1)) all=1;if ((d==1)&&(e==1)&&(f==1)) all=1;if ((g==1)&&(h==1)&&(i==1)) all=1;
if ((c==1)&&(f==1)&&(i==1)) all=1;if ((g==1)&&(e==1)&&(c==1)) all=1;if ((a==2)&&(b==2)&&(c==2)) all=2;
if ((a==2)&&(d==2)&&(g==2)) all=2;if ((a==2)&&(e==2)&&(i==2)) all=2;if ((b==2)&&(e==2)&&(h==2)) all=2;
if ((d==2)&&(e==2)&&(f==2)) all=2;if ((g==2)&&(h==2)&&(i==2)) all=2;if ((c==2)&&(f==2)&&(i==2)) all=2;
if ((g==2)&&(e==2)&&(c==2)) all=2;
if ((a != 0)&&(b != 0)&&(c != 0)&&(d != 0)&&(e != 0)&&(f != 0)&&(g != 0)&&(h != 0)&&(i != 0)&&(all == 0)) all = 3;}
function logicTwo() {
if ((a==2)&&(b==2)&&(c== 0)&&(temp=="")) temp="C";if ((a==2)&&(b== 0)&&(c==2)&&(temp=="")) temp="B";
if ((a== 0)&&(b==2)&&(c==2)&&(temp=="")) temp="A";if ((a==2)&&(d==2)&&(g== 0)&&(temp=="")) temp="G";
if ((a==2)&&(d== 0)&&(g==2)&&(temp=="")) temp="D";if ((a== 0)&&(d==2)&&(g==2)&&(temp=="")) temp="A";
if ((a==2)&&(e==2)&&(i== 0)&&(temp=="")) temp="I";if ((a==2)&&(e== 0)&&(i==2)&&(temp=="")) temp="E";
if ((a== 0)&&(e==2)&&(i==2)&&(temp=="")) temp="A";if ((b==2)&&(e==2)&&(h== 0)&&(temp=="")) temp="H";
if ((b==2)&&(e== 0)&&(h==2)&&(temp=="")) temp="E";if ((b== 0)&&(e==2)&&(h==2)&&(temp=="")) temp="B";
if ((d==2)&&(e==2)&&(f== 0)&&(temp=="")) temp="F";if ((d==2)&&(e== 0)&&(f==2)&&(temp=="")) temp="E";
if ((d== 0)&&(e==2)&&(f==2)&&(temp=="")) temp="D";if ((g==2)&&(h==2)&&(i== 0)&&(temp=="")) temp="I";
if ((g==2)&&(h== 0)&&(i==2)&&(temp=="")) temp="H";if ((g== 0)&&(h==2)&&(i==2)&&(temp=="")) temp="G";
if ((c==2)&&(f==2)&&(i== 0)&&(temp=="")) temp="I";if ((c==2)&&(f== 0)&&(i==2)&&(temp=="")) temp="F";
if ((c== 0)&&(f==2)&&(i==2)&&(temp=="")) temp="C";if ((g==2)&&(e==2)&&(c== 0)&&(temp=="")) temp="C";
if ((g==2)&&(e== 0)&&(c==2)&&(temp=="")) temp="E";if ((g== 0)&&(e==2)&&(c==2)&&(temp=="")) temp="G";}
<!-- web-mastery.info -->
function logicThree() {
if ((a==1)&&(b==1)&&(c==0)&&(temp=="")) temp="C";if ((a==1)&&(b==0)&&(c==1)&&(temp=="")) temp="B";
if ((a==0)&&(b==1)&&(c==1)&&(temp=="")) temp="A";if ((a==1)&&(d==1)&&(g==0)&&(temp=="")) temp="G";
if ((a==1)&&(d==0)&&(g==1)&&(temp=="")) temp="D";if ((a==0)&&(d==1)&&(g==1)&&(temp=="")) temp="A";
if ((a==1)&&(e==1)&&(i==0)&&(temp=="")) temp="I";if ((a==1)&&(e==0)&&(i==1)&&(temp=="")) temp="E";
if ((a==0)&&(e==1)&&(i==1)&&(temp=="")) temp="A";if ((b==1)&&(e==1)&&(h==0)&&(temp=="")) temp="H";
if ((b==1)&&(e==0)&&(h==1)&&(temp=="")) temp="E";if ((b==0)&&(e==1)&&(h==1)&&(temp=="")) temp="B";
if ((d==1)&&(e==1)&&(f==0)&&(temp=="")) temp="F";if ((d==1)&&(e==0)&&(f==1)&&(temp=="")) temp="E";
if ((d==0)&&(e==1)&&(f==1)&&(temp=="")) temp="D";if ((g==1)&&(h==1)&&(i==0)&&(temp=="")) temp="I";
if ((g==1)&&(h==0)&&(i==1)&&(temp=="")) temp="H";if ((g==0)&&(h==1)&&(i==1)&&(temp=="")) temp="G";
if ((c==1)&&(f==1)&&(i==0)&&(temp=="")) temp="I";if ((c==1)&&(f==0)&&(i==1)&&(temp=="")) temp="F";
if ((c==0)&&(f==1)&&(i==1)&&(temp=="")) temp="C";if ((g==1)&&(e==1)&&(c==0)&&(temp=="")) temp="C";
if ((g==1)&&(e==0)&&(c==1)&&(temp=="")) temp="E";if ((g==0)&&(e==1)&&(c==1)&&(temp=="")) temp="G";}
function clearOut() {
document.game.you.value="0";
document.game.computer.value="0";
document.game.ties.value="0";}
function checkSpace() {
if ((temp=="A")&&(a==0)) {ok=1;if (cf==0) a=1;if (cf==1) a=2;}
if ((temp=="B")&&(b==0)) {ok=1;if (cf==0) b=1;if (cf==1) b=2;}
if ((temp=="C")&&(c==0)) {ok=1;if (cf==0) c=1;if (cf==1) c=2;}
if ((temp=="D")&&(d==0)) {ok=1;if (cf==0) d=1;if (cf==1) d=2;}
if ((temp=="E")&&(e==0)) {ok=1;if (cf==0) e=1;if (cf==1) e=2;}
if ((temp=="F")&&(f==0)) {ok=1;if (cf==0) f=1;if (cf==1) f=2;}
if ((temp=="G")&&(g==0)) {ok=1;if (cf==0) g=1;if (cf==1) g=2;}
if ((temp=="H")&&(h==0)) {ok=1;if (cf==0) h=1;if (cf==1) h=2;}
if ((temp=="I")&&(i==0)) {ok=1;if (cf==0) i=1;if (cf==1) i=2;}}
function yourChoice(chName) {
pause = 0;
if (all!=0) ended();
if (all==0) {
cf = 0;ok = 0;temp=chName;
checkSpace();
if (ok==1) {document.images[chName].src = x;}
if (ok==0)taken();
process();
if ((all==0)&&(pause==0)) myChoice();}}
function taken() {alert("Квадрат уже занят!")
pause=1;}
function myChoice() {
temp="";ok = 0;cf=1;logicTwo();logicThree();checkSpace();
while(ok==0) {
aRandomNumber=Math.random()
comp=Math.round((choice-1)*aRandomNumber)+1;
if (comp==1) temp="A";if (comp==2) temp="B";if (comp==3) temp="C";if (comp==4) temp="D";if (comp==5) temp="E";
if (comp==6) temp="F";if (comp==7) temp="G";if (comp==8) temp="H";if (comp==9) temp="I";
checkSpace();}
document.images[temp].src= o;
process();}
function ended() {alert("Для начала новой игры нажмите кнопку.")}
function process() {
logicOne();
if (all==1){ alert("Вы выиграли! Поздравляем!"); wn++; }
if (all==2){ alert("Вы проиграли."); ls++; }
if (all==3){ alert("Мы сыграли вничью."); ts++; }
if (all!=0) {
document.game.you.value = wn;
document.game.computer.value = ls;
document.game.ties.value = ts;}}
function playAgain() {
if (all==0) {if(confirm("Сейчас произойдет сброс счета и начнется новый тур.")) reset();}
if (all>0) reset();}
function reset() {
all = 0;a = 0;b = 0;c = 0;d = 0;e = 0;f = 0;g = 0;h = 0;i = 0;temp="";ok = 0;cf = 0;choice=9;
aRandomNumber = 0;comp = 0;
document.images.A.src= blank;document.images.B.src= blank;document.images.C.src= blank;
document.images.D.src= blank;document.images.E.src= blank;document.images.F.src= blank;
document.images.G.src= blank;document.images.H.src= blank;document.images.I.src= blank;
if (t==0) { t=2; myChoice(); }
t--;}
<!-- Maximilian Stocker -->
</script> </head>
<body>
<form name=game>
<table class="tbl" align="center"><tr>
<td><a href="jav * ascript:yourChoice('A')"><img src="z.gif" name=A></a></td>
<td><a href="jav * ascript:yourChoice('B')"><img src="z.gif" name=B></a></td>
<td><a href="jav * ascript:yourChoice('C')"><img src="z.gif" name=C></a></td></tr><tr>
<td><a href="jav * ascript:yourChoice('D')"><img src="z.gif" name=D></a></td>
<td><a href="jav * ascript:yourChoice('E')"><img src="z.gif" name=E></a></td>
<td><a href="jav * ascript:yourChoice('F')"><img src="z.gif" name=F></a></td></tr><tr>
<td><a href="jav * ascript:yourChoice('G')"><img src="z.gif" name=G></a></td>
<td><a href="jav * ascript:yourChoice('H')"><img src="z.gif" name=H></a></td>
<td><a href="jav * ascript:yourChoice('I')"><img src="z.gif" name=I></a></td>
</tr></table>
<table class="tbl" align="center"><tr><td> <input type='button' value=" Новая игра " onCl ick="playAgain();"><br> </td>
<td> <input type='text' size='5' name='you'><br>Вы</td><td><input type='text' size='5' name='computer'><br>Комп.</td>
<td> <input type='text' size='5' name='ties'><br>Ничья</td></tr></table></form>