-
Notifications
You must be signed in to change notification settings - Fork 39
/
script.js
124 lines (99 loc) · 4 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
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('registration-form');
form.addEventListener('submit', (e) => {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const event = document.getElementById('event').value;
// console.log(name + " " + email +" "+ event);
if (name && email && event) {
// alert("hello world");
alert(`Thank you for registering, ${name}! You've signed up for the ${event}.`);
form.reset();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
alert('Please fill out all fields.');
}
});
window.onscroll = function() {
const button = document.getElementById('backToTop');
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
button.style.display = "block";
} else {
button.style.display = "none";
}
};
document.getElementById('backToTop').addEventListener('click', function() {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
const themeToggle = document.getElementById('theme-toggle');
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
const navLinks = document.querySelector('.nav-links');
const body = document.body;
// Theme toggle functionality
themeToggle.addEventListener('click', () => {
body.classList.toggle('dark-mode');
updateThemeIcon();
localStorage.setItem('darkMode', body.classList.contains('dark-mode'));
});
// Check for saved user preference
const darkModeEnabled = localStorage.getItem('darkMode') === 'true';
if (darkModeEnabled) {
body.classList.add('dark-mode');
}
updateThemeIcon();
function updateThemeIcon() {
const icon = themeToggle.querySelector('i');
if (body.classList.contains('dark-mode')) {
icon.classList.remove('fa-moon');
icon.classList.add('fa-sun');
} else {
icon.classList.remove('fa-sun');
icon.classList.add('fa-moon');
}
}
// Mobile menu toggle
mobileMenuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
mobileMenuToggle.classList.toggle('active');
});
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Close mobile menu if open
navLinks.classList.remove('active');
mobileMenuToggle.classList.remove('active');
}
});
});
// Intersection Observer for fade-in animations
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.about, .schedule, .register').forEach(section => {
observer.observe(section);
});
});
document.addEventListener("mousemove", function (e) {
const follower = document.getElementById("mouseFollower");
// Move the follower div to the mouse position
follower.style.left = `${e.clientX}px`;
follower.style.top = `${e.clientY}px`;
});