-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
166 lines (143 loc) · 3.51 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
function showDate() {
var dateToday = document.querySelector(".date-today");
var data = new Date();
var day = data.getDay();
var daymonth = data.getDate();
var month = data.getMonth();
var hrs = data.getHours();
var minutes = data.getMinutes();
switch (day) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
}
switch (month) {
case 0:
month = "January";
break;
case 1:
month = "february";
break;
case 2:
month = "March";
break;
case 3:
month = "April";
break;
case 4:
month = "May";
break;
case 5:
month = "June";
break;
case 6:
month = "July";
break;
case 7:
month = "August";
break;
case 8:
month = "Septembar";
break;
case 9:
month = "Octobar";
break;
case 10:
month = "Novembar";
break;
case 11:
month = "December";
break;
}
function hrsFixed() {
if (hrs == "0") {
hrs += "0";
}
}
hrsFixed();
dateToday.innerHTML =
day + ", " + month + " " + daymonth + "th" + ", " + hrs + "h:" + minutes;
function Aberto() {
var openClose = document.querySelector("#now-open");
var time = document.querySelector(".time-missing");
("#now-open");
if (day != "Thrusday" && hrs >= 16) {
openClose.innerHTML = "Now open";
time.innerHTML = "Closes at 11:30";
} else {
openClose.innerHTML = "Closed now";
if (day == "Thrusday") {
time.innerHTML = "Opens at 4pm tomorrow";
} else {
time.innerHTML = "Opens at 4pm today";
}
}
}
Aberto();
}
setInterval(showDate, 1000);
function menus() {
var btnMenu = document.querySelectorAll(".btns-menu button");
var menu = document.querySelectorAll(".container-menu .menus");
function activeMenu(index) {
menu.forEach((menu) => {
menu.classList.remove("menu-active");
});
btnMenu.forEach((menu) => {
menu.classList.remove("btn-menu-active");
});
menu[index].classList.add("menu-active");
btnMenu[index].classList.add("btn-menu-active");
}
btnMenu.forEach((itemMenu, index) => {
itemMenu.addEventListener("click", () => {
activeMenu(index);
});
});
}
menus();
/* header change color */
function headerScroll() {
var header = document.querySelector("header");
var headerTop = header.getBoundingClientRect().top;
if (headerTop <= 0) {
header.classList.add("header-scroll");
} else {
header.classList.remove("header-scroll");
}
}
window.addEventListener("scroll", headerScroll);
/* menu mobile */
var btnMobile = document.querySelector("#btn-menu");
var headerMobile = document.querySelector(".header-down .container");
function menuMobile(event) {
if (event.type === "touchstart") event.preventDefault();
headerMobile.classList.toggle("header-mobile-active");
var active = headerMobile.classList.contains("header-mobile-active");
event.currentTarget.setAttribute("aria-expanded", active);
if (active) {
event.currentTarget.setAttribute("aria-label", "Close menu");
} else {
event.currentTarget.setAttribute("aria-label", "Open menu");
}
}
btnMobile.addEventListener("click", menuMobile);
btnMobile.addEventListener("touchstart", menuMobile);