-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
83 lines (72 loc) · 2.63 KB
/
script.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
// Burger menus
document.addEventListener('DOMContentLoaded', function() {
// open
const burger = document.querySelectorAll('.navbar-burger');
const menu = document.querySelectorAll('.navbar-menu');
if (burger.length && menu.length) {
for (var i = 0; i < burger.length; i++) {
burger[i].addEventListener('click', function() {
for (var j = 0; j < menu.length; j++) {
menu[j].classList.toggle('hidden');
}
});
}
}
// close
const close = document.querySelectorAll('.navbar-close');
const backdrop = document.querySelectorAll('.navbar-backdrop');
if (close.length) {
for (var i = 0; i < close.length; i++) {
close[i].addEventListener('click', function() {
for (var j = 0; j < menu.length; j++) {
menu[j].classList.toggle('hidden');
}
});
}
}
if (backdrop.length) {
for (var i = 0; i < backdrop.length; i++) {
backdrop[i].addEventListener('click', function() {
for (var j = 0; j < menu.length; j++) {
menu[j].classList.toggle('hidden');
}
});
}
}
const opClose = document.querySelectorAll('.op-close');
if (opClose.length) {
for (var i = 0; i < opClose.length; i++) {
opClose[i].addEventListener('click', function() {
for (var j = 0; j < menu.length; j++) {
menu[j].classList.toggle('hidden');
}
});
}
}
function checkOpen(){
const data = new Date();
return data.getHours() >= 8 && data.getHours() < 18;
}
function daySunday(){ //checking sunday
const data = new Date();
return data.getDay() == 0;
}
const divDateOpen = document.getElementById("div-date-open");
if(checkOpen() && !daySunday()) {
divDateOpen.classList.remove("bg-red-600");
divDateOpen.classList.add("bg-green-600");
}else{
divDateOpen.classList.remove("bg-green-600");
divDateOpen.classList.add("bg-red-600");
}
// tests
// When the user scrolls down 50px from the top of the document, resize the header's font size
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if(document.body.scrollTop > 50 || document.documentElement.scrollTop > 50){
document.getElementById("nav-header").style.background = "#18181b";
}else{
document.getElementById("nav-header").style.background = "transparent";
}
}
});