-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
235 lines (204 loc) · 11.2 KB
/
game.html
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en" class="h-100" data-bs-theme="auto">
<head>
<title>Math Games</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Maksym Ivanov>">
<link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
<link rel="manifest" href="favicon/site.webmanifest">
<link rel="stylesheet" href="assets/bootstrap.min.css">
<style>
h1 {
font-size: 3em;
}
.form-control {
font-size: 2.5em;
}
.btn.btn-text-size {
font-size: 1.5em;
}
.alert {
font-size: 1.5em;
}
.result-block {
height: 50px;
}
.btn.bd-teal-500 {
background-color: #20c997;
border-color: transparent;
}
.btn.bd-blue-300 {
background-color: #6ea8fe;
border-color: transparent;
}
.btn-close.size {
font-size: 1.2em;
}
#table-result-id {
font-size: 1.5em;
}
.modal-body.no-zoom {
touch-action: manipulation
}
.item-value-one {
display: inline-block;
width: 27px;
margin-right: 15px;
}
.item-value-two {
display: inline-block;
width: 25px;
margin-right: 5px;
}
.item-equal {
margin-right: 15px;
}
.item-result {
}
</style>
</head>
<body class="d-flex h-100 text-center text-bg-dark">
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
<header class="mb-auto">
<!-- <div>-->
<!-- <nav class="nav nav-masthead justify-content-center">-->
<!-- <a href="/" type="button" class="btn btn-lg btn-light mx-1">Повернутись</a>-->
<!-- </nav>-->
<!-- </div>-->
</header>
<main class="px-md-3">
<div class="modal modal-sheet position-static d-block p-md-4 py-md-5 text-body" tabindex="-1" role="dialog" id="modalTour">
<div class="modal-dialog" role="document">
<div class="modal-content rounded-4 shadow">
<div class="modal-body p-md-5 no-zoom">
<div class="d-flex justify-content-between mb-3">
<label for="value-id" id="task-label-id">Завдання<span id="counter-id"></span></label>
<a href="/" type="button" class="btn-close size"></a>
</div>
<div class="mb-4 result-block">
<div id="result-success-id" class="alert alert-success p-1" role="alert" style="display: none;">
😀 Вірно!
</div>
<div id="result-warning-id" class="alert alert-warning p-1" role="alert" style="display: none;">
😕 Не вірно
</div>
<a id="back-id" href="/" type="button" class="btn btn-text-size btn-primary w-100 result" style="display: none;">Повернутись</a>
</div>
<h1 class="mb-4"><span id="task-id"></span><span id="result-value-id">?</span> </h1>
<div id="value-block-id" class="mb-3">
<input id="value-id" type="number" class="form-control rounded-3 text-center" data-result="" max="99" readonly>
</div>
<table id="table-result-id" class="table my-3">
<tbody>
<tr class="fw-bold">
<td class="text-success">Вірно</td>
<td class="text-warning">Не вірно</td>
</tr>
<tr class="fw-bold">
<td id="table-result-value-correct-id" class="text-success"></td>
<td id="table-result-value-wrong-id" class="text-warning"></td>
</tr>
</tbody>
</table>
<div class="container text-center mt-3">
<div class="row" id="keyboard-id">
<div class="col d-grid row-gap-2 ps-0">
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="1">1</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="4">4</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="7">7</button>
<button id="backspace-id" type="button" class="btn btn-light w-100 result">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-backspace" viewBox="0 0 16 16">
<path d="M5.83 5.146a.5.5 0 0 0 0 .708L7.975 8l-2.147 2.146a.5.5 0 0 0 .707.708l2.147-2.147 2.146 2.147a.5.5 0 0 0 .707-.708L9.39 8l2.146-2.146a.5.5 0 0 0-.707-.708L8.683 7.293 6.536 5.146a.5.5 0 0 0-.707 0z"/>
<path d="M13.683 1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-7.08a2 2 0 0 1-1.519-.698L.241 8.65a1 1 0 0 1 0-1.302L5.084 1.7A2 2 0 0 1 6.603 1zm-7.08 1a1 1 0 0 0-.76.35L1 8l4.844 5.65a1 1 0 0 0 .759.35h7.08a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1z"/>
</svg>
</button>
</div>
<div class="col d-grid row-gap-2">
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="2">2</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="5">5</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="8">8</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="0">0</button>
</div>
<div class="col d-grid row-gap-2 pe-0">
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="3">3</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="6">6</button>
<button type="button" class="btn btn-primary fw-bolder bd-blue-300 number" data-value="9">9</button>
<button id="result-id" type="button" class="btn btn-success w-100 bd-teal-500">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-check-lg" viewBox="0 0 16 16">
<path d="M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425z"/>
</svg>
</button>
<button id="next-id" type="button" class="btn btn-success w-100" style="display: none;">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/>
</svg>
</button>
</div>
</div>
</div>
<div class="container my-1" id="result-table-id" style="display: none">
<div class="row mb-0">
<div id="result-expression-id" class="col text-end pe-0">
</div>
<div id="result-answer-id" class="col text-start ps-2">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<footer class="mt-auto text-white-50">
</footer>
</div>
<script src="assets/bootstrap.min.js?v=1.2"></script>
<script src="assets/jquery.min.js?v=1.2"></script>
<script src="assets/tasks.js?v=1.2"></script>
<script>
urlParams = new URLSearchParams(window.location.search);
let action = urlParams.get('action');
let type = urlParams.get('type');
let tasks = [];
let shuffle = true;
if ('sum' === action) {
if ('one' === type) {
tasks = new Sum(1, 10, null).listAll();
} else if ('two' === type) {
tasks = new Sum(10, 99, 100).listAll();
} else if ('two-simple' === type) {
tasks = new Sum(10, 99, 100).listAllSimple();
} else {
tasks = new Sum(parseInt(type), 10, null).listAllSingle();
shuffle = 'true' === urlParams.get('shuffle');
}
} else if ('sub' === action) {
if ('one' === type) {
tasks = new Sub(1, 10, null).listAll();
} else if ('two' === type) {
tasks = new Sub(10, 99, 100).listAll();
} else if ('two-simple' === type) {
tasks = new Sub(10, 99, 100).listAllSimple();
}else {
tasks = new Sub(parseInt(type), 10, null).listAllSingle();
shuffle = 'true' === urlParams.get('shuffle');
}
} else if ('multiply' === action) {
if ('one' === type) {
tasks = new Multiply(1, 10, null).listAll();
} else {
tasks = new Multiply(parseInt(type), 10, null).listAllSingle();
shuffle = 'true' === urlParams.get('shuffle');
}
}
let game = new Game();
game.init();
game.addTasks(tasks);
game.start(shuffle);
</script>
</body>
</html>