-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscripts.js
133 lines (109 loc) · 3.87 KB
/
scripts.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
document.addEventListener("DOMContentLoaded", () => {
const darkModeToggle = document.getElementById("darkModeToggle")
const body = document.body
const navToggle = document.querySelector(".nav-toggle")
const navLinks = document.querySelector(".nav-links")
const mainTitle = document.getElementById("mainTitle")
const joinForm = document.getElementById("join-form")
const slideshows = document.querySelectorAll(".event-slideshow")
slideshows.forEach((slideshow) => {
const slides = slideshow.querySelectorAll(".slide")
let currentSlide = 0
function showSlide(index) {
currentSlide = (index + slides.length) % slides.length
slides.forEach((slide, i) => {
slide.style.display = i === currentSlide ? "block" : "none"
})
}
showSlide(currentSlide)
const prevButton = slideshow.querySelector(".prev")
const nextButton = slideshow.querySelector(".next")
if (prevButton) {
prevButton.addEventListener("click", () => {
showSlide(currentSlide - 1)
})
}
if (nextButton) {
nextButton.addEventListener("click", () => {
showSlide(currentSlide + 1)
})
}
})
darkModeToggle.addEventListener("click", () => {
body.classList.toggle("light-mode")
const isLightMode = body.classList.contains("light-mode")
localStorage.setItem("lightMode", isLightMode)
updateModeIcon(isLightMode)
})
const savedLightMode = localStorage.getItem("lightMode")
if (savedLightMode === "true") {
body.classList.add("light-mode")
updateModeIcon(true)
}
function updateModeIcon(isLightMode) {
const icon = darkModeToggle.querySelector("i")
icon.className = isLightMode ? "fas fa-sun" : "fas fa-moon"
}
navToggle.addEventListener("click", () => {
navLinks.classList.toggle("active")
})
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault()
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
})
})
})
mainTitle.addEventListener("mouseover", glitchEffect)
function glitchEffect() {
const glitchText = "Welcome to The FOSS Club!"
const glitchChars = "!<>-_\\/[]{}—=+*^?#________"
let iterations = 0
const interval = setInterval(() => {
mainTitle.textContent = glitchText
.split("")
.map((char, index) => {
if (index < iterations) {
return glitchText[index]
}
return glitchChars[Math.floor(Math.random() * glitchChars.length)]
})
.join("")
if (iterations >= glitchText.length) {
clearInterval(interval)
mainTitle.textContent = glitchText
}
iterations += 1 / 3
}, 30)
}
if (joinForm) {
joinForm.addEventListener("submit", (e) => {
e.preventDefault()
alert("Thanks for your interest! We'll get back to you soon.")
joinForm.reset()
})
}
const animateOnScroll = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("animate")
}
})
},
{ threshold: 0.1 },
)
document
.querySelectorAll(".project-card, .event-card,.event-slideshow .blog-post, .tool-card, .member-card")
.forEach((el) => {
animateOnScroll.observe(el)
})
const sectionTitles = document.querySelectorAll(".section-title")
sectionTitles.forEach((title) => {
title.addEventListener("click", () => {
const memberGrid = title.nextElementSibling
memberGrid.classList.toggle("hidden")
})
})
})