-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.js
More file actions
79 lines (66 loc) · 2.6 KB
/
profile.js
File metadata and controls
79 lines (66 loc) · 2.6 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
78
79
// Profile page specific JavaScript
document.addEventListener("DOMContentLoaded", () => {
// Tab functionality
const tabBtns = document.querySelectorAll(".tab-btn")
const tabContents = document.querySelectorAll(".tab-content")
tabBtns.forEach((btn) => {
btn.addEventListener("click", function () {
const targetTab = this.getAttribute("data-tab")
// Remove active class from all tabs and contents
tabBtns.forEach((b) => b.classList.remove("active"))
tabContents.forEach((c) => c.classList.remove("active"))
// Add active class to clicked tab and corresponding content
this.classList.add("active")
const targetContent = document.getElementById(targetTab + "-tab")
if (targetContent) {
targetContent.classList.add("active")
}
})
})
// Animate progress bars
const progressBars = document.querySelectorAll(".progress-fill")
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const progressBar = entry.target
const width = progressBar.style.width
progressBar.style.width = "0%"
setTimeout(() => {
progressBar.style.width = width
}, 100)
}
})
})
progressBars.forEach((bar) => observer.observe(bar))
// Handle club management buttons
document.addEventListener("click", (e) => {
if (e.target.textContent === "Manage") {
window.showNotification("Club management panel opened!", "info")
} else if (e.target.textContent === "View Club") {
window.showNotification("Redirecting to club page...", "info")
}
})
// Theme Toggle Functionality
const themeToggle = document.getElementById("themeToggle")
const themeIcon = themeToggle.querySelector("i")
// Check for saved theme preference
const savedTheme = localStorage.getItem("theme") || "light"
document.documentElement.setAttribute("data-theme", savedTheme)
updateThemeIcon(savedTheme)
// Theme toggle click handler
themeToggle.addEventListener("click", () => {
const currentTheme = document.documentElement.getAttribute("data-theme")
const newTheme = currentTheme === "light" ? "dark" : "light"
document.documentElement.setAttribute("data-theme", newTheme)
localStorage.setItem("theme", newTheme)
updateThemeIcon(newTheme)
})
// Update theme icon based on current theme
function updateThemeIcon(theme) {
themeIcon.className = theme === "light" ? "fas fa-moon" : "fas fa-sun"
}
})
// Declare showNotification function
function showNotification(message, type) {
console.log(`Notification (${type}): ${message}`)
}