1
1
< html >
2
2
< head >
3
3
< title > Tic-Tac-Toe</ title >
4
+ < link rel ="stylesheet " href ="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css " integrity ="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk " crossorigin ="anonymous ">
4
5
< style >
5
6
* {
6
- font-family : 'Segoe UI' , Tahoma, Geneva, Verdana, sans-serif;
7
+ font-family : monospace;
8
+ }
9
+ body {
10
+ margin : 10px ;
7
11
}
8
12
.center {
9
13
text-align : center;
19
23
width : 100px ;
20
24
height : 100px ;
21
25
padding : 15px ;
26
+ border : 1px solid black;
22
27
}
23
28
.restart-button {
24
29
margin-bottom : 5px ;
25
30
}
26
31
</ style >
27
32
</ head >
28
33
< body onload ="init() ">
29
- < div class ="center ">
30
- < h1 > Tic-Tac-Toe!</ h1 >
31
- </ div >
32
- < div class ="center ">
33
- < button id ="restart-button " class ="restart-button " onclick ="restart() "> restart</ button >
34
+ < div class ="jumbotron jumbotron-fluid ">
35
+ < div class ="container ">
36
+ < h1 class ="display-4 "> Tic-Tac-Toe!</ h1 >
37
+ < p class ="lead ">
38
+ Classic Tic-Tac-Toe game; play against the computer
39
+ </ p >
40
+ < hr class ="my-4 ">
41
+ < p >
42
+ Hit restart at any time to start over
43
+ </ p >
44
+ < button id ="restart-button " type ="button " class ="btn btn-primary " onclick ="restart() "> restart</ button >
45
+ </ div >
34
46
</ div >
35
47
< table class ="ttt-table ">
36
48
< tbody >
@@ -51,9 +63,8 @@ <h1>Tic-Tac-Toe!</h1>
51
63
</ tr >
52
64
</ tbody >
53
65
</ table >
54
- < div id ="result " class ="center ">
55
-
56
- </ div >
66
+ < br />
67
+ < div id ="result " class ="alert alert-primary " role ="alert " style ="display: none; "> </ div >
57
68
58
69
< audio id ="clicked ">
59
70
< source src ="audio/fairy.mp3 " type ="audio/mp3 ">
@@ -114,6 +125,7 @@ <h1>Tic-Tac-Toe!</h1>
114
125
if ( isGridFull ( ) ) {
115
126
gameOver = true ;
116
127
result . innerHTML = `Draw!` ;
128
+ result . style . display = 'block' ;
117
129
} else {
118
130
function doTimer ( ) {
119
131
const position = getComputerPosition ( ) ;
@@ -128,6 +140,7 @@ <h1>Tic-Tac-Toe!</h1>
128
140
if ( winner !== 'none' ) {
129
141
gameOver = true ;
130
142
result . innerHTML = `${ winner } Win!` ;
143
+ result . style . display = 'block' ;
131
144
}
132
145
133
146
clearInterval ( timer ) ;
@@ -140,6 +153,7 @@ <h1>Tic-Tac-Toe!</h1>
140
153
} else {
141
154
gameOver = true ;
142
155
result . innerHTML = `${ winner } Win!` ;
156
+ result . style . display = 'block' ;
143
157
}
144
158
}
145
159
@@ -162,6 +176,7 @@ <h1>Tic-Tac-Toe!</h1>
162
176
function restart ( ) {
163
177
const result = document . getElementById ( 'result' ) ;
164
178
result . innerHTML = '' ;
179
+ result . style . display = 'none' ;
165
180
166
181
gameOver = false ;
167
182
clearTable ( ) ;
0 commit comments