-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
169 lines (157 loc) · 6.86 KB
/
Copy pathindex.html
File metadata and controls
169 lines (157 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic meta tags for character encoding and responsive viewport -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XOXO.array</title>
<!-- Link to external stylesheet and favicon -->
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 4h4v4H4V4zm6 0h4v4h-4V4zm6 0h4v4h-4V4zM4 10h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4zM4 16h4v4H4v-4zm6 0h4v4h-4V4zm6 0h4v4h-4V4z'/></svg>" type="image/svg+xml">
</head>
<body>
<!-- Main container for the game layout -->
<div class="container">
<!-- Left side: Title, Scoreboard, and Game Stats -->
<div class="left-panel">
<!-- Game title -->
<div class="title-container">
<h1>TIC-TAC-TOE</h1>
<p class="subtitle">Powered by Arrays</p>
</div>
<!-- Scoreboard section -->
<div class="score-board">
<h2 class="score-title">SCOREBOARD</h2>
<div class="score-container">
<div class="score x-score">X: <span id="x-score">0</span></div>
<div class="score o-score">O: <span id="o-score">0</span></div>
</div>
</div>
<!-- Game status information -->
<div class="game-status">
<div class="game-info">
<div id="current-player">Current Player: X</div>
<div id="timer">Time: 00:00:00</div>
<div id="moves">Moves: 0</div>
</div>
</div>
</div>
<!-- Center: Main game area -->
<div class="game-area">
<!-- Game board grid (3x3) -->
<div class="game-board">
<!-- First row -->
<div class="board-row">
<button class="cell" data-index="0"></button>
<button class="cell" data-index="1"></button>
<button class="cell" data-index="2"></button>
</div>
<!-- Second row -->
<div class="board-row">
<button class="cell" data-index="3"></button>
<button class="cell" data-index="4"></button>
<button class="cell" data-index="5"></button>
</div>
<!-- Third row -->
<div class="board-row">
<button class="cell" data-index="6"></button>
<button class="cell" data-index="7"></button>
<button class="cell" data-index="8"></button>
</div>
</div>
<!-- Game control buttons -->
<div class="game-controls">
<div class="control-buttons">
<button id="new-game" class="control-btn">New Game</button>
<button id="undo-move" class="control-btn" disabled>Undo</button>
<button id="reset-stats" class="control-btn" disabled>Reset</button>
</div>
</div>
</div>
<!-- Right side: Side panel with game information -->
<div class="side-panel">
<!-- Player name input fields -->
<div class="player-names">
<div class="player-input">
<label for="player-x">Player X:</label>
<input type="text" id="player-x" placeholder="Enter name">
</div>
<div class="player-input">
<label for="player-o">Player O:</label>
<input type="text" id="player-o" placeholder="Enter name">
</div>
</div>
<!-- Move history section -->
<div class="move-history">
<h2>Move History</h2>
<div id="history-text" class="history-container"></div>
</div>
<!-- Game mode toggles -->
<div class="game-mode">
<!-- Single player mode toggle -->
<div class="mode-switch">
<label class="switch">
<input type="checkbox" id="single-player-mode">
<span class="slider"></span>
</label>
<span>Single Player Mode</span>
</div>
<!-- Dark mode toggle -->
<div class="mode-switch">
<label class="switch">
<input type="checkbox" id="theme-toggle">
<span class="slider"></span>
</label>
<span>Dark Mode</span>
</div>
</div>
</div>
</div>
<!-- JavaScript files -->
<script src="game.js"></script>
<!-- Theme detection and initialization script -->
<script>
// Theme detection and initialization
const themeToggle = document.getElementById('theme-toggle');
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
// Function to update theme based on dark mode preference
function updateTheme(isDark) {
if (isDark) {
document.documentElement.setAttribute('data-theme', 'dark');
} else {
document.documentElement.removeAttribute('data-theme');
}
themeToggle.checked = isDark;
localStorage.setItem('theme', isDark ? 'dark' : 'light');
}
// Initialize theme based on system preference or saved preference
function initializeTheme() {
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
updateTheme(savedTheme === 'dark');
} else {
updateTheme(prefersDarkScheme.matches);
}
}
// Listen for system theme changes
prefersDarkScheme.addListener((e) => {
if (!localStorage.getItem('theme')) {
updateTheme(e.matches);
}
});
// Listen for manual theme toggle
themeToggle.addEventListener('change', () => {
updateTheme(themeToggle.checked);
});
// Initialize theme on page load
document.addEventListener('DOMContentLoaded', initializeTheme);
initializeTheme();
// Update favicon based on current theme
function updateFavicon() {
const favicon = document.querySelector("link[rel='icon']");
favicon.href = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%236C5CE7' d='M4 4h4v4H4V4zm6 0h4v4h-4V4zm6 0h4v4h-4V4zM4 10h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4zM4 16h4v4H4v-4zm6 0h4v4h-4V4zm6 0h4v4h-4V4z'/></svg>";
}
updateFavicon();
</script>
</body>
</html>