質問編集履歴
3
HTML脱字の修正 </tr>
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,22 +1,402 @@
|
|
1
|
+
初学者です。
|
2
|
+
|
3
|
+
javaScriptで会社の自動シフト作成表を作ってます。
|
4
|
+
|
5
|
+
カレンダーの次月と前月をクリックしたら前のカレンダーが残った状態なってしまいます。
|
6
|
+
|
7
|
+
前のカレンダーの表示を削除した上で次月、前月を表示したいです。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
### 発生している問題・エラーメッセージ
|
12
|
+
|
13
|
+
function clearCalender() { //前のカレンダーを削除
|
14
|
+
|
15
|
+
const table = document.querySelector('.table1');
|
16
|
+
|
17
|
+
while (table.firstChild) {
|
18
|
+
|
19
|
+
table.removeChild(table.firstChild);
|
20
|
+
|
21
|
+
}
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
を使っても上手くいかず、最初に削除されてしまいます。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
エラーメッセージ
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
### 該当のソースコード
|
38
|
+
|
39
|
+
```ここに言語を入力
|
40
|
+
|
1
41
|
コード
|
2
42
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
43
|
+
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
--CSS--
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
body {
|
52
|
+
|
53
|
+
margin: 0;
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
.container {
|
60
|
+
|
61
|
+
display: flex;
|
62
|
+
|
63
|
+
justify-content: center;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
.table1 {
|
70
|
+
|
71
|
+
width: 80%;
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
.thisMonth {
|
78
|
+
|
79
|
+
text-align: center;
|
80
|
+
|
81
|
+
margin: 40px auto;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
.sat {
|
88
|
+
|
89
|
+
background-color: skyblue;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
.sun {
|
96
|
+
|
97
|
+
background-color: tomato;
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
#prev,
|
104
|
+
|
105
|
+
#next {
|
106
|
+
|
107
|
+
display: block;
|
108
|
+
|
109
|
+
margin: auto;
|
110
|
+
|
111
|
+
cursor: pointer;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
.heading {
|
118
|
+
|
119
|
+
display: flex;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
.header {
|
126
|
+
|
127
|
+
font-weight: bold;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
.btn {
|
134
|
+
|
135
|
+
margin-left: 150px;
|
136
|
+
|
137
|
+
margin-bottom: 20px;
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
table,
|
144
|
+
|
145
|
+
th,
|
146
|
+
|
147
|
+
tr,
|
148
|
+
|
149
|
+
td {
|
150
|
+
|
151
|
+
border-collapse: collapse;
|
152
|
+
|
153
|
+
border: 2px solid #333;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
td {
|
160
|
+
|
161
|
+
width: 53px;
|
162
|
+
|
163
|
+
height: 28px;
|
164
|
+
|
165
|
+
text-align: center;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
#run {
|
172
|
+
|
173
|
+
cursor: pointer;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
#run:hover {
|
180
|
+
|
181
|
+
opacity: 0.5;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
tbody tr td {
|
188
|
+
|
189
|
+
cursor: pointer;
|
190
|
+
|
191
|
+
user-select: none;
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
--HTML--
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<!DOCTYPE html>
|
202
|
+
|
203
|
+
<html lang="ja">
|
204
|
+
|
205
|
+
<head>
|
206
|
+
|
207
|
+
<meta charset="UTF-8">
|
208
|
+
|
209
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
210
|
+
|
211
|
+
<title>Shift Creation</title>
|
212
|
+
|
213
|
+
<link rel="stylesheet" href="css/styles.css">
|
214
|
+
|
215
|
+
</head>
|
216
|
+
|
217
|
+
<body>
|
218
|
+
|
219
|
+
<div class="heading">
|
220
|
+
|
221
|
+
<span id="prev">«</span>
|
222
|
+
|
223
|
+
<h3 id="title" class="thisMonth"></h3>
|
224
|
+
|
225
|
+
<span id="next">»</span>
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
<button id="run" class="btn">RUN</button>
|
230
|
+
|
231
|
+
<div class="container" id="_container">
|
232
|
+
|
233
|
+
<table class="table1">
|
234
|
+
|
235
|
+
<thead>
|
236
|
+
|
237
|
+
<tr id="calender">
|
238
|
+
|
239
|
+
<th rowspan="2">root</th>
|
240
|
+
|
241
|
+
<th rowspan="2">name</th>
|
242
|
+
|
243
|
+
</tr>
|
244
|
+
|
245
|
+
<tr id="week"></tr>
|
246
|
+
|
247
|
+
</thead>
|
248
|
+
|
249
|
+
<tbody id="tbody1">
|
250
|
+
|
251
|
+
<tr id="row0">
|
252
|
+
|
253
|
+
<th>2009</th>
|
254
|
+
|
255
|
+
<th>yu-ki</th>
|
256
|
+
|
257
|
+
</tr>
|
258
|
+
|
259
|
+
<tr id="row1">
|
260
|
+
|
261
|
+
<th>2010</th>
|
262
|
+
|
263
|
+
<th>aya</th>
|
264
|
+
|
265
|
+
</tr>
|
266
|
+
|
267
|
+
<tr id="row2">
|
268
|
+
|
269
|
+
<th>2011</th>
|
270
|
+
|
271
|
+
<th>rino</th>
|
272
|
+
|
273
|
+
</tr>
|
274
|
+
|
275
|
+
<tr id="row3">
|
276
|
+
|
277
|
+
<th>2012</th>
|
278
|
+
|
279
|
+
<th>den</th>
|
280
|
+
|
281
|
+
</tr>
|
282
|
+
|
283
|
+
<tr id="row4">
|
284
|
+
|
285
|
+
<th>2014</th>
|
286
|
+
|
287
|
+
<th>petie</th>
|
288
|
+
|
289
|
+
</tr>
|
290
|
+
|
291
|
+
<tr id="row5">
|
292
|
+
|
293
|
+
<th>STR</th>
|
294
|
+
|
295
|
+
<th>tanaka</th>
|
296
|
+
|
297
|
+
</tr>
|
298
|
+
|
299
|
+
<tr id="row6">
|
300
|
+
|
301
|
+
<th>STR</th>
|
302
|
+
|
303
|
+
<th>yoshida</th>
|
304
|
+
|
305
|
+
</tr>
|
306
|
+
|
307
|
+
</tbody>
|
308
|
+
|
309
|
+
</table>
|
310
|
+
|
311
|
+
<table class="table2">
|
312
|
+
|
313
|
+
<thead>
|
314
|
+
|
315
|
+
<tr>
|
316
|
+
|
317
|
+
<th height="60">P.H</th>
|
318
|
+
|
319
|
+
</tr>
|
320
|
+
|
321
|
+
</thead>
|
322
|
+
|
323
|
+
<tbody id="tbody2">
|
324
|
+
|
325
|
+
<tr id="_row0">
|
326
|
+
|
327
|
+
<td id="phValue0">0</td>
|
328
|
+
|
329
|
+
</tr>
|
330
|
+
|
331
|
+
<tr id="_row1">
|
332
|
+
|
333
|
+
<td id="phValue1">0</td>
|
334
|
+
|
335
|
+
</tr>
|
336
|
+
|
337
|
+
<tr id="_row2">
|
338
|
+
|
339
|
+
<td id="phValue2">0</td>
|
340
|
+
|
341
|
+
</tr>
|
342
|
+
|
343
|
+
<tr id="_row3">
|
344
|
+
|
345
|
+
<td id="phValue3">0</td>
|
346
|
+
|
347
|
+
</tr>
|
348
|
+
|
349
|
+
<tr id="_row4">
|
350
|
+
|
351
|
+
<td id="phValue4">0</td>
|
352
|
+
|
353
|
+
</tr>
|
354
|
+
|
355
|
+
<tr id="_row5">
|
356
|
+
|
357
|
+
<td id="phValue5">0</td>
|
358
|
+
|
359
|
+
</tr>
|
360
|
+
|
361
|
+
<tr id="_row6">
|
362
|
+
|
363
|
+
<td id="phValue6">0</td>
|
364
|
+
|
365
|
+
</tr>
|
366
|
+
|
367
|
+
</tbody>
|
368
|
+
|
369
|
+
</table>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
<script src="js/main.js"></script>
|
374
|
+
|
375
|
+
</body>
|
376
|
+
|
377
|
+
</html>
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
--javaScript--
|
382
|
+
|
383
|
+
'use strict';
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
{
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
const date = new Date();
|
392
|
+
|
393
|
+
let year = date.getFullYear();
|
394
|
+
|
395
|
+
let month = date.getMonth();
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
function clearCalender() { //前のカレンダーを削除
|
20
400
|
|
21
401
|
const table = document.querySelector('.table1');
|
22
402
|
|
@@ -28,614 +408,252 @@
|
|
28
408
|
|
29
409
|
}
|
30
410
|
|
411
|
+
|
412
|
+
|
413
|
+
function renderTitle() {//年月を表示
|
414
|
+
|
415
|
+
const title = document.getElementById('title');
|
416
|
+
|
417
|
+
title.textContent = `${year}/${String(month + 1).padStart(2, '0')}`;
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
function getCalender() { //日数分のセルを生成しtextContentで日付を入れる
|
424
|
+
|
425
|
+
const lastDate = new Date(year, month + 1, 0).getDate();
|
426
|
+
|
427
|
+
for (let i = 1; i <= lastDate; i++) {
|
428
|
+
|
429
|
+
const tdDate = document.createElement('td');
|
430
|
+
|
431
|
+
tdDate.textContent = i;
|
432
|
+
|
433
|
+
document.getElementById('calender').appendChild(tdDate);
|
434
|
+
|
435
|
+
if (new Date(year, month, i).getDay() === 6) {
|
436
|
+
|
437
|
+
tdDate.classList.add('sat');
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
if (new Date(year, month, i).getDay() === 0) {
|
442
|
+
|
443
|
+
tdDate.classList.add('sun');
|
444
|
+
|
445
|
+
}
|
446
|
+
|
447
|
+
};
|
448
|
+
|
449
|
+
}
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
function getWeek() {//当月の曜日を取得しセルを生成
|
454
|
+
|
455
|
+
const lastDate = new Date(year, month + 1, 0).getDate();
|
456
|
+
|
457
|
+
for (let n = 1; n <= lastDate; n++) {
|
458
|
+
|
459
|
+
const tdDay = document.createElement('td');
|
460
|
+
|
461
|
+
let wObj = ["日", "月", "火", "水", "木", "金", "土"][new Date(year, month, n).getDay()];//指定した日付の曜日を文字列で取得
|
462
|
+
|
463
|
+
tdDay.textContent = wObj;
|
464
|
+
|
465
|
+
document.getElementById('week').appendChild(tdDay);
|
466
|
+
|
467
|
+
if (tdDay.textContent==="土") {
|
468
|
+
|
469
|
+
tdDay.classList.add('sat');
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
if (tdDay.textContent==="日") {
|
474
|
+
|
475
|
+
tdDay.classList.add('sun');
|
476
|
+
|
477
|
+
}
|
478
|
+
|
479
|
+
};
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
function addCell(id) {//シフト用のセルを生成
|
486
|
+
|
487
|
+
const lastDate = new Date(year, month + 1, 0).getDate();
|
488
|
+
|
489
|
+
for (let n = 1; n <= lastDate; n++) {
|
490
|
+
|
491
|
+
const td = document.createElement('td');
|
492
|
+
|
493
|
+
td.textContent = '○';
|
494
|
+
|
495
|
+
document.getElementById(id).appendChild(td);
|
496
|
+
|
497
|
+
td.addEventListener('click', () => {
|
498
|
+
|
499
|
+
if (td.textContent==='○') {
|
500
|
+
|
501
|
+
td.textContent = '休';
|
502
|
+
|
503
|
+
} else if (td.textContent==='休') {
|
504
|
+
|
505
|
+
td.textContent = '○';
|
506
|
+
|
507
|
+
};
|
508
|
+
|
509
|
+
});
|
510
|
+
|
511
|
+
};
|
512
|
+
|
513
|
+
}
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
function ph(rowId, phId) {//個人の休みをカウントする
|
518
|
+
|
519
|
+
const row = document.getElementById(rowId);
|
520
|
+
|
521
|
+
const td = row.querySelectorAll('td');
|
522
|
+
|
523
|
+
const phValue = document.getElementById(phId);
|
524
|
+
|
525
|
+
let phCount = 0;
|
526
|
+
|
527
|
+
// console.log(td);
|
528
|
+
|
529
|
+
td.forEach(td => td.addEventListener('click', () => {
|
530
|
+
|
531
|
+
if (td.textContent==='○') {
|
532
|
+
|
533
|
+
phCount--;
|
534
|
+
|
535
|
+
phValue.textContent = phCount;
|
536
|
+
|
537
|
+
} else if (td.textContent==='休') {
|
538
|
+
|
539
|
+
phCount++;
|
540
|
+
|
541
|
+
phValue.textContent = phCount;
|
542
|
+
|
543
|
+
};
|
544
|
+
|
545
|
+
}));
|
546
|
+
|
547
|
+
}
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
function bundling() {
|
554
|
+
|
555
|
+
clearCalender();
|
556
|
+
|
557
|
+
renderTitle();
|
558
|
+
|
559
|
+
getCalender();
|
560
|
+
|
561
|
+
getWeek();
|
562
|
+
|
31
|
-
|
563
|
+
addCell('row0');
|
564
|
+
|
32
|
-
|
565
|
+
addCell('row1');
|
566
|
+
|
33
|
-
|
567
|
+
addCell('row2');
|
568
|
+
|
34
|
-
|
569
|
+
addCell('row3');
|
570
|
+
|
35
|
-
|
571
|
+
addCell('row4');
|
572
|
+
|
36
|
-
|
573
|
+
addCell('row5');
|
574
|
+
|
575
|
+
addCell('row6');
|
576
|
+
|
577
|
+
ph('row0', 'phValue0');
|
578
|
+
|
579
|
+
ph('row1', 'phValue1');
|
580
|
+
|
581
|
+
ph('row2', 'phValue2');
|
582
|
+
|
583
|
+
ph('row3', 'phValue3');
|
584
|
+
|
585
|
+
ph('row4', 'phValue4');
|
586
|
+
|
587
|
+
ph('row5', 'phValue5');
|
588
|
+
|
589
|
+
ph('row6', 'phValue6');
|
590
|
+
|
591
|
+
}
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
document.getElementById('prev').addEventListener('click', () => {
|
604
|
+
|
37
|
-
|
605
|
+
month--;
|
606
|
+
|
607
|
+
if (month < 0) {
|
608
|
+
|
609
|
+
year--;
|
610
|
+
|
611
|
+
month = 11;
|
612
|
+
|
613
|
+
}
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
bundling();
|
618
|
+
|
619
|
+
});
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
document.getElementById('next').addEventListener('click', () => {
|
624
|
+
|
625
|
+
month++;
|
626
|
+
|
627
|
+
if (month > 11) {
|
628
|
+
|
629
|
+
year++;
|
630
|
+
|
631
|
+
month = 0;
|
632
|
+
|
633
|
+
}
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
bundling();
|
638
|
+
|
639
|
+
});
|
640
|
+
|
641
|
+
|
642
|
+
|
643
|
+
bundling();
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
}
|
38
648
|
|
39
649
|
```
|
40
650
|
|
41
651
|
|
42
652
|
|
43
|
-
###
|
653
|
+
### 試したこと
|
44
|
-
|
45
|
-
``` --CSS--
|
46
|
-
|
47
|
-
body {
|
48
|
-
|
49
|
-
margin: 0;
|
50
|
-
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
.container {
|
56
|
-
|
57
|
-
display: flex;
|
58
|
-
|
59
|
-
justify-content: center;
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
.table1 {
|
66
|
-
|
67
|
-
width: 80%;
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
.thisMonth {
|
74
|
-
|
75
|
-
text-align: center;
|
76
|
-
|
77
|
-
margin: 40px auto;
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
.sat {
|
84
|
-
|
85
|
-
background-color: skyblue;
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
.sun {
|
92
|
-
|
93
|
-
background-color: tomato;
|
94
|
-
|
95
|
-
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#prev,
|
100
|
-
|
101
|
-
#next {
|
102
|
-
|
103
|
-
display: block;
|
104
|
-
|
105
|
-
margin: auto;
|
106
|
-
|
107
|
-
cursor: pointer;
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
.heading {
|
114
|
-
|
115
|
-
display: flex;
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
.header {
|
122
|
-
|
123
|
-
font-weight: bold;
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
.btn {
|
130
|
-
|
131
|
-
margin-left: 150px;
|
132
|
-
|
133
|
-
margin-bottom: 20px;
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
table,
|
140
|
-
|
141
|
-
th,
|
142
|
-
|
143
|
-
tr,
|
144
|
-
|
145
|
-
td {
|
146
|
-
|
147
|
-
border-collapse: collapse;
|
148
|
-
|
149
|
-
border: 2px solid #333;
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
td {
|
156
|
-
|
157
|
-
width: 53px;
|
158
|
-
|
159
|
-
height: 28px;
|
160
|
-
|
161
|
-
text-align: center;
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
#run {
|
168
|
-
|
169
|
-
cursor: pointer;
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
#run:hover {
|
176
|
-
|
177
|
-
opacity: 0.5;
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
tbody tr td {
|
184
|
-
|
185
|
-
cursor: pointer;
|
186
|
-
|
187
|
-
user-select: none;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
--HTML--
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
<!DOCTYPE html>
|
198
|
-
|
199
|
-
<html lang="ja">
|
200
|
-
|
201
|
-
<head>
|
202
|
-
|
203
|
-
<meta charset="UTF-8">
|
204
|
-
|
205
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
206
|
-
|
207
|
-
<title>Shift Creation</title>
|
208
|
-
|
209
|
-
<link rel="stylesheet" href="css/styles.css">
|
210
|
-
|
211
|
-
</head>
|
212
|
-
|
213
|
-
<body>
|
214
|
-
|
215
|
-
<div class="heading">
|
216
|
-
|
217
|
-
<span id="prev">«</span>
|
218
|
-
|
219
|
-
<h3 id="title" class="thisMonth"></h3>
|
220
|
-
|
221
|
-
<span id="next">»</span>
|
222
|
-
|
223
|
-
</div>
|
224
|
-
|
225
|
-
<button id="run" class="btn">RUN</button>
|
226
|
-
|
227
|
-
<div class="container" id="_container">
|
228
|
-
|
229
|
-
<table class="table1">
|
230
|
-
|
231
|
-
<thead>
|
232
|
-
|
233
|
-
<tr id="calender">
|
234
|
-
|
235
|
-
<th rowspan="2">root</th>
|
236
|
-
|
237
|
-
<th rowspan="2">name</th>
|
238
|
-
|
239
|
-
</tr>
|
240
|
-
|
241
|
-
<tr id="week"></tr>
|
242
|
-
|
243
|
-
</thead>
|
244
|
-
|
245
|
-
<tbody id="tbody1">
|
246
|
-
|
247
|
-
<tr id="row0">
|
248
|
-
|
249
|
-
<th>2009</th>
|
250
|
-
|
251
|
-
<th>yu-ki</th>
|
252
|
-
|
253
|
-
<tr id="row1">
|
254
|
-
|
255
|
-
<th>2010</th>
|
256
|
-
|
257
|
-
<th>aya</th>
|
258
|
-
|
259
|
-
<tr id="row2">
|
260
|
-
|
261
|
-
<th>2011</th>
|
262
|
-
|
263
|
-
<th>rino</th>
|
264
|
-
|
265
|
-
<tr id="row3">
|
266
|
-
|
267
|
-
<th>2012</th>
|
268
|
-
|
269
|
-
<th>den</th>
|
270
|
-
|
271
|
-
<tr id="row4">
|
272
|
-
|
273
|
-
<th>2014</th>
|
274
|
-
|
275
|
-
<th>petie</th>
|
276
|
-
|
277
|
-
<tr id="row5">
|
278
|
-
|
279
|
-
<th>STR</th>
|
280
|
-
|
281
|
-
<th>tanaka</th>
|
282
|
-
|
283
|
-
<tr id="row6">
|
284
|
-
|
285
|
-
<th>STR</th>
|
286
|
-
|
287
|
-
<th>yoshida</th>
|
288
|
-
|
289
|
-
</tr>
|
290
|
-
|
291
|
-
</tbody>
|
292
|
-
|
293
|
-
</table>
|
294
|
-
|
295
|
-
<table class="table2">
|
296
|
-
|
297
|
-
<thead>
|
298
|
-
|
299
|
-
<tr>
|
300
|
-
|
301
|
-
<th height="60">P.H</th>
|
302
|
-
|
303
|
-
</tr>
|
304
|
-
|
305
|
-
</thead>
|
306
|
-
|
307
|
-
<tbody id="tbody2">
|
308
|
-
|
309
|
-
<tr id="_row0">
|
310
|
-
|
311
|
-
<td id="phValue0">0</td>
|
312
|
-
|
313
|
-
</tr>
|
314
|
-
|
315
|
-
<tr id="_row1">
|
316
|
-
|
317
|
-
<td id="phValue1">0</td>
|
318
|
-
|
319
|
-
</tr>
|
320
|
-
|
321
|
-
<tr id="_row2">
|
322
|
-
|
323
|
-
<td id="phValue2">0</td>
|
324
|
-
|
325
|
-
</tr>
|
326
|
-
|
327
|
-
<tr id="_row3">
|
328
|
-
|
329
|
-
<td id="phValue3">0</td>
|
330
|
-
|
331
|
-
</tr>
|
332
|
-
|
333
|
-
<tr id="_row4">
|
334
|
-
|
335
|
-
<td id="phValue4">0</td>
|
336
|
-
|
337
|
-
</tr>
|
338
|
-
|
339
|
-
<tr id="_row5">
|
340
|
-
|
341
|
-
<td id="phValue5">0</td>
|
342
|
-
|
343
|
-
</tr>
|
344
|
-
|
345
|
-
<tr id="_row6">
|
346
|
-
|
347
|
-
<td id="phValue6">0</td>
|
348
|
-
|
349
|
-
</tr>
|
350
|
-
|
351
|
-
</tbody>
|
352
|
-
|
353
|
-
</table>
|
354
|
-
|
355
|
-
</div>
|
356
|
-
|
357
|
-
<script src="js/main.js"></script>
|
358
|
-
|
359
|
-
</body>
|
360
|
-
|
361
|
-
</html>
|
362
|
-
|
363
|
-
--javaScript--
|
364
|
-
|
365
|
-
'use strict';
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
{
|
370
654
|
|
371
655
|
|
372
656
|
|
373
|
-
const date = new Date();
|
374
|
-
|
375
|
-
let year = date.getFullYear();
|
376
|
-
|
377
|
-
let month = date.getMonth();
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
function clearCalender() { //前のカレンダーを削除
|
382
|
-
|
383
|
-
const table = document.querySelector('.table1');
|
384
|
-
|
385
|
-
while (table.firstChild) {
|
386
|
-
|
387
|
-
table.removeChild(table.firstChild);
|
388
|
-
|
389
|
-
}
|
390
|
-
|
391
|
-
}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
function renderTitle() {//年月を表示
|
396
|
-
|
397
|
-
const title = document.getElementById('title');
|
398
|
-
|
399
|
-
title.textContent = `${year}/${String(month + 1).padStart(2, '0')}`;
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
function getCalender() { //日数分のセルを生成しtextContentで日付を入れる
|
406
|
-
|
407
|
-
const lastDate = new Date(year, month + 1, 0).getDate();
|
408
|
-
|
409
|
-
for (let i = 1; i <= lastDate; i++) {
|
410
|
-
|
411
|
-
const tdDate = document.createElement('td');
|
412
|
-
|
413
|
-
tdDate.textContent = i;
|
414
|
-
|
415
|
-
document.getElementById('calender').appendChild(tdDate);
|
416
|
-
|
417
|
-
if (new Date(year, month, i).getDay() === 6) {
|
418
|
-
|
419
|
-
tdDate.classList.add('sat');
|
420
|
-
|
421
|
-
}
|
422
|
-
|
423
|
-
if (new Date(year, month, i).getDay() === 0) {
|
424
|
-
|
425
|
-
tdDate.classList.add('sun');
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
};
|
430
|
-
|
431
|
-
}
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
function getWeek() {//当月の曜日を取得しセルを生成
|
436
|
-
|
437
|
-
const lastDate = new Date(year, month + 1, 0).getDate();
|
438
|
-
|
439
|
-
for (let n = 1; n <= lastDate; n++) {
|
440
|
-
|
441
|
-
const tdDay = document.createElement('td');
|
442
|
-
|
443
|
-
let wObj = ["日", "月", "火", "水", "木", "金", "土"][new Date(year, month, n).getDay()];//指定した日付の曜日を文字列で取得
|
444
|
-
|
445
|
-
tdDay.textContent = wObj;
|
446
|
-
|
447
|
-
document.getElementById('week').appendChild(tdDay);
|
448
|
-
|
449
|
-
if (tdDay.textContent==="土") {
|
450
|
-
|
451
|
-
tdDay.classList.add('sat');
|
452
|
-
|
453
|
-
}
|
454
|
-
|
455
|
-
if (tdDay.textContent==="日") {
|
456
|
-
|
457
|
-
tdDay.classList.add('sun');
|
458
|
-
|
459
|
-
}
|
460
|
-
|
461
|
-
};
|
462
|
-
|
463
|
-
}
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
function addCell(id) {//シフト用のセルを生成
|
468
|
-
|
469
|
-
const lastDate = new Date(year, month + 1, 0).getDate();
|
470
|
-
|
471
|
-
for (let n = 1; n <= lastDate; n++) {
|
472
|
-
|
473
|
-
const td = document.createElement('td');
|
474
|
-
|
475
|
-
td.textContent = '○';
|
476
|
-
|
477
|
-
document.getElementById(id).appendChild(td);
|
478
|
-
|
479
|
-
td.addEventListener('click', () => {
|
480
|
-
|
481
|
-
if (td.textContent==='○') {
|
482
|
-
|
483
|
-
td.textContent = '休';
|
484
|
-
|
485
|
-
} else if (td.textContent==='休') {
|
486
|
-
|
487
|
-
td.textContent = '○';
|
488
|
-
|
489
|
-
};
|
490
|
-
|
491
|
-
});
|
492
|
-
|
493
|
-
};
|
494
|
-
|
495
|
-
}
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
function ph(rowId, phId) {//個人の休みをカウントする
|
500
|
-
|
501
|
-
const row = document.getElementById(rowId);
|
502
|
-
|
503
|
-
const td = row.querySelectorAll('td');
|
504
|
-
|
505
|
-
const phValue = document.getElementById(phId);
|
506
|
-
|
507
|
-
let phCount = 0;
|
508
|
-
|
509
|
-
// console.log(td);
|
510
|
-
|
511
|
-
td.forEach(td => td.addEventListener('click', () => {
|
512
|
-
|
513
|
-
if (td.textContent==='○') {
|
514
|
-
|
515
|
-
phCount--;
|
516
|
-
|
517
|
-
phValue.textContent = phCount;
|
518
|
-
|
519
|
-
} else if (td.textContent==='休') {
|
520
|
-
|
521
|
-
phCount++;
|
522
|
-
|
523
|
-
phValue.textContent = phCount;
|
524
|
-
|
525
|
-
};
|
526
|
-
|
527
|
-
}));
|
528
|
-
|
529
|
-
}
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
function bundling() {
|
536
|
-
|
537
|
-
clearCalender();
|
538
|
-
|
539
|
-
renderTitle();
|
540
|
-
|
541
|
-
getCalender();
|
542
|
-
|
543
|
-
getWeek();
|
544
|
-
|
545
|
-
addCell('row0');
|
546
|
-
|
547
|
-
addCell('row1');
|
548
|
-
|
549
|
-
addCell('row2');
|
550
|
-
|
551
|
-
addCell('row3');
|
552
|
-
|
553
|
-
addCell('row4');
|
554
|
-
|
555
|
-
addCell('row5');
|
556
|
-
|
557
|
-
addCell('row6');
|
558
|
-
|
559
|
-
ph('row0', 'phValue0');
|
560
|
-
|
561
|
-
ph('row1', 'phValue1');
|
562
|
-
|
563
|
-
ph('row2', 'phValue2');
|
564
|
-
|
565
|
-
ph('row3', 'phValue3');
|
566
|
-
|
567
|
-
ph('row4', 'phValue4');
|
568
|
-
|
569
|
-
ph('row5', 'phValue5');
|
570
|
-
|
571
|
-
ph('row6', 'phValue6');
|
572
|
-
|
573
|
-
}
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
document.getElementById('prev').addEventListener('click', () => {
|
586
|
-
|
587
|
-
month--;
|
588
|
-
|
589
|
-
if (month < 0) {
|
590
|
-
|
591
|
-
year--;
|
592
|
-
|
593
|
-
month = 11;
|
594
|
-
|
595
|
-
}
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
bundling();
|
600
|
-
|
601
|
-
});
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
document.getElementById('next').addEventListener('click', () => {
|
606
|
-
|
607
|
-
month++;
|
608
|
-
|
609
|
-
if (month > 11) {
|
610
|
-
|
611
|
-
year++;
|
612
|
-
|
613
|
-
month = 0;
|
614
|
-
|
615
|
-
}
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
bundling();
|
620
|
-
|
621
|
-
});
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
bundling();
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
}
|
630
|
-
|
631
|
-
```
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
### 試したこと
|
636
|
-
|
637
|
-
|
638
|
-
|
639
657
|
|
640
658
|
|
641
659
|
### 補足情報(FW/ツールのバージョンなど)
|
2
CSSの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
### 該当のソースコード
|
44
44
|
|
45
|
-
``` --CSS--
|
45
|
+
``` --CSS--
|
46
46
|
|
47
47
|
body {
|
48
48
|
|
@@ -190,17 +190,9 @@
|
|
190
190
|
|
191
191
|
|
192
192
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
193
|
+
--HTML--
|
202
|
-
|
203
|
-
|
194
|
+
|
195
|
+
|
204
196
|
|
205
197
|
<!DOCTYPE html>
|
206
198
|
|
@@ -368,7 +360,7 @@
|
|
368
360
|
|
369
361
|
</html>
|
370
362
|
|
371
|
-
--javaScript--
|
363
|
+
--javaScript--
|
372
364
|
|
373
365
|
'use strict';
|
374
366
|
|
1
CSSの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
コード
|
2
|
+
|
1
|
-
### 前提・実現したいこと
|
3
|
+
```### 前提・実現したいこと
|
2
4
|
|
3
5
|
|
4
6
|
|
@@ -40,7 +42,161 @@
|
|
40
42
|
|
41
43
|
### 該当のソースコード
|
42
44
|
|
43
|
-
```
|
45
|
+
``` --CSS--
|
46
|
+
|
47
|
+
body {
|
48
|
+
|
49
|
+
margin: 0;
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
.container {
|
56
|
+
|
57
|
+
display: flex;
|
58
|
+
|
59
|
+
justify-content: center;
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
.table1 {
|
66
|
+
|
67
|
+
width: 80%;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
.thisMonth {
|
74
|
+
|
75
|
+
text-align: center;
|
76
|
+
|
77
|
+
margin: 40px auto;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
.sat {
|
84
|
+
|
85
|
+
background-color: skyblue;
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
.sun {
|
92
|
+
|
93
|
+
background-color: tomato;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
#prev,
|
100
|
+
|
101
|
+
#next {
|
102
|
+
|
103
|
+
display: block;
|
104
|
+
|
105
|
+
margin: auto;
|
106
|
+
|
107
|
+
cursor: pointer;
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
.heading {
|
114
|
+
|
115
|
+
display: flex;
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
.header {
|
122
|
+
|
123
|
+
font-weight: bold;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
.btn {
|
130
|
+
|
131
|
+
margin-left: 150px;
|
132
|
+
|
133
|
+
margin-bottom: 20px;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
table,
|
140
|
+
|
141
|
+
th,
|
142
|
+
|
143
|
+
tr,
|
144
|
+
|
145
|
+
td {
|
146
|
+
|
147
|
+
border-collapse: collapse;
|
148
|
+
|
149
|
+
border: 2px solid #333;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
td {
|
156
|
+
|
157
|
+
width: 53px;
|
158
|
+
|
159
|
+
height: 28px;
|
160
|
+
|
161
|
+
text-align: center;
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
#run {
|
168
|
+
|
169
|
+
cursor: pointer;
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
#run:hover {
|
176
|
+
|
177
|
+
opacity: 0.5;
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
tbody tr td {
|
184
|
+
|
185
|
+
cursor: pointer;
|
186
|
+
|
187
|
+
user-select: none;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
44
200
|
|
45
201
|
コード
|
46
202
|
|