-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhartplan.js
More file actions
77 lines (59 loc) · 2.11 KB
/
hartplan.js
File metadata and controls
77 lines (59 loc) · 2.11 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
const hamburger = document.getElementById('hamburger');
const dropdownMenu = document.getElementById('dropdown-menu');
const toggleMenu = () => {
if (dropdownMenu.style.display === 'block') {
dropdownMenu.style.display = 'none';
} else {
dropdownMenu.style.display = 'block';
}
};
const checkWidth = () => {
if (window.innerWidth > 768) {
dropdownMenu.style.display = 'none';
}
};
hamburger.addEventListener('click', toggleMenu);
window.addEventListener('resize', checkWidth);
// Close the dropdown if the user clicks outside of it
window.addEventListener('click', (event) => {
if (!event.target.matches('#hamburger')) {
if (dropdownMenu.style.display === 'block') {
dropdownMenu.style.display = 'none';
}
}
});
// home page background image change
const backgrounds = [
'url("images/Homepage.jpg")',
'url("images/pexels-19x14-8478237.jpg")',
'url("images/pexels-anastasia-shuraeva-8470886.jpg ")'
];
const headings = [
'Welcome to Hartplan',
'Explore Our services',
'Join Us Today'
];
const texts = [
'Find out what makes us unique.',
'Discover our amazing services and offers.',
'Get in touch to learn more about us.'
];
const buttons = [
{ text: 'Learn More', href: './hartplan.html' },
{ text: 'View Services', href: './services.html' },
{ text: 'Contact Us', href: './contactus.html' }
];
let currentIndex = 0;
function switchContent() {
currentIndex = (currentIndex + 1) % backgrounds.length;
document.getElementById('background').style.backgroundImage = backgrounds[currentIndex];
document.getElementById('heading').textContent = headings[currentIndex];
document.getElementById('text').textContent = texts[currentIndex];
const button = document.getElementById('button');
button.textContent = buttons[currentIndex].text;
button.href = buttons[currentIndex].href;
}
// Switch content every 5 seconds
setInterval(switchContent, 5000); // 5000 milliseconds = 5 seconds
// Initial load
switchContent();