質問編集履歴
2
HTML/CSS/JSのソースコードを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,14 +30,346 @@
|
|
30
30
|
|
31
31
|
### 該当のソースコード
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
長くなってしまいますが全コードを追記させていただきました。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```HTML
|
38
|
+
|
39
|
+
<body>
|
40
|
+
|
41
|
+
<table>
|
42
|
+
|
43
|
+
<thead>
|
44
|
+
|
45
|
+
<tr><th>B</th><th>I</th><th>N</th><th>G</th><th>O</th></tr>
|
46
|
+
|
47
|
+
</thead>
|
48
|
+
|
49
|
+
<tbody>
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
</tbody>
|
54
|
+
|
55
|
+
</table>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<div id="refresh">カードをシャッフル</div>
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<div id="lock">カードを決定する</div>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<script src="js/main.js">
|
68
|
+
|
69
|
+
</script>
|
70
|
+
|
71
|
+
</body>
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```CSS
|
78
|
+
|
79
|
+
body {
|
80
|
+
|
81
|
+
font-family: 'Courier New' , monospace;
|
82
|
+
|
83
|
+
user-select: none;
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
table {
|
90
|
+
|
91
|
+
margin: 15px auto;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
th, td {
|
98
|
+
|
99
|
+
width: 60px;
|
100
|
+
|
101
|
+
height: 60px;
|
102
|
+
|
103
|
+
text-align: center;
|
104
|
+
|
105
|
+
line-height: 60px;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
th {
|
110
|
+
|
111
|
+
font-size: 24px;
|
112
|
+
|
113
|
+
font-weight: bold;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
td {
|
118
|
+
|
119
|
+
background-color: orange;
|
120
|
+
|
121
|
+
border: 2px solid orange;
|
122
|
+
|
123
|
+
border-radius: 5px;
|
124
|
+
|
125
|
+
cursor: pointer;
|
126
|
+
|
127
|
+
transition: 0.5s;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
.opened {
|
134
|
+
|
135
|
+
background-color: white;
|
136
|
+
|
137
|
+
border-radius: 50%;
|
138
|
+
|
139
|
+
transform: rotateX(360deg);
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
#refresh {
|
146
|
+
|
147
|
+
height: 40px;
|
148
|
+
|
149
|
+
width: 200px;
|
150
|
+
|
151
|
+
background-color: lightsalmon;
|
152
|
+
|
153
|
+
border-radius: 10px;
|
154
|
+
|
155
|
+
box-shadow: 0 5px salmon;
|
156
|
+
|
157
|
+
margin: 40px auto;
|
158
|
+
|
159
|
+
text-align: center;
|
160
|
+
|
161
|
+
line-height: 40px;
|
162
|
+
|
163
|
+
cursor: pointer;
|
164
|
+
|
165
|
+
user-select: none;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
#refresh:hover {
|
170
|
+
|
171
|
+
opacity: 0.8;
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
#refresh:active {
|
176
|
+
|
177
|
+
transform: translate(0, 5px);
|
178
|
+
|
179
|
+
box-shadow: none;
|
180
|
+
|
181
|
+
opacity: 1;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
#lock {
|
188
|
+
|
189
|
+
height: 40px;
|
190
|
+
|
191
|
+
width: 200px;
|
192
|
+
|
193
|
+
background-color: lightgreen;
|
194
|
+
|
195
|
+
border-radius: 10px;
|
196
|
+
|
197
|
+
margin: 20px auto;
|
198
|
+
|
199
|
+
text-align: center;
|
200
|
+
|
201
|
+
line-height: 40px;
|
202
|
+
|
203
|
+
cursor: pointer;
|
204
|
+
|
205
|
+
user-select: none;
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
.inactive {
|
212
|
+
|
213
|
+
opacity: 0.5 !important;
|
214
|
+
|
215
|
+
background-color: #777 !important;
|
216
|
+
|
217
|
+
box-shadow: 0 5px #444 !important;
|
218
|
+
|
219
|
+
pointer-events: none !important;
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
.active {
|
226
|
+
|
227
|
+
background-color: green !important;
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
```
|
36
232
|
|
37
233
|
|
38
234
|
|
39
235
|
```JavaScript
|
40
236
|
|
237
|
+
'use strict';
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
function createColumn(col) {
|
244
|
+
|
245
|
+
const source = [];
|
246
|
+
|
247
|
+
for (let i = 0; i < 15; i++){
|
248
|
+
|
249
|
+
source[i] = i + 1 + 15 * col;
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
const column = [];
|
256
|
+
|
257
|
+
for (let i = 0; i < 5; i++){
|
258
|
+
|
259
|
+
column[i] = source.splice (Math.floor(Math.random() * source.length), 1)[0];
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
return column;
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
function createColumns(){
|
272
|
+
|
273
|
+
const columns = [];
|
274
|
+
|
275
|
+
for (let i = 0; i < 5; i++){
|
276
|
+
|
277
|
+
columns[i] = createColumn(i);
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
columns[2][2] = 'FREE';
|
284
|
+
|
285
|
+
return columns;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
function renderBingo(columns){
|
292
|
+
|
293
|
+
const tbody = document.querySelector('tbody')
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
while(tbody.firstChild) {
|
298
|
+
|
299
|
+
tbody.removeChild(tbody.firstChild);
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
for (let row = 0; row < 5; row++){
|
306
|
+
|
307
|
+
const tr = document.createElement('tr');
|
308
|
+
|
309
|
+
for (let col = 0; col < 5; col++){
|
310
|
+
|
311
|
+
const td = document.createElement('td');
|
312
|
+
|
313
|
+
td.textContent = columns[col][row];
|
314
|
+
|
315
|
+
tr.appendChild(td);
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
document.querySelector('tbody').appendChild(tr);
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
const columns = createColumns();
|
328
|
+
|
329
|
+
renderBingo(columns);
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
const refresh = document.getElementById('refresh');
|
336
|
+
|
337
|
+
const lock = document.getElementById('lock');
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
refresh.addEventListener('click', () => {
|
342
|
+
|
343
|
+
const columns = createColumns();
|
344
|
+
|
345
|
+
renderBingo(columns);
|
346
|
+
|
347
|
+
});
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
lock.addEventListener('click', () => {
|
352
|
+
|
353
|
+
refresh.classList.toggle('inactive');
|
354
|
+
|
355
|
+
lock.classList.toggle('active');
|
356
|
+
|
357
|
+
if(lock.classList.contains('active') === true){
|
358
|
+
|
359
|
+
lock.textContent = 'カードを変更する';
|
360
|
+
|
361
|
+
}else{
|
362
|
+
|
363
|
+
lock.textContent = 'カードを決定する';
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
});
|
370
|
+
|
371
|
+
|
372
|
+
|
41
373
|
const td = document.querySelectorAll('td');
|
42
374
|
|
43
375
|
|
@@ -52,6 +384,8 @@
|
|
52
384
|
|
53
385
|
}
|
54
386
|
|
387
|
+
}
|
388
|
+
|
55
389
|
```
|
56
390
|
|
57
391
|
|
1
初心者マークを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -70,4 +70,4 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
プログラミング学習を初めて2ヶ月ほどの初心者で無知ではありますが、よろしくお願い
|
73
|
+
プログラミング学習を初めて2ヶ月ほどの初心者で無知ではありますが、よろしくお願い致します。
|