-
-
Notifications
You must be signed in to change notification settings - Fork 431
/
new.js
157 lines (134 loc) · 4.72 KB
/
new.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Function to initialize theme based on localStorage
function initializeTheme() {
const body = document.body;
const toggleButton = document.getElementById("theme-toggle");
const currentTheme = localStorage.getItem("theme");
// Apply saved theme
if (currentTheme === "dark") {
body.classList.add("dark-mode");
toggleButton.classList.add("dark");
toggleButton.querySelector("span").textContent = "🌙"; // Dark mode icon
} else {
toggleButton.querySelector("span").textContent = "🌞"; // Light mode icon
}
}
// Call initializeTheme on page load
document.addEventListener("DOMContentLoaded", () => {
initializeTheme();
const toggleButton = document.getElementById("theme-toggle");
const body = document.body;
// Event listener for theme toggle
toggleButton.addEventListener("click", () => {
body.classList.toggle("dark-mode");
toggleButton.classList.toggle("dark");
// Update icon and save theme
if (body.classList.contains("dark-mode")) {
toggleButton.querySelector("span").textContent = "🌙"; // Dark mode icon
localStorage.setItem("theme", "dark");
} else {
toggleButton.querySelector("span").textContent = "🌞"; // Light mode icon
localStorage.setItem("theme", "light");
}
loadShow(); // Call any additional function if needed
});
});
// Function placeholder for additional operations (if needed)
function loadShow() {
// Additional actions can go here
}
function filterFAQs() {
const searchInput = document
.getElementById("faq-search-input")
.value.toLowerCase();
const faqs = document.querySelectorAll(".accordion-item");
faqs.forEach((faq) => {
const question = faq
.querySelector(".accordion-button")
.textContent.toLowerCase();
const answer = faq
.querySelector(".accordion-body")
.textContent.toLowerCase();
// Display the FAQ item only if the search term matches either the question or answer
if (question.includes(searchInput) || answer.includes(searchInput)) {
faq.style.display = "block";
} else {
faq.style.display = "none";
}
});
}
// Function for the contributors section
const owner = "ayush-that";
const repo = "FinVeda";
const contributorsPerPage = 8;
let contributors = [];
let currentPage = 1;
async function fetchContributors() {
const response = await fetch(
`https://api.github.com/repos/${owner}/${repo}/contributors`
);
if (!response.ok) {
console.error("Failed to fetch contributors:", response.statusText);
return;
}
contributors = await response.json();
displayContributors();
createPaginationButtons();
}
function displayContributors() {
const container = document.getElementById("contributor-cards");
container.innerHTML = "";
const start = (currentPage - 1) * contributorsPerPage;
const end = start + contributorsPerPage;
const currentContributors = contributors.slice(start, end);
currentContributors.forEach((contributor) => {
const card = document.createElement("div");
card.className = "contributor-member";
card.setAttribute("data-tilt", "");
const img = document.createElement("img");
img.src = contributor.avatar_url;
img.alt = contributor.login;
const name = document.createElement("h3");
name.textContent = contributor.login;
const contributions = document.createElement("p");
contributions.textContent = `${contributor.contributions} contributions`;
const viewProfileButton = document.createElement("button");
viewProfileButton.textContent = "View Profile";
viewProfileButton.addEventListener("click", () => {
window.open(contributor.html_url, "_blank");
});
card.appendChild(img);
card.appendChild(name);
card.appendChild(contributions);
container.appendChild(card);
card.appendChild(viewProfileButton);
});
}
function createPaginationButtons() {
const paginationContainer = document.getElementById("pagination");
paginationContainer.innerHTML = "";
const totalPages = Math.ceil(contributors.length / contributorsPerPage);
for (let i = 1; i <= totalPages; i++) {
const button = document.createElement("button");
button.textContent = i;
button.classList.add("pagination-button");
if (i === currentPage) {
button.classList.add("active");
}
button.addEventListener("click", () => {
currentPage = i;
displayContributors();
updatePaginationButtons();
});
paginationContainer.appendChild(button);
}
}
function updatePaginationButtons() {
const buttons = document.querySelectorAll(".pagination-button");
buttons.forEach((button) => {
button.classList.remove("active");
if (parseInt(button.textContent) === currentPage) {
button.classList.add("active");
}
});
}
fetchContributors();