質問編集履歴
7
訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,200 +14,6 @@
|
|
14
14
|
|
15
15
|
```javscript
|
16
16
|
|
17
|
-
<div id="calendar"></div>
|
18
|
-
|
19
|
-
<p>予約可能時間帯<br>
|
20
|
-
|
21
|
-
<%= form_for @book, :url => {:action => 'create'} do |f| %>
|
22
|
-
|
23
|
-
<div class="cp_ipselect cp_sl01">
|
24
|
-
|
25
|
-
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "予約日" %>
|
26
|
-
|
27
|
-
</div>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
<%= form_for @end, :url => {:action => 'create'} do |f| %>
|
32
|
-
|
33
|
-
<div class="cp_ipselect cp_sl01">
|
34
|
-
|
35
|
-
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "予約日" %>
|
36
|
-
|
37
|
-
</div>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
<input type="submit" value="送信">
|
42
|
-
|
43
|
-
<% end %>
|
44
|
-
|
45
|
-
<% end %>
|
46
|
-
|
47
|
-
</p>
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
<% @r_start.each do |start_times| %>
|
52
|
-
|
53
|
-
<input type="hidden" name="sample" value="<%= start_times.start_time.strftime("%H:%M") %>", id='sample' readonly>
|
54
|
-
|
55
|
-
<% end %>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<% @r_finish.each do |finish_times| %>
|
60
|
-
|
61
|
-
<input type="hidden" name="sample" value="<%= finish_times.end_time.strftime("%H:%M") %>", id='sample2' readonly>
|
62
|
-
|
63
|
-
<% end %>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
<input type="text" class= "text" id="acdn-target" onselect="click_date">
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<p>休憩時間帯<br>
|
74
|
-
|
75
|
-
<%= form_for @break_start, :url => {:action => 'create'} do |f| %>
|
76
|
-
|
77
|
-
<div class="cp_ipselect cp_sl01">
|
78
|
-
|
79
|
-
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "休憩時間" %>
|
80
|
-
|
81
|
-
</div>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<%= form_for @break_end, :url => {:action => 'create'} do |f| %>
|
86
|
-
|
87
|
-
<div class="cp_ipselect cp_sl01">
|
88
|
-
|
89
|
-
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "休憩時間" %>
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
<input type="submit" value="送信">
|
96
|
-
|
97
|
-
<% end %>
|
98
|
-
|
99
|
-
<% end %>
|
100
|
-
|
101
|
-
</p>
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<p>インターバル時間<br>
|
106
|
-
|
107
|
-
<%= form_for @interval, :url => {:action => 'create'} do |f| %>
|
108
|
-
|
109
|
-
<div class="cp_ipselect cp_sl01">
|
110
|
-
|
111
|
-
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "インターバル時間" %>
|
112
|
-
|
113
|
-
</div>
|
114
|
-
|
115
|
-
<input type="submit" value="送信">
|
116
|
-
|
117
|
-
<% end %>
|
118
|
-
|
119
|
-
</p>
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<table class="table">
|
124
|
-
|
125
|
-
<tr>
|
126
|
-
|
127
|
-
<th colspan="7">定休日</th>
|
128
|
-
|
129
|
-
</tr>
|
130
|
-
|
131
|
-
<tr>
|
132
|
-
|
133
|
-
<% @regular_holiday.each do |regular_holidays| %>
|
134
|
-
|
135
|
-
<th><%= regular_holidays %></th>
|
136
|
-
|
137
|
-
<% end %>
|
138
|
-
|
139
|
-
</tr>
|
140
|
-
|
141
|
-
<tr>
|
142
|
-
|
143
|
-
<td id="mon"><%= @check [0]['regular_holidays_check_s'] %></td>
|
144
|
-
|
145
|
-
<td id="tue"><%= @check [0]['regular_holidays_check_s'] %></td>
|
146
|
-
|
147
|
-
<td id="wed"><%= @check [0]['regular_holidays_check_s'] %></td>
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
<td id="thu"><%= @check [0]['regular_holidays_check_s'] %></td>
|
152
|
-
|
153
|
-
<td id="fri"><%= @check [0]['regular_holidays_check_s'] %></td>
|
154
|
-
|
155
|
-
<td id="sat"><%= @check [0]['regular_holidays_check_s'] %></td>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
<td id="sun"><%= @check [0]['regular_holidays_check_s'] %></td>
|
160
|
-
|
161
|
-
</tr>
|
162
|
-
|
163
|
-
</table>
|
164
|
-
|
165
|
-
<br>
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
<!-- 休日設定 -->
|
170
|
-
|
171
|
-
<form>
|
172
|
-
|
173
|
-
<lavel>
|
174
|
-
|
175
|
-
<p>休みたい日</p>
|
176
|
-
|
177
|
-
<input type="date" /><br>
|
178
|
-
|
179
|
-
</label>
|
180
|
-
|
181
|
-
</form>
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
<!-- off_days -->
|
186
|
-
|
187
|
-
<% @off_date.each do |off_date_hidden| %>
|
188
|
-
|
189
|
-
<input type="hidden" name="off_date" value="<%= off_date_hidden.off_days_date.strftime("%Y-%m-%dT") %>", class='off_date' readonly>
|
190
|
-
|
191
|
-
<% end %>
|
192
|
-
|
193
|
-
<% @off_start.each do |off_start_hidden| %>
|
194
|
-
|
195
|
-
<input type="hidden" name="off_start" value="<%= off_start_hidden.off_days_start_time.strftime("%H:%M") %>", class='off_start' readonly>
|
196
|
-
|
197
|
-
<% end %>
|
198
|
-
|
199
|
-
<% @off_finish.each do |off_finish_hidden| %>
|
200
|
-
|
201
|
-
<input type="hidden" name="off_finish" value="<%= off_finish_hidden.off_days_finish_time.strftime("%H:%M") %>", class='off_finish' readonly>
|
202
|
-
|
203
|
-
<% end %>
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
17
|
<!-- JS -->
|
212
18
|
|
213
19
|
<script>
|
@@ -520,44 +326,6 @@
|
|
520
326
|
|
521
327
|
|
522
328
|
|
523
|
-
var abc = Array.from(document.getElementsByName('off_date'), x => x.value);
|
524
|
-
|
525
|
-
var bcd = Array.from(document.getElementsByName('off_start'), x => x.value);
|
526
|
-
|
527
|
-
var cde = Array.from(document.getElementsByName('off_finish'), x => x.value);
|
528
|
-
|
529
|
-
console.log(abc + bcd + '~' + cde);//19年02月06日08:00~20:00
|
530
|
-
|
531
|
-
const BUSY = abc.map((v, i) => abc[i] + bcd[i]); //mapでなんでこうなるの?配列の結合が意味分からない
|
532
|
-
|
533
|
-
console.log(BUSY);
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
let a = new Shedule (new Date, 14, BUSY), {table: b} = a;
|
548
|
-
|
549
|
-
document.querySelector ('#calendar').appendChild (b);
|
550
|
-
|
551
|
-
b.addEventListener ('click', a, false);
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
/*let c = new Shedule (new Date,7,BUSY), {table: d} = c;
|
556
|
-
|
557
|
-
document.querySelector ('#calendar').appendChild (d);
|
558
|
-
|
559
|
-
d.addEventListener ('click', c, false);*/
|
560
|
-
|
561
329
|
|
562
330
|
|
563
331
|
var today = new Date();
|
@@ -619,13 +387,3 @@
|
|
619
387
|
</script>
|
620
388
|
|
621
389
|
```
|
622
|
-
|
623
|
-
### 入力画面イメージ
|
624
|
-
|
625
|
-
![イメージ説明](c595e80e0d54fd8ec138921b75c87aa7.png)
|
626
|
-
|
627
|
-
###イメージ
|
628
|
-
|
629
|
-
![イメージ説明](6fd9888846b014d82e617608c71deead.png)
|
630
|
-
|
631
|
-
**大変失礼なことをしてしまい申し訳ございませんでした。**
|
6
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,328 +12,614 @@
|
|
12
12
|
|
13
13
|
### 該当のソースコード
|
14
14
|
|
15
|
-
```
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
```javscript
|
16
|
+
|
17
|
+
<div id="calendar"></div>
|
18
|
+
|
19
|
+
<p>予約可能時間帯<br>
|
20
|
+
|
21
|
+
<%= form_for @book, :url => {:action => 'create'} do |f| %>
|
22
|
+
|
23
|
+
<div class="cp_ipselect cp_sl01">
|
24
|
+
|
25
|
+
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "予約日" %>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
<%= form_for @end, :url => {:action => 'create'} do |f| %>
|
32
|
+
|
33
|
+
<div class="cp_ipselect cp_sl01">
|
34
|
+
|
35
|
+
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "予約日" %>
|
36
|
+
|
37
|
+
</div>
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
<input type="submit" value="送信">
|
42
|
+
|
43
|
+
<% end %>
|
44
|
+
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
</p>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<% @r_start.each do |start_times| %>
|
52
|
+
|
53
|
+
<input type="hidden" name="sample" value="<%= start_times.start_time.strftime("%H:%M") %>", id='sample' readonly>
|
54
|
+
|
55
|
+
<% end %>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<% @r_finish.each do |finish_times| %>
|
60
|
+
|
61
|
+
<input type="hidden" name="sample" value="<%= finish_times.end_time.strftime("%H:%M") %>", id='sample2' readonly>
|
62
|
+
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<input type="text" class= "text" id="acdn-target" onselect="click_date">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<p>休憩時間帯<br>
|
74
|
+
|
75
|
+
<%= form_for @break_start, :url => {:action => 'create'} do |f| %>
|
76
|
+
|
77
|
+
<div class="cp_ipselect cp_sl01">
|
78
|
+
|
79
|
+
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "休憩時間" %>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<%= form_for @break_end, :url => {:action => 'create'} do |f| %>
|
86
|
+
|
87
|
+
<div class="cp_ipselect cp_sl01">
|
88
|
+
|
89
|
+
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "休憩時間" %>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<input type="submit" value="送信">
|
96
|
+
|
97
|
+
<% end %>
|
98
|
+
|
99
|
+
<% end %>
|
100
|
+
|
101
|
+
</p>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<p>インターバル時間<br>
|
106
|
+
|
107
|
+
<%= form_for @interval, :url => {:action => 'create'} do |f| %>
|
108
|
+
|
109
|
+
<div class="cp_ipselect cp_sl01">
|
110
|
+
|
111
|
+
<%= f.collection_select :t_book_times, TBookTime.all, :id, :t_book_times_zone, :prompt => "インターバル時間" %>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<input type="submit" value="送信">
|
116
|
+
|
117
|
+
<% end %>
|
118
|
+
|
119
|
+
</p>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<table class="table">
|
124
|
+
|
125
|
+
<tr>
|
126
|
+
|
127
|
+
<th colspan="7">定休日</th>
|
128
|
+
|
129
|
+
</tr>
|
130
|
+
|
131
|
+
<tr>
|
132
|
+
|
133
|
+
<% @regular_holiday.each do |regular_holidays| %>
|
134
|
+
|
135
|
+
<th><%= regular_holidays %></th>
|
136
|
+
|
137
|
+
<% end %>
|
138
|
+
|
139
|
+
</tr>
|
140
|
+
|
141
|
+
<tr>
|
142
|
+
|
143
|
+
<td id="mon"><%= @check [0]['regular_holidays_check_s'] %></td>
|
144
|
+
|
145
|
+
<td id="tue"><%= @check [0]['regular_holidays_check_s'] %></td>
|
146
|
+
|
147
|
+
<td id="wed"><%= @check [0]['regular_holidays_check_s'] %></td>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<td id="thu"><%= @check [0]['regular_holidays_check_s'] %></td>
|
152
|
+
|
153
|
+
<td id="fri"><%= @check [0]['regular_holidays_check_s'] %></td>
|
154
|
+
|
155
|
+
<td id="sat"><%= @check [0]['regular_holidays_check_s'] %></td>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<td id="sun"><%= @check [0]['regular_holidays_check_s'] %></td>
|
160
|
+
|
161
|
+
</tr>
|
162
|
+
|
163
|
+
</table>
|
164
|
+
|
165
|
+
<br>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<!-- 休日設定 -->
|
170
|
+
|
171
|
+
<form>
|
172
|
+
|
173
|
+
<lavel>
|
174
|
+
|
175
|
+
<p>休みたい日</p>
|
176
|
+
|
177
|
+
<input type="date" /><br>
|
178
|
+
|
179
|
+
</label>
|
180
|
+
|
181
|
+
</form>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<!-- off_days -->
|
186
|
+
|
187
|
+
<% @off_date.each do |off_date_hidden| %>
|
188
|
+
|
189
|
+
<input type="hidden" name="off_date" value="<%= off_date_hidden.off_days_date.strftime("%Y-%m-%dT") %>", class='off_date' readonly>
|
190
|
+
|
191
|
+
<% end %>
|
192
|
+
|
193
|
+
<% @off_start.each do |off_start_hidden| %>
|
194
|
+
|
195
|
+
<input type="hidden" name="off_start" value="<%= off_start_hidden.off_days_start_time.strftime("%H:%M") %>", class='off_start' readonly>
|
196
|
+
|
197
|
+
<% end %>
|
198
|
+
|
199
|
+
<% @off_finish.each do |off_finish_hidden| %>
|
200
|
+
|
201
|
+
<input type="hidden" name="off_finish" value="<%= off_finish_hidden.off_days_finish_time.strftime("%H:%M") %>", class='off_finish' readonly>
|
202
|
+
|
203
|
+
<% end %>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<!-- JS -->
|
212
|
+
|
213
|
+
<script>
|
214
|
+
|
215
|
+
{
|
216
|
+
|
217
|
+
const
|
218
|
+
|
219
|
+
day_name = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
220
|
+
|
221
|
+
day_jname = ['Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'],
|
222
|
+
|
223
|
+
doc = document;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
const
|
228
|
+
|
229
|
+
A = (e, ...a) => a.map (a => e.appendChild (doc.createElement (a))),
|
230
|
+
|
231
|
+
B = (d, n) => d.setDate (d.getDate () + n),
|
232
|
+
|
233
|
+
C = d => [d.getFullYear (), '年', d.getMonth () + 1 , '月'].join (''),
|
234
|
+
|
235
|
+
D = d => [('0' + d.getHours ()).slice (-2), ('0' + d.getMinutes ()).slice (-2)].join (':'),
|
236
|
+
|
237
|
+
E = (e, d) => {
|
238
|
+
|
239
|
+
let
|
240
|
+
|
241
|
+
[a,,b] = A (e, 'label', 'br', 'label'),
|
242
|
+
|
243
|
+
w = d.getDay () ;
|
244
|
+
|
245
|
+
a.textContent = d.getDate ();
|
246
|
+
|
247
|
+
b.textContent = day_jname[w];
|
248
|
+
|
249
|
+
e.classList.add (day_name[w]);
|
250
|
+
|
251
|
+
},
|
252
|
+
|
253
|
+
F = d => {
|
254
|
+
|
255
|
+
let m = d.getMonth ();
|
256
|
+
|
257
|
+
return [0,31,59,90,120,151,181,212,243,273,304,334][m] + d.getDate() - 1 +
|
258
|
+
|
259
|
+
(new Date (d.getFullYear (), m + 1,0) === 29 && 0 < m);
|
260
|
+
|
261
|
+
},
|
262
|
+
|
263
|
+
G = ary => ary.reduce ((a, b) => {
|
264
|
+
|
265
|
+
let
|
266
|
+
|
267
|
+
c = typeof b === 'string' ? new Date (b +':00.000+09:00'): b,
|
268
|
+
|
269
|
+
d = D (c);
|
270
|
+
|
271
|
+
if (! (d in a)) a[d] = [];
|
272
|
+
|
273
|
+
a[d][F(c)] = true;
|
274
|
+
|
275
|
+
return a;
|
276
|
+
|
277
|
+
}, { })
|
278
|
+
|
279
|
+
,
|
280
|
+
|
281
|
+
H = d => new Date (d.getFullYear (), d.getMonth (), d.getDate ()),
|
282
|
+
|
283
|
+
I = d => [('0' + d.getUTCHours ()).slice (-2), ('0' + d.getUTCMinutes ()).slice (-2)].join (':')
|
284
|
+
|
285
|
+
;
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
class Shedule {
|
292
|
+
|
293
|
+
constructor (date = new Date, range = 7, plan = []) {
|
294
|
+
|
295
|
+
this.current = H (date);
|
296
|
+
|
297
|
+
this.date = H (date);
|
298
|
+
|
299
|
+
this.range = range;
|
300
|
+
|
301
|
+
this.plan = G (plan);
|
302
|
+
|
303
|
+
this.table = document.createElement ('table');
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
this.remake ();
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
add (day = this.range) {
|
316
|
+
|
317
|
+
let d = H (this.current);
|
318
|
+
|
319
|
+
d.setDate (d.getDate () + day);
|
320
|
+
|
321
|
+
if (+this.date <= +d) {
|
322
|
+
|
323
|
+
this.current = d;
|
324
|
+
|
325
|
+
this.remake ();
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
remake () {
|
336
|
+
|
337
|
+
this.prev_btn = this.next_btn = null;
|
338
|
+
|
339
|
+
let t = this.table;
|
340
|
+
|
341
|
+
[...t.childNodes].forEach (e => e.remove ());
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
let
|
346
|
+
|
347
|
+
h = t.createTHead (),
|
348
|
+
|
349
|
+
tr0 = h.insertRow (-1),
|
350
|
+
|
351
|
+
tr1 = h.insertRow (-1),
|
352
|
+
|
353
|
+
d = H (this.current),
|
354
|
+
|
355
|
+
s = tr0.insertCell (-1),
|
356
|
+
|
357
|
+
c = 1,
|
358
|
+
|
359
|
+
m = d.getMonth ();
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
for (let i = 0; i < this.range; i++, c++, B (d, 1)) {
|
364
|
+
|
365
|
+
let td = tr1.insertCell (-1);
|
366
|
+
|
367
|
+
if (m !== d.getMonth ()) {
|
368
|
+
|
369
|
+
s.colSpan = c - 1;
|
370
|
+
|
371
|
+
s = tr0.insertCell (-1);
|
372
|
+
|
373
|
+
m = d.getMonth ();
|
374
|
+
|
375
|
+
c = 1;
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
s.textContent = C (d);
|
380
|
+
|
381
|
+
E (td, d);
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
s.colSpan = c - 1;
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
let e = tr0.insertCell (0);
|
390
|
+
|
391
|
+
e.textContent = '前の一週間';
|
392
|
+
|
393
|
+
e.classList.add ('button');
|
394
|
+
|
395
|
+
e.rowSpan = 2;
|
396
|
+
|
397
|
+
this.prev_btn = e;
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
e = tr0.insertCell (-1);
|
402
|
+
|
403
|
+
e.textContent = '次の一週間';
|
404
|
+
|
405
|
+
e.classList.add ('button');
|
406
|
+
|
407
|
+
e.rowSpan = 2;
|
408
|
+
|
409
|
+
this.next_btn = e;
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
//start--時間の時と分の分割処理
|
414
|
+
|
415
|
+
var name_start = document.getElementById('sample').value;
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
var result = name_start.substr( 0, 2 );
|
420
|
+
|
421
|
+
var result2 = name_start.substr( 3, 4 );
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
var hour_start = result, minutes_start = result2;
|
426
|
+
|
427
|
+
//---end
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
//finish
|
432
|
+
|
433
|
+
var name_finish = document.getElementById('sample2').value;
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
var result_finish = name_finish.substr( 0, 2 );
|
438
|
+
|
439
|
+
var result2_finish = name_finish.substr( 3, 4 );
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
var hour_end = result_finish, minutes_end = result2_finish;
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
//---end
|
448
|
+
|
449
|
+
let
|
450
|
+
|
451
|
+
begin = new Date (Date.UTC (1970,0,1, hour_start, minutes_start)),//列のスタート時間 //ここをどうにかしたい。
|
452
|
+
|
453
|
+
end = new Date (Date.UTC (1970,0,1, hour_end, minutes_end)),//列の終了時間 //ここをどうにかしたい
|
454
|
+
|
455
|
+
step = new Date (Date.UTC (1970,0,1, 0,30)),//列の感覚調整時間
|
456
|
+
|
457
|
+
o = F (this.current),
|
458
|
+
|
459
|
+
rst = [ ];
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
for (let d = begin; d < end; d = new Date (+step + (+d))) {
|
464
|
+
|
465
|
+
let
|
466
|
+
|
467
|
+
a = new Array (this.rangi),
|
468
|
+
|
469
|
+
b = I (d),
|
470
|
+
|
471
|
+
c = this.plan[b] || [];
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
for (let i = 0; i < this.range; i++)
|
476
|
+
|
477
|
+
a[i] = c[o + i] ? '-' : '◎';
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
rst.push ([b, ...a, b]);
|
482
|
+
|
483
|
+
}
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
let [tb] = A (t, 'tbody');
|
488
|
+
|
489
|
+
rst.forEach (r => {
|
490
|
+
|
491
|
+
let tr = tb.insertRow (-1);
|
492
|
+
|
493
|
+
r.forEach (c => tr.insertCell (-1).textContent = c)
|
494
|
+
|
495
|
+
});
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
}
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
handleEvent ({target: t}) {
|
504
|
+
|
505
|
+
if (t === this.prev_btn) this.add (-this.range);
|
506
|
+
|
507
|
+
if (t === this.next_btn) this.add (this.range);
|
508
|
+
|
509
|
+
}
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
}
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
this.Shedule = Shedule;
|
518
|
+
|
519
|
+
}
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
var abc = Array.from(document.getElementsByName('off_date'), x => x.value);
|
524
|
+
|
525
|
+
var bcd = Array.from(document.getElementsByName('off_start'), x => x.value);
|
526
|
+
|
527
|
+
var cde = Array.from(document.getElementsByName('off_finish'), x => x.value);
|
528
|
+
|
529
|
+
console.log(abc + bcd + '~' + cde);//19年02月06日08:00~20:00
|
530
|
+
|
531
|
+
const BUSY = abc.map((v, i) => abc[i] + bcd[i]); //mapでなんでこうなるの?配列の結合が意味分からない
|
532
|
+
|
533
|
+
console.log(BUSY);
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
let a = new Shedule (new Date, 14, BUSY), {table: b} = a;
|
548
|
+
|
549
|
+
document.querySelector ('#calendar').appendChild (b);
|
550
|
+
|
551
|
+
b.addEventListener ('click', a, false);
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
/*let c = new Shedule (new Date,7,BUSY), {table: d} = c;
|
556
|
+
|
557
|
+
document.querySelector ('#calendar').appendChild (d);
|
558
|
+
|
559
|
+
d.addEventListener ('click', c, false);*/
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
var today = new Date();
|
564
|
+
|
565
|
+
var year = today.getFullYear();
|
566
|
+
|
567
|
+
var month = today.getMonth() + 1;
|
568
|
+
|
569
|
+
var day = today.getDate();
|
570
|
+
|
571
|
+
var tds = document.querySelectorAll('td');
|
572
|
+
|
573
|
+
var yobi= new Array("日","月","火","水","木","金","土");
|
574
|
+
|
575
|
+
document.getElementById('acdn-target').value = year+'年'+month+'月'+ day+'日 ';
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
document.querySelector('#calendar').addEventListener('click', event => {
|
582
|
+
|
583
|
+
const target = event.target;
|
584
|
+
|
585
|
+
if (target.nodeName.toLowerCase() !== 'td') {
|
586
|
+
|
587
|
+
return true;
|
588
|
+
|
589
|
+
}
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
if (!(target.closest('tbody') && 1 <= target.cellIndex && target.cellIndex <= 14)) {
|
594
|
+
|
595
|
+
return true;
|
596
|
+
|
597
|
+
}
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
const time = target.parentNode.cells[0].textContent;
|
602
|
+
|
603
|
+
const table = target.closest('table');
|
604
|
+
|
605
|
+
const date = table.tHead.rows[1].cells[target.cellIndex - 1].textContent.slice(0,-4);
|
606
|
+
|
607
|
+
const ymrow = table.tHead.rows[0];
|
608
|
+
|
609
|
+
const ym = (target.cellIndex <= ymrow.cells[1].colSpan ? ymrow.cells[1] : ymrow.cells[2]).textContent;
|
610
|
+
|
611
|
+
document.getElementById('acdn-target').value = ym + date + '日' + time;
|
612
|
+
|
613
|
+
return true;
|
614
|
+
|
615
|
+
}, false);
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
</script>
|
20
620
|
|
21
621
|
```
|
22
622
|
|
23
|
-
```js
|
24
|
-
|
25
|
-
<script>
|
26
|
-
|
27
|
-
{
|
28
|
-
|
29
|
-
const
|
30
|
-
|
31
|
-
day_name = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
32
|
-
|
33
|
-
day_jname = ['(日)', '(月)', '(火)', '(水)', '(木)', '(金)', '(土)'],
|
34
|
-
|
35
|
-
doc = document;
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
const
|
40
|
-
|
41
|
-
A = (e, ...a) => a.map (a => e.appendChild (doc.createElement (a))),
|
42
|
-
|
43
|
-
B = (d, n) => d.setDate (d.getDate () + n),
|
44
|
-
|
45
|
-
C = d => [d.getFullYear (), '年', d.getMonth () + 1 , '月'].join (''),
|
46
|
-
|
47
|
-
D = d => [('0' + d.getHours ()).slice (-2), ('0' + d.getMinutes ()).slice (-2)].join (':'),
|
48
|
-
|
49
|
-
E = (e, d) => {
|
50
|
-
|
51
|
-
let
|
52
|
-
|
53
|
-
[a,,b] = A (e, 'label', 'br', 'label'),
|
54
|
-
|
55
|
-
w = d.getDay () ;
|
56
|
-
|
57
|
-
a.textContent = d.getDate ();
|
58
|
-
|
59
|
-
b.textContent = day_jname[w];
|
60
|
-
|
61
|
-
e.classList.add (day_name[w]);
|
62
|
-
|
63
|
-
},
|
64
|
-
|
65
|
-
F = d => {
|
66
|
-
|
67
|
-
let m = d.getMonth ();
|
68
|
-
|
69
|
-
return [0,31,59,90,120,151,181,212,243,273,304,334][m] + d.getDate() - 1 +
|
70
|
-
|
71
|
-
(new Date (d.getFullYear (), m + 1,0) === 29 && 0 < m);
|
72
|
-
|
73
|
-
},
|
74
|
-
|
75
|
-
G = ary => ary.reduce ((a, b) => {
|
76
|
-
|
77
|
-
let
|
78
|
-
|
79
|
-
c = typeof b === 'string' ? new Date (b +':00.000+09:00'): b,
|
80
|
-
|
81
|
-
d = D (c);
|
82
|
-
|
83
|
-
if (! (d in a)) a[d] = [];
|
84
|
-
|
85
|
-
a[d][F(c)] = true;
|
86
|
-
|
87
|
-
return a;
|
88
|
-
|
89
|
-
}, { })
|
90
|
-
|
91
|
-
,
|
92
|
-
|
93
|
-
H = d => new Date (d.getFullYear (), d.getMonth (), d.getDate ()),
|
94
|
-
|
95
|
-
I = d => [('0' + d.getUTCHours ()).slice (-2), ('0' + d.getUTCMinutes ()).slice (-2)].join (':')
|
96
|
-
|
97
|
-
;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
class Shedule {
|
104
|
-
|
105
|
-
constructor (date = new Date, range = 7, plan = []) {
|
106
|
-
|
107
|
-
this.current = H (date);
|
108
|
-
|
109
|
-
this.date = H (date);
|
110
|
-
|
111
|
-
this.range = range;
|
112
|
-
|
113
|
-
this.plan = G (plan);
|
114
|
-
|
115
|
-
this.table = document.createElement ('table');
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
this.remake ();
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
add (day = this.range) {
|
128
|
-
|
129
|
-
let d = H (this.current);
|
130
|
-
|
131
|
-
d.setDate (d.getDate () + day);
|
132
|
-
|
133
|
-
if (+this.date <= +d) {
|
134
|
-
|
135
|
-
this.current = d;
|
136
|
-
|
137
|
-
this.remake ();
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
remake () {
|
148
|
-
|
149
|
-
this.prev_btn = this.next_btn = null;
|
150
|
-
|
151
|
-
let t = this.table;
|
152
|
-
|
153
|
-
[...t.childNodes].forEach (e => e.remove ());
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
let
|
158
|
-
|
159
|
-
h = t.createTHead (),
|
160
|
-
|
161
|
-
tr0 = h.insertRow (-1),
|
162
|
-
|
163
|
-
tr1 = h.insertRow (-1),
|
164
|
-
|
165
|
-
d = H (this.current),
|
166
|
-
|
167
|
-
s = tr0.insertCell (-1),
|
168
|
-
|
169
|
-
c = 1,
|
170
|
-
|
171
|
-
m = d.getMonth ();
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
for (let i = 0; i < this.range; i++, c++, B (d, 1)) {
|
176
|
-
|
177
|
-
let td = tr1.insertCell (-1);
|
178
|
-
|
179
|
-
if (m !== d.getMonth ()) {
|
180
|
-
|
181
|
-
s.colSpan = c - 1;
|
182
|
-
|
183
|
-
s = tr0.insertCell (-1);
|
184
|
-
|
185
|
-
m = d.getMonth ();
|
186
|
-
|
187
|
-
c = 1;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
s.textContent = C (d);
|
192
|
-
|
193
|
-
E (td, d);
|
194
|
-
|
195
|
-
}
|
196
|
-
|
197
|
-
s.colSpan = c - 1;
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
let e = tr0.insertCell (0);
|
202
|
-
|
203
|
-
e.textContent = '前の一週間';
|
204
|
-
|
205
|
-
e.classList.add ('button');
|
206
|
-
|
207
|
-
e.rowSpan = 2;
|
208
|
-
|
209
|
-
this.prev_btn = e;
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
e = tr0.insertCell (-1);
|
214
|
-
|
215
|
-
e.textContent = '次の一週間';
|
216
|
-
|
217
|
-
e.classList.add ('button');
|
218
|
-
|
219
|
-
e.rowSpan = 2;
|
220
|
-
|
221
|
-
this.next_btn = e;
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
//__
|
226
|
-
|
227
|
-
let
|
228
|
-
|
229
|
-
begin = new Date (Date.UTC (1970,0,1, 9, 0)),
|
230
|
-
|
231
|
-
end = new Date (Date.UTC (1970,0,1,12, 0)),
|
232
|
-
|
233
|
-
step = new Date (Date.UTC (1970,0,1, 0,30)),
|
234
|
-
|
235
|
-
o = F (this.current),
|
236
|
-
|
237
|
-
rst = [ ];
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
for (let d = begin; d < end; d = new Date (+step + (+d))) {
|
242
|
-
|
243
|
-
let
|
244
|
-
|
245
|
-
a = new Array (this.rangi),
|
246
|
-
|
247
|
-
b = I (d),
|
248
|
-
|
249
|
-
c = this.plan[b] || [];
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
for (let i = 0; i < this.range; i++)
|
254
|
-
|
255
|
-
a[i] = c[o + i] ? '◎': '-';
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
rst.push ([b, ...a, b]);
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
let [tb] = A (t, 'tbody');
|
266
|
-
|
267
|
-
rst.forEach (r => {
|
268
|
-
|
269
|
-
let tr = tb.insertRow (-1);
|
270
|
-
|
271
|
-
r.forEach (c => tr.insertCell (-1).textContent = c)
|
272
|
-
|
273
|
-
});
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
handleEvent ({target: t}) {
|
282
|
-
|
283
|
-
if (t === this.prev_btn) this.add (-this.range);
|
284
|
-
|
285
|
-
if (t === this.next_btn) this.add (this.range);
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
this.Shedule = Shedule;
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
const BUSY = [
|
302
|
-
|
303
|
-
'2019-02-12T10:00',
|
304
|
-
|
305
|
-
'2019-02-12T10:30',
|
306
|
-
|
307
|
-
'2019-02-13T10:00',
|
308
|
-
|
309
|
-
'2019-02-02T10:00',
|
310
|
-
|
311
|
-
'2019-02-02T10:30',
|
312
|
-
|
313
|
-
'2019-02-03T10:00',
|
314
|
-
|
315
|
-
'2019-02-03T10:30',
|
316
|
-
|
317
|
-
'2019-02-09T10:00',
|
318
|
-
|
319
|
-
'2019-02-09T10:30'
|
320
|
-
|
321
|
-
];
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
let c = new Shedule (new Date,7,BUSY), {table: d} = c;
|
326
|
-
|
327
|
-
document.querySelector ('#calendar').appendChild (d);
|
328
|
-
|
329
|
-
d.addEventListener ('click', c, false);
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
</script>
|
334
|
-
|
335
|
-
```
|
336
|
-
|
337
623
|
### 入力画面イメージ
|
338
624
|
|
339
625
|
![イメージ説明](c595e80e0d54fd8ec138921b75c87aa7.png)
|
5
画像の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -334,4 +334,12 @@
|
|
334
334
|
|
335
335
|
```
|
336
336
|
|
337
|
+
### 入力画面イメージ
|
338
|
+
|
339
|
+
![イメージ説明](c595e80e0d54fd8ec138921b75c87aa7.png)
|
340
|
+
|
341
|
+
###イメージ
|
342
|
+
|
343
|
+
![イメージ説明](6fd9888846b014d82e617608c71deead.png)
|
344
|
+
|
337
345
|
**大変失礼なことをしてしまい申し訳ございませんでした。**
|
4
タイトルの変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Javascript:
|
1
|
+
Javascript: getElementByIdをクリックした時の処理について
|
test
CHANGED
File without changes
|
3
ご指摘を受けたため質問を元の形にしました。失礼なことをしてしまい申し訳ございませんでした。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,337 @@
|
|
1
|
-
###
|
1
|
+
### 大変失礼なことをしてしまいすいませんでした。
|
2
|
+
|
2
|
-
|
3
|
+
### 前提・実現したいこと
|
4
|
+
|
3
|
-
|
5
|
+
下記のボタンをクリックした時に月曜日の全時間帯を **-** と表示させれたらいいなと思います。
|
6
|
+
|
4
|
-
|
7
|
+
失礼なことをした以上、回答を頂けるとは思いませんがもしそれでもご教授頂けたら幸いです。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### 該当のソースコード
|
14
|
+
|
15
|
+
```html
|
16
|
+
|
17
|
+
<div id="calendar"></div>
|
18
|
+
|
19
|
+
<input type="button" value="月曜日を定休日に" class="mon">
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
```js
|
24
|
+
|
25
|
+
<script>
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
const
|
30
|
+
|
31
|
+
day_name = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
32
|
+
|
33
|
+
day_jname = ['(日)', '(月)', '(火)', '(水)', '(木)', '(金)', '(土)'],
|
34
|
+
|
35
|
+
doc = document;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
const
|
40
|
+
|
41
|
+
A = (e, ...a) => a.map (a => e.appendChild (doc.createElement (a))),
|
42
|
+
|
43
|
+
B = (d, n) => d.setDate (d.getDate () + n),
|
44
|
+
|
45
|
+
C = d => [d.getFullYear (), '年', d.getMonth () + 1 , '月'].join (''),
|
46
|
+
|
47
|
+
D = d => [('0' + d.getHours ()).slice (-2), ('0' + d.getMinutes ()).slice (-2)].join (':'),
|
48
|
+
|
49
|
+
E = (e, d) => {
|
50
|
+
|
51
|
+
let
|
52
|
+
|
5
|
-
|
53
|
+
[a,,b] = A (e, 'label', 'br', 'label'),
|
54
|
+
|
6
|
-
|
55
|
+
w = d.getDay () ;
|
56
|
+
|
57
|
+
a.textContent = d.getDate ();
|
58
|
+
|
59
|
+
b.textContent = day_jname[w];
|
60
|
+
|
61
|
+
e.classList.add (day_name[w]);
|
62
|
+
|
63
|
+
},
|
64
|
+
|
65
|
+
F = d => {
|
66
|
+
|
67
|
+
let m = d.getMonth ();
|
68
|
+
|
69
|
+
return [0,31,59,90,120,151,181,212,243,273,304,334][m] + d.getDate() - 1 +
|
70
|
+
|
71
|
+
(new Date (d.getFullYear (), m + 1,0) === 29 && 0 < m);
|
72
|
+
|
73
|
+
},
|
74
|
+
|
75
|
+
G = ary => ary.reduce ((a, b) => {
|
76
|
+
|
77
|
+
let
|
78
|
+
|
7
|
-
|
79
|
+
c = typeof b === 'string' ? new Date (b +':00.000+09:00'): b,
|
80
|
+
|
81
|
+
d = D (c);
|
82
|
+
|
83
|
+
if (! (d in a)) a[d] = [];
|
84
|
+
|
85
|
+
a[d][F(c)] = true;
|
86
|
+
|
87
|
+
return a;
|
88
|
+
|
89
|
+
}, { })
|
90
|
+
|
91
|
+
,
|
92
|
+
|
93
|
+
H = d => new Date (d.getFullYear (), d.getMonth (), d.getDate ()),
|
94
|
+
|
95
|
+
I = d => [('0' + d.getUTCHours ()).slice (-2), ('0' + d.getUTCMinutes ()).slice (-2)].join (':')
|
96
|
+
|
97
|
+
;
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
class Shedule {
|
104
|
+
|
105
|
+
constructor (date = new Date, range = 7, plan = []) {
|
106
|
+
|
107
|
+
this.current = H (date);
|
108
|
+
|
109
|
+
this.date = H (date);
|
110
|
+
|
111
|
+
this.range = range;
|
112
|
+
|
113
|
+
this.plan = G (plan);
|
114
|
+
|
115
|
+
this.table = document.createElement ('table');
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
this.remake ();
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
add (day = this.range) {
|
128
|
+
|
129
|
+
let d = H (this.current);
|
130
|
+
|
131
|
+
d.setDate (d.getDate () + day);
|
132
|
+
|
133
|
+
if (+this.date <= +d) {
|
134
|
+
|
135
|
+
this.current = d;
|
136
|
+
|
137
|
+
this.remake ();
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
remake () {
|
148
|
+
|
149
|
+
this.prev_btn = this.next_btn = null;
|
150
|
+
|
151
|
+
let t = this.table;
|
152
|
+
|
153
|
+
[...t.childNodes].forEach (e => e.remove ());
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
let
|
158
|
+
|
159
|
+
h = t.createTHead (),
|
160
|
+
|
161
|
+
tr0 = h.insertRow (-1),
|
162
|
+
|
163
|
+
tr1 = h.insertRow (-1),
|
164
|
+
|
165
|
+
d = H (this.current),
|
166
|
+
|
167
|
+
s = tr0.insertCell (-1),
|
168
|
+
|
169
|
+
c = 1,
|
170
|
+
|
171
|
+
m = d.getMonth ();
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
for (let i = 0; i < this.range; i++, c++, B (d, 1)) {
|
176
|
+
|
177
|
+
let td = tr1.insertCell (-1);
|
178
|
+
|
179
|
+
if (m !== d.getMonth ()) {
|
180
|
+
|
181
|
+
s.colSpan = c - 1;
|
182
|
+
|
183
|
+
s = tr0.insertCell (-1);
|
184
|
+
|
185
|
+
m = d.getMonth ();
|
186
|
+
|
187
|
+
c = 1;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
s.textContent = C (d);
|
192
|
+
|
193
|
+
E (td, d);
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
s.colSpan = c - 1;
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
let e = tr0.insertCell (0);
|
202
|
+
|
203
|
+
e.textContent = '前の一週間';
|
204
|
+
|
205
|
+
e.classList.add ('button');
|
206
|
+
|
207
|
+
e.rowSpan = 2;
|
208
|
+
|
209
|
+
this.prev_btn = e;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
e = tr0.insertCell (-1);
|
214
|
+
|
215
|
+
e.textContent = '次の一週間';
|
216
|
+
|
217
|
+
e.classList.add ('button');
|
218
|
+
|
219
|
+
e.rowSpan = 2;
|
220
|
+
|
221
|
+
this.next_btn = e;
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
//__
|
226
|
+
|
227
|
+
let
|
228
|
+
|
229
|
+
begin = new Date (Date.UTC (1970,0,1, 9, 0)),
|
230
|
+
|
231
|
+
end = new Date (Date.UTC (1970,0,1,12, 0)),
|
232
|
+
|
233
|
+
step = new Date (Date.UTC (1970,0,1, 0,30)),
|
234
|
+
|
235
|
+
o = F (this.current),
|
236
|
+
|
237
|
+
rst = [ ];
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
for (let d = begin; d < end; d = new Date (+step + (+d))) {
|
242
|
+
|
243
|
+
let
|
244
|
+
|
245
|
+
a = new Array (this.rangi),
|
246
|
+
|
247
|
+
b = I (d),
|
248
|
+
|
249
|
+
c = this.plan[b] || [];
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
for (let i = 0; i < this.range; i++)
|
254
|
+
|
255
|
+
a[i] = c[o + i] ? '◎': '-';
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
rst.push ([b, ...a, b]);
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
let [tb] = A (t, 'tbody');
|
266
|
+
|
267
|
+
rst.forEach (r => {
|
268
|
+
|
269
|
+
let tr = tb.insertRow (-1);
|
270
|
+
|
271
|
+
r.forEach (c => tr.insertCell (-1).textContent = c)
|
272
|
+
|
273
|
+
});
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
handleEvent ({target: t}) {
|
282
|
+
|
283
|
+
if (t === this.prev_btn) this.add (-this.range);
|
284
|
+
|
285
|
+
if (t === this.next_btn) this.add (this.range);
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
this.Shedule = Shedule;
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
const BUSY = [
|
302
|
+
|
303
|
+
'2019-02-12T10:00',
|
304
|
+
|
305
|
+
'2019-02-12T10:30',
|
306
|
+
|
307
|
+
'2019-02-13T10:00',
|
308
|
+
|
309
|
+
'2019-02-02T10:00',
|
310
|
+
|
311
|
+
'2019-02-02T10:30',
|
312
|
+
|
313
|
+
'2019-02-03T10:00',
|
314
|
+
|
315
|
+
'2019-02-03T10:30',
|
316
|
+
|
317
|
+
'2019-02-09T10:00',
|
318
|
+
|
319
|
+
'2019-02-09T10:30'
|
320
|
+
|
321
|
+
];
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
let c = new Shedule (new Date,7,BUSY), {table: d} = c;
|
326
|
+
|
327
|
+
document.querySelector ('#calendar').appendChild (d);
|
328
|
+
|
329
|
+
d.addEventListener ('click', c, false);
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
</script>
|
334
|
+
|
335
|
+
```
|
336
|
+
|
337
|
+
**大変失礼なことをしてしまい申し訳ございませんでした。**
|
2
質問の変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Javascript:
|
1
|
+
Javascript: コンストラクタとメソッドの違い
|
test
CHANGED
@@ -1,597 +1,7 @@
|
|
1
|
-
###
|
1
|
+
### 質問がアバウト過ぎたので質問を変更いたします。
|
2
|
-
|
3
|
-
他の定休日を決めるtableのtdをクリックした時にカレンダーではその曜日全体が×と表示できるようにしたい。
|
4
2
|
|
5
3
|
|
6
4
|
|
7
|
-
|
5
|
+
javascriptを勉強する中で、コンストラクタとメソッドの違いが分からないのですが、なんのためにコンストラクタがあるのでしょうか?
|
8
6
|
|
9
|
-
![イメージ説明](f9e7626da74585457d32fea881eecc87.png)
|
10
|
-
|
11
|
-
### 発生している問題・エラーメッセージ
|
12
|
-
|
13
|
-
1つずつカレンダーのtdを×と表記させるまではできるが全体をまとめて×と表記させる方法が分からない。
|
14
|
-
|
15
|
-
下記の七つのgetElementByIdをクリックした時に○×判定をできました。
|
16
|
-
|
17
|
-
しかし、判定した結果をcleandarに反映させる方法が分からなくて困っています。
|
18
|
-
|
19
|
-
下記で×マークを挿入しようとしたができなかった。
|
20
|
-
|
21
|
-
```js
|
22
|
-
|
23
|
-
target.closest('tbody') = text; //tbodyに×と挿入しようとしている。
|
24
|
-
|
25
|
-
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
```js
|
30
|
-
|
31
|
-
//monday clicked
|
32
|
-
|
33
|
-
document.getElementById("mon").addEventListener( 'click', function( event ) {
|
34
|
-
|
35
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
36
|
-
|
37
|
-
event.currentTarget.innerText = text;
|
38
|
-
|
39
|
-
target.closest('tbody') = text; //tbodyに×と挿入しようとしている。
|
40
|
-
|
41
|
-
} );
|
42
|
-
|
43
|
-
//tuesday clicked
|
44
|
-
|
45
|
-
document.getElementById("tue").addEventListener( 'click', function( event ) {
|
46
|
-
|
47
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
48
|
-
|
49
|
-
event.currentTarget.innerText = text;
|
50
|
-
|
51
|
-
target.closest('tbody') = text; //tbodyに×と挿入しようとしている。
|
52
|
-
|
53
|
-
} );
|
54
|
-
|
55
|
-
//wednesday clicked
|
56
|
-
|
57
|
-
document.getElementById("wed").addEventListener( 'click', function( event ) {
|
58
|
-
|
59
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
60
|
-
|
61
|
-
event.currentTarget.innerText = text;
|
62
|
-
|
63
|
-
} );
|
64
|
-
|
65
|
-
//thursday clicked
|
66
|
-
|
67
|
-
document.getElementById("thu").addEventListener( 'click', function( event ) {
|
68
|
-
|
69
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
70
|
-
|
71
|
-
event.currentTarget.innerText = text;
|
72
|
-
|
73
|
-
} );
|
74
|
-
|
75
|
-
//Friday clicked
|
76
|
-
|
77
|
-
document.getElementById("fri").addEventListener( 'click', function( event ) {
|
78
|
-
|
79
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
80
|
-
|
81
|
-
event.currentTarget.innerText = text;
|
82
|
-
|
83
|
-
} );
|
84
|
-
|
85
|
-
//saturday clicked
|
86
|
-
|
87
|
-
document.getElementById("sat").addEventListener( 'click', function( event ) {
|
88
|
-
|
89
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
90
|
-
|
91
|
-
event.currentTarget.innerText = text;
|
92
|
-
|
93
|
-
} );
|
94
|
-
|
95
|
-
//sunday clicked
|
96
|
-
|
97
|
-
document.getElementById("sun").addEventListener( 'click', function( event ) {
|
98
|
-
|
99
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
100
|
-
|
101
|
-
event.currentTarget.innerText = text;
|
102
|
-
|
103
|
-
} );
|
104
|
-
|
105
|
-
```
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
### 該当のソースコード
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
```js
|
114
|
-
|
115
|
-
{
|
116
|
-
|
117
|
-
const
|
118
|
-
|
119
|
-
day_name = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
120
|
-
|
121
|
-
day_jname = ['Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'],
|
122
|
-
|
123
|
-
doc = document;
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
const
|
128
|
-
|
129
|
-
A = (e, ...a) => a.map (a => e.appendChild (doc.createElement (a))),
|
130
|
-
|
131
|
-
B = (d, n) => d.setDate (d.getDate () + n),
|
132
|
-
|
133
|
-
C = d => [d.getFullYear (), '年', d.getMonth () + 1 , '月'].join (''),
|
134
|
-
|
135
|
-
D = d => [('0' + d.getHours ()).slice (-2), ('0' + d.getMinutes ()).slice (-2)].join (':'),
|
136
|
-
|
137
|
-
E = (e, d) => {
|
138
|
-
|
139
|
-
let
|
140
|
-
|
141
|
-
[a,,b] = A (e, 'label', 'br', 'label'),
|
142
|
-
|
143
|
-
w = d.getDay () ;
|
144
|
-
|
145
|
-
a.textContent = d.getDate ();
|
146
|
-
|
147
|
-
b.textContent = day_jname[w];
|
148
|
-
|
149
|
-
e.classList.add (day_name[w]);
|
150
|
-
|
151
|
-
},
|
152
|
-
|
153
|
-
F = d => {
|
154
|
-
|
155
|
-
let m = d.getMonth ();
|
156
|
-
|
157
|
-
return [0,31,59,90,120,151,181,212,243,273,304,334][m] + d.getDate() - 1 +
|
158
|
-
|
159
|
-
(new Date (d.getFullYear (), m + 1,0) === 29 && 0 < m);
|
160
|
-
|
161
|
-
},
|
162
|
-
|
163
|
-
G = ary => ary.reduce ((a, b) => {
|
164
|
-
|
165
|
-
let
|
166
|
-
|
167
|
-
|
7
|
+
コンストララクタではメソッドの代わりにはならないにしてもメソッドはコンストラクタの代わりにはなりそうなんですが、わざわざコンストラクタがある意味があるのでしょうか?
|
168
|
-
|
169
|
-
d = D (c);
|
170
|
-
|
171
|
-
if (! (d in a)) a[d] = [];
|
172
|
-
|
173
|
-
a[d][F(c)] = true;
|
174
|
-
|
175
|
-
return a;
|
176
|
-
|
177
|
-
}, { })
|
178
|
-
|
179
|
-
,
|
180
|
-
|
181
|
-
H = d => new Date (d.getFullYear (), d.getMonth (), d.getDate ()),
|
182
|
-
|
183
|
-
I = d => [('0' + d.getUTCHours ()).slice (-2), ('0' + d.getUTCMinutes ()).slice (-2)].join (':')
|
184
|
-
|
185
|
-
;
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
class Shedule {
|
192
|
-
|
193
|
-
constructor (date = new Date, range = 7, plan = []) {
|
194
|
-
|
195
|
-
this.current = H (date);
|
196
|
-
|
197
|
-
this.date = H (date);
|
198
|
-
|
199
|
-
this.range = range;
|
200
|
-
|
201
|
-
this.plan = G (plan);
|
202
|
-
|
203
|
-
this.table = document.createElement ('table');
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
this.remake ();
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
add (day = this.range) {
|
216
|
-
|
217
|
-
let d = H (this.current);
|
218
|
-
|
219
|
-
d.setDate (d.getDate () + day);
|
220
|
-
|
221
|
-
if (+this.date <= +d) {
|
222
|
-
|
223
|
-
this.current = d;
|
224
|
-
|
225
|
-
this.remake ();
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
remake () {
|
236
|
-
|
237
|
-
this.prev_btn = this.next_btn = null;
|
238
|
-
|
239
|
-
let t = this.table;
|
240
|
-
|
241
|
-
[...t.childNodes].forEach (e => e.remove ());
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
let
|
246
|
-
|
247
|
-
h = t.createTHead (),
|
248
|
-
|
249
|
-
tr0 = h.insertRow (-1),
|
250
|
-
|
251
|
-
tr1 = h.insertRow (-1),
|
252
|
-
|
253
|
-
d = H (this.current),
|
254
|
-
|
255
|
-
s = tr0.insertCell (-1),
|
256
|
-
|
257
|
-
c = 1,
|
258
|
-
|
259
|
-
m = d.getMonth ();
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
for (let i = 0; i < this.range; i++, c++, B (d, 1)) {
|
264
|
-
|
265
|
-
let td = tr1.insertCell (-1);
|
266
|
-
|
267
|
-
if (m !== d.getMonth ()) {
|
268
|
-
|
269
|
-
s.colSpan = c - 1;
|
270
|
-
|
271
|
-
s = tr0.insertCell (-1);
|
272
|
-
|
273
|
-
m = d.getMonth ();
|
274
|
-
|
275
|
-
c = 1;
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
s.textContent = C (d);
|
280
|
-
|
281
|
-
E (td, d);
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
s.colSpan = c - 1;
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
let e = tr0.insertCell (0);
|
290
|
-
|
291
|
-
e.textContent = '前の一週間';
|
292
|
-
|
293
|
-
e.classList.add ('button');
|
294
|
-
|
295
|
-
e.rowSpan = 2;
|
296
|
-
|
297
|
-
this.prev_btn = e;
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
e = tr0.insertCell (-1);
|
302
|
-
|
303
|
-
e.textContent = '次の一週間';
|
304
|
-
|
305
|
-
e.classList.add ('button');
|
306
|
-
|
307
|
-
e.rowSpan = 2;
|
308
|
-
|
309
|
-
this.next_btn = e;
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
//start--時間の時と分の分割処理
|
314
|
-
|
315
|
-
var name_start = document.getElementById('sample').value;
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
var result = name_start.substr( 0, 2 );
|
320
|
-
|
321
|
-
var result2 = name_start.substr( 3, 4 );
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
var hour_start = result, minutes_start = result2;
|
326
|
-
|
327
|
-
//---end
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
//finish
|
332
|
-
|
333
|
-
var name_finish = document.getElementById('sample2').value;
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
var result_finish = name_finish.substr( 0, 2 );
|
338
|
-
|
339
|
-
var result2_finish = name_finish.substr( 3, 4 );
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
var hour_end = result_finish, minutes_end = result2_finish;
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
//---end
|
348
|
-
|
349
|
-
let
|
350
|
-
|
351
|
-
begin = new Date (Date.UTC (1970,0,1, hour_start, minutes_start)),//列のスタート時間 //ここをどうにかしたい。
|
352
|
-
|
353
|
-
end = new Date (Date.UTC (1970,0,1, hour_end, minutes_end)),//列の終了時間 //ここをどうにかしたい
|
354
|
-
|
355
|
-
step = new Date (Date.UTC (1970,0,1, 0,30)),//列の感覚調整時間
|
356
|
-
|
357
|
-
o = F (this.current),
|
358
|
-
|
359
|
-
rst = [ ];
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
for (let d = begin; d < end; d = new Date (+step + (+d))) {
|
364
|
-
|
365
|
-
let
|
366
|
-
|
367
|
-
a = new Array (this.rangi),
|
368
|
-
|
369
|
-
b = I (d),
|
370
|
-
|
371
|
-
c = this.plan[b] || [];
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
for (let i = 0; i < this.range; i++)
|
376
|
-
|
377
|
-
a[i] = c[o + i] ? '-' : '◎';
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
rst.push ([b, ...a, b]);
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
let [tb] = A (t, 'tbody');
|
388
|
-
|
389
|
-
rst.forEach (r => {
|
390
|
-
|
391
|
-
let tr = tb.insertRow (-1);
|
392
|
-
|
393
|
-
r.forEach (c => tr.insertCell (-1).textContent = c)
|
394
|
-
|
395
|
-
});
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
handleEvent ({target: t}) {
|
404
|
-
|
405
|
-
if (t === this.prev_btn) this.add (-this.range);
|
406
|
-
|
407
|
-
if (t === this.next_btn) this.add (this.range);
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
}
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
this.Shedule = Shedule;
|
418
|
-
|
419
|
-
}
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
var abc = Array.from(document.getElementsByName('off_date'), x => x.value);
|
424
|
-
|
425
|
-
var bcd = Array.from(document.getElementsByName('off_start'), x => x.value);
|
426
|
-
|
427
|
-
var cde = Array.from(document.getElementsByName('off_finish'), x => x.value);
|
428
|
-
|
429
|
-
console.log(abc + bcd + '~' + cde);//19年02月06日08:00~20:00
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
//ここで○ - の判定をしている
|
434
|
-
|
435
|
-
const BUSY = abc.map((v, i) => abc[i] + bcd[i]); //ここ
|
436
|
-
|
437
|
-
console.log(BUSY);
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
let a = new Shedule (new Date, 14, BUSY), {table: b} = a;
|
446
|
-
|
447
|
-
document.querySelector ('#calendar').appendChild (b);
|
448
|
-
|
449
|
-
b.addEventListener ('click', a, false);
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
var today = new Date();
|
458
|
-
|
459
|
-
var year = today.getFullYear();
|
460
|
-
|
461
|
-
var month = today.getMonth() + 1;
|
462
|
-
|
463
|
-
var day = today.getDate();
|
464
|
-
|
465
|
-
var tds = document.querySelectorAll('td');
|
466
|
-
|
467
|
-
var yobi= new Array("日","月","火","水","木","金","土");
|
468
|
-
|
469
|
-
document.getElementById('acdn-target').value = year+'年'+month+'月'+ day+'日 ';
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
document.querySelector('#calendar').addEventListener('click', event => {
|
476
|
-
|
477
|
-
const target = event.target;
|
478
|
-
|
479
|
-
if (target.nodeName.toLowerCase() !== 'td') {
|
480
|
-
|
481
|
-
return true;
|
482
|
-
|
483
|
-
}
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
if (!(target.closest('tbody') && 1 <= target.cellIndex && target.cellIndex <= 14)) {
|
488
|
-
|
489
|
-
return true;
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
const time = target.parentNode.cells[0].textContent;
|
496
|
-
|
497
|
-
const table = target.closest('table');
|
498
|
-
|
499
|
-
const date = table.tHead.rows[1].cells[target.cellIndex - 1].textContent.slice(0,-4);
|
500
|
-
|
501
|
-
const ymrow = table.tHead.rows[0];
|
502
|
-
|
503
|
-
const ym = (target.cellIndex <= ymrow.cells[1].colSpan ? ymrow.cells[1] : ymrow.cells[2]).textContent;
|
504
|
-
|
505
|
-
document.getElementById('acdn-target').value = ym + date + '日' + time;
|
506
|
-
|
507
|
-
return true;
|
508
|
-
|
509
|
-
}, false);
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
//monday clicked
|
514
|
-
|
515
|
-
document.getElementById("mon").addEventListener( 'click', function( event ) {
|
516
|
-
|
517
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
518
|
-
|
519
|
-
event.currentTarget.innerText = text;
|
520
|
-
|
521
|
-
} );
|
522
|
-
|
523
|
-
//tuesday clicked
|
524
|
-
|
525
|
-
document.getElementById("tue").addEventListener( 'click', function( event ) {
|
526
|
-
|
527
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
528
|
-
|
529
|
-
event.currentTarget.innerText = text;
|
530
|
-
|
531
|
-
} );
|
532
|
-
|
533
|
-
//wednesday clicked
|
534
|
-
|
535
|
-
document.getElementById("wed").addEventListener( 'click', function( event ) {
|
536
|
-
|
537
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
538
|
-
|
539
|
-
event.currentTarget.innerText = text;
|
540
|
-
|
541
|
-
} );
|
542
|
-
|
543
|
-
//thursday clicked
|
544
|
-
|
545
|
-
document.getElementById("thu").addEventListener( 'click', function( event ) {
|
546
|
-
|
547
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
548
|
-
|
549
|
-
event.currentTarget.innerText = text;
|
550
|
-
|
551
|
-
} );
|
552
|
-
|
553
|
-
//Friday clicked
|
554
|
-
|
555
|
-
document.getElementById("fri").addEventListener( 'click', function( event ) {
|
556
|
-
|
557
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
558
|
-
|
559
|
-
event.currentTarget.innerText = text;
|
560
|
-
|
561
|
-
} );
|
562
|
-
|
563
|
-
//saturday clicked
|
564
|
-
|
565
|
-
document.getElementById("sat").addEventListener( 'click', function( event ) {
|
566
|
-
|
567
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
568
|
-
|
569
|
-
event.currentTarget.innerText = text;
|
570
|
-
|
571
|
-
} );
|
572
|
-
|
573
|
-
//sunday clicked
|
574
|
-
|
575
|
-
document.getElementById("sun").addEventListener( 'click', function( event ) {
|
576
|
-
|
577
|
-
var text = ( event.currentTarget.innerText === '○' ) ? '×' : '○';
|
578
|
-
|
579
|
-
event.currentTarget.innerText = text;
|
580
|
-
|
581
|
-
} );
|
582
|
-
|
583
|
-
```
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
### 補足情報(FW/ツールのバージョンなど)
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
```ruby on rails``` ```javascript```
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
### 追記
|
596
|
-
|
597
|
-
id [mon]をクリックした時にカレンダー内の月曜日の縦列のtd全てを×と表示させたいです。
|
1
質問の意図の説明
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
他の定休日を決めるtableのtdをクリックした時にカレンダーではその曜日全体が×と表示できるようにしたい。
|
4
4
|
|
5
|
+
|
6
|
+
|
5
7
|
![イメージ説明](b7c149f6872ee2584e936fcbf716b1dd.png)
|
6
8
|
|
7
9
|
![イメージ説明](f9e7626da74585457d32fea881eecc87.png)
|
@@ -587,3 +589,9 @@
|
|
587
589
|
|
588
590
|
|
589
591
|
```ruby on rails``` ```javascript```
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
### 追記
|
596
|
+
|
597
|
+
id [mon]をクリックした時にカレンダー内の月曜日の縦列のtd全てを×と表示させたいです。
|