forked from khushi-joshi-05/Food-ordering-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
69 lines (57 loc) · 1.9 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
document.getElementById("copyright-year").textContent =
new Date().getFullYear();
window.addEventListener("beforeunload", function (event) {
localStorage.clear();
});
document.addEventListener("DOMContentLoaded", function () {
setTimeout(function () {
document.querySelector("body").classList.add("loaded");
}, 500);
});
document.addEventListener('DOMContentLoaded', () => {
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
item.querySelector('h2').addEventListener('click', () => {
// Close all other items
faqItems.forEach(otherItem => {
if (otherItem !== item) {
otherItem.classList.remove('active');
const otherContent = otherItem.querySelector('p');
otherContent.style.maxHeight = 0;
otherContent.style.opacity = 0;
}
});
// Toggle the clicked item
item.classList.toggle('active');
const content = item.querySelector('p');
if (item.classList.contains('active')) {
content.style.maxHeight = content.scrollHeight + 'px';
content.style.opacity = 1;
} else {
content.style.maxHeight = 0;
content.style.opacity = 0;
}
});
});
});
/*Refresher*/
document.addEventListener('DOMContentLoaded', function() {
const caduceus = document.getElementById('caduceus');
caduceus.addEventListener('mouseover', function() {
location.reload();
});
});
function getVisitorCount() {
return localStorage.getItem('visitorCount') || 0;
}
function incrementVisitorCount() {
let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);
return count;
}
function displayVisitorCount() {
const counterElement = document.querySelector('.website-counter');
const count = incrementVisitorCount();
counterElement.textContent = count;
}
document.addEventListener('DOMContentLoaded', displayVisitorCount);