-
Notifications
You must be signed in to change notification settings - Fork 0
/
fmw.js
94 lines (66 loc) · 2.76 KB
/
fmw.js
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
window.addEventListener('DOMContentLoaded', (event) => {
let fmwaclose = document.querySelector('#fmwaclose');
let fmwapr = document.querySelector('#fmwapr');
let fmwaopen = document.querySelector('#fmwaopen');
// when fmwaclose is clicked, add class inactive to fmwapr
fmwaclose.addEventListener('click', (event) => {
fmwapr.classList.add('inactive');
// remove class active from fmwapr
fmwapr.classList.remove('active');
// add class inactive to this
fmwaclose.classList.add('inactive');
// add class active to fmwaopen
fmwaopen.classList.remove('inactive');
fmwaopen.classList.add('active');
});
// when fmwaopen is clicked, remove class inactive from fmwapr
fmwaopen.addEventListener('click', (event) => {
fmwapr.classList.remove('inactive');
// add class active to fmwapr
fmwapr.classList.add('active');
// remove class inactive from this
fmwaopen.classList.remove('inactive');
// add class inactive to fmwaopen
fmwaopen.classList.add('inactive');
// add class active to fmwaclose
fmwaclose.classList.remove('inactive');
fmwaclose.classList.add('active');
});
jQuery(function () {
callAction();
whatsappAction();
// call action
function callAction() {
jQuery('.fmcallbg').click(function () {
let dataCall = 'tel:+' + jQuery(this).attr('data-call');
window.open(dataCall);
});
}
// whatsapp action
function whatsappAction() {
jQuery('.fmwabg').click(function () {
let dataWhatsapp = 'https://wa.me/' + jQuery(this).attr('data-wa');
window.open(dataWhatsapp);
});
}
/*=========================days=========================*/
// get day today in Indonesia
var fmwaitem = jQuery('.fmwaitem');
// note: attribute data-schedule-days is array seperated by comma.
// get attribute data-current-day and data-schedule-days from each fmwaitem.
fmwaitem.each(function () {
var currentDay = jQuery(this).attr('data-current-day');
var scheduleDays = jQuery(this).attr('data-schedule-days');
var scheduleDaysArray = scheduleDays.split(',');
// check if currentDay is in scheduleDaysArray
if (scheduleDaysArray.includes(currentDay)) {
// if true, add class active to this
jQuery(this).addClass('active');
} else {
// if false, add class inactive to this
// jQuery(this).addClass('inactive');
jQuery(this).remove();
}
});
});
});