-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfront.js
More file actions
86 lines (81 loc) · 2.73 KB
/
front.js
File metadata and controls
86 lines (81 loc) · 2.73 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
jQuery(document).ready(function($){
// コマ
$("table.edit_schedule tr.valid>td.status").on("click", function() {
if(!$(this).hasClass('past')){
if($(this).hasClass('open')){
$(this).removeClass('open');
$(this).addClass('closed');
$(this).children('input[name^="new"]').val('close');
}
else if($(this).hasClass('closed')){
$(this).removeClass('closed');
$(this).addClass('open');
$(this).children('input[name^="new"]').val('open');
}
}
})
// 曜日
$("table.edit_schedule tr.head>th").on("click", function() {
var wname = $(this).attr('class');
var opened = $('tr.valid>td').filter('.'+wname).filter('.open');
var closed = $('tr.valid>td').filter('.'+wname).filter('.closed').filter(function(index){
if(!$(this).hasClass('past')){
return true;
}
});
if(opened.length == 0 || (closed.length != 0 && closed.length < opened.length)){
$(closed).removeClass('closed');
$(closed).addClass('open');
$(closed).children('input[name^="new"]').val('open');
}
else {
$(opened).removeClass('open');
$(opened).addClass('closed');
$(opened).children('input[name^="new"]').val('close');
}
})
// 時間
$("table.edit_schedule tr.valid>.times").on("click", function() {
var opened = $(this).parent().children('td').filter('.open');
var closed = $(this).parent().children('td').filter('.closed').filter(function(index){
if(!$(this).hasClass('past')){
return true;
}
});
if(opened.length == 0 || (closed.length != 0 && closed.length < opened.length)){
$(closed).removeClass('closed');
$(closed).addClass('open');
$(closed).children('input[name^="new"]').val('open');
}
else {
$(opened).removeClass('open');
$(opened).addClass('closed');
$(opened).children('input[name^="new"]').val('close');
}
})
/* Update by URANI */
var date_time_arr = []
var room_arr = []
$(".reserve_slot").click(function(e) {
$(this).toggleClass('active');
$(this).parent().toggleClass('active');
if($(e.target).hasClass('active')) {
date_time_arr.push($(this).attr('data-date-time'));
if(!room_arr.includes($(this).attr('data-room'))) {
room_arr.push($(this).attr('data-room'));
}
$(".item_select").text(date_time_arr.join(" / "));
}
else {
date_time_arr = date_time_arr.filter(e => e !== $(this).attr('data-date-time'))
$(".item_select").text( date_time_arr.join(" / "));
}
})
$(".booking_btn").click(function() {
if(Array.isArray(date_time_arr) && date_time_arr.length) {
$dates = date_time_arr.join(",");
$room_id = room_arr.join(",");
window.location.href = `${window.location.origin}/booking/reservation/?t=${$dates}&room_id=${$room_id}`
}
})
})