forked from shaun099/PACE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.js
133 lines (114 loc) · 3.21 KB
/
module.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
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.2.0/firebase-app.js";
import {
getAuth,
signOut,
} from "https://www.gstatic.com/firebasejs/11.2.0/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyCsY1X-dFMumMntR74GF86Otx-VEYKZzIE",
authDomain: "pace-52f35.firebaseapp.com",
projectId: "pace-52f35",
storageBucket: "pace-52f35.appspot.com",
messagingSenderId: "630887135858",
appId: "1:630887135858:web:317de71e655d58276e60eb",
measurementId: "G-G4QFKJZFRB",
};
const app = initializeApp(firebaseConfig);
const auth = getAuth();
const logOut = document.getElementById("Logout");
logOut.addEventListener("click", () => {
signOut(auth)
.then(() => {
console.log("logged out");
localStorage.clear();
sessionStorage.clear();
window.location.href = "index.html";
})
.catch((error) => {
console.log("error", error);
});
});
const sidebarToggler = document.getElementById("sidebarToggler");
const sideBar = document.querySelector(".sidebar");
// Toggle the sidebar and icons
sidebarToggler.addEventListener("click", () => {
sideBar.classList.toggle("hidden"); // Show/hide the sidebar
sideBar.classList.add("w-64"); // Ensure sidebar has a width
// Toggle the icons
if (sidebarToggler.classList.contains("ri-menu-2-line")) {
sidebarToggler.classList.remove("ri-menu-2-line");
sidebarToggler.classList.add("ri-close-line");
} else {
sidebarToggler.classList.remove("ri-close-line");
sidebarToggler.classList.add("ri-menu-2-line");
}
});
const moduleLinks = [
"mod1-link",
"mod2-link",
"mod3-link",
"mod4-link",
"mod5-link",
"mod6-link",
"mod7-link",
];
const bodySections = [
"mod1",
"mod2",
"mod3",
"mod4",
"mod5",
"mod6",
"mod7",
"mod8",
"profileBody",
"settingsBody",
"opening-pg",
];
// page management
const profile = document.getElementById("Profile");
const settings = document.getElementById("Settings");
const hideAllSections = () => {
bodySections.forEach((sectionId) => {
const section = document.getElementById(sectionId);
if (section) section.classList.add("hidden");
});
};
const showSection = (sectionId) => {
const section = document.getElementById(sectionId);
if (section) section.classList.remove("hidden");
};
moduleLinks.forEach((linkId, index) => {
const link = document.getElementById(linkId);
if (link) {
link.addEventListener("click", () => {
hideAllSections();
showSection(`mod${index + 1}`);
});
}
});
profile.addEventListener("click", () => {
hideAllSections();
showSection("profileBody");
});
settings.addEventListener("click", () => {
hideAllSections();
showSection("settingsBody");
});
// logOut.addEventListener("click", () => {
// hideAllSections();
// showSection("logoutBody");
// });
// ------------
const sidebar = document.querySelector(".sidebar");
const sidebarTitle = document.querySelectorAll(".sidebarTitle");
// Add hover event listeners to toggle title visibility
sidebar.addEventListener("mouseover", () => {
sidebarTitle.forEach((title) => {
title.classList.remove("hidden");
});
});
sidebar.addEventListener("mouseout", () => {
sidebarTitle.forEach((title) => {
title.classList.add("hidden");
});
});