forked from dhairyagothi/100_days_100_web_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
397 lines (352 loc) · 18.6 KB
/
Copy pathindex.js
File metadata and controls
397 lines (352 loc) · 18.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
if (typeof REPO_OWNER === 'undefined') {
window.REPO_OWNER = "dhairyagothi";
window.REPO_NAME = "100_days_100_web_project";
}
async function fetchRepoStats() {
try {
const [repoRes, prRes] = await Promise.all([
fetch(`https://api.github.com/repos/${window.REPO_OWNER}/${window.REPO_NAME}`),
fetch(`https://api.github.com/search/issues?q=repo:${window.REPO_OWNER}/${window.REPO_NAME}+type:pr+state:open`)
]);
if (!repoRes.ok || !prRes.ok) throw new Error("Stats fetch failed");
const repoData = await repoRes.json();
const prData = await prRes.json();
const starEl = document.getElementById('starCount');
const forkEl = document.getElementById('forkCount');
const issueEl = document.getElementById('issueCount');
const prEl = document.getElementById('prCount');
if (starEl) starEl.textContent = repoData.stargazers_count.toLocaleString();
if (forkEl) forkEl.textContent = repoData.forks_count.toLocaleString();
if (issueEl) issueEl.textContent = (repoData.open_issues_count - prData.total_count).toLocaleString();
if (prEl) prEl.textContent = prData.total_count.toLocaleString();
} catch (error) {
console.error("Error fetching repo stats:", error);
}
}
// Canvas Background Animation
function initCanvas() {
const canvas = document.getElementById('bgCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const particles = [];
const particleCount = 100;
class Particle {
constructor() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.vx = (Math.random() - 0.5) * 0.5;
this.vy = (Math.random() - 0.5) * 0.5;
this.size = Math.random() * 2 + 1;
}
update() {
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
}
draw() {
const isDark = !document.body.classList.contains('light-mode');
const alpha = isDark ? Math.random() * 0.5 + 0.2 : Math.random() * 0.3 + 0.1;
ctx.fillStyle = `rgba(26, 188, 156, ${alpha})`;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
}
}
for (let i = 0; i < particleCount; i++) {
particles.push(new Particle());
}
function animate() {
const isDark = !document.body.classList.contains('light-mode');
ctx.fillStyle = isDark ? 'rgba(10, 10, 10, 0.1)' : 'rgba(245, 245, 245, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
particles.forEach(p => {
p.update();
p.draw();
});
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 100) {
const alpha = isDark ? 0.2 * (1 - dist / 100) : 0.1 * (1 - dist / 100);
ctx.strokeStyle = `rgba(26, 188, 156, ${alpha})`;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.stroke();
}
}
}
requestAnimationFrame(animate);
}
animate();
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
}
// Theme Toggle Functionality
const themeToggle = document.getElementById('themeToggle');
const themeIcon = themeToggle.querySelector('i');
// Check for saved theme preference or default to dark mode
const currentTheme = window.theme || 'dark';
if (currentTheme === 'light') {
document.body.classList.add('light-mode');
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
}
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('light-mode');
if (document.body.classList.contains('light-mode')) {
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
window.theme = 'light';
} else {
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
window.theme = 'dark';
}
});
// Update Navbar for Login Status
const buttons = document.getElementsByClassName('buttons')[0];
function updateNavbar() {
const username = window.username || null;
const isRoot = !window.location.pathname.includes('/contributors/');
const basePath = isRoot ? '' : '../';
const themeButton = `
<button id="themeToggle" class="button" title="Toggle Theme">
<i class="fas ${document.body.classList.contains('light-mode') ? 'fa-sun' : 'fa-moon'}"></i>
</button>
`;
if (username) {
buttons.innerHTML = `
<span class="welcome-text">Welcome, ${username}</span>
<button class="button logout-btn" id='logout'>Logout</button>
<a class="button" href="https://github.com/dhairyagothi/100_days_100_web_project" target="_blank">GitHub</a>
<a class="button" href="${basePath}contributors/contributor.html">Contributors</a>
${themeButton}`;
document.getElementById('logout').addEventListener('click', () => {
window.username = null;
updateNavbar();
});
} else {
buttons.innerHTML = `
<a class="button" href="${basePath}contributors/contributor.html">Contributors</a>
<a class="button" href="https://github.com/dhairyagothi" target="_blank">GitHub</a>
<a class="button login-btn" href="${basePath}public/Login.html">Log in</a>
${themeButton}`;
}
// Re-attach theme toggle event listener
const newThemeToggle = document.getElementById('themeToggle');
const newThemeIcon = newThemeToggle.querySelector('i');
newThemeToggle.addEventListener('click', () => {
document.body.classList.toggle('light-mode');
if (document.body.classList.contains('light-mode')) {
newThemeIcon.classList.remove('fa-moon');
newThemeIcon.classList.add('fa-sun');
window.theme = 'light';
} else {
newThemeIcon.classList.remove('fa-sun');
newThemeIcon.classList.add('fa-moon');
window.theme = 'dark';
}
});
}
// Populate the table with project data
function fillTable() {
const data = [
["Day 1", "To-Do List", "./public/TO_DO_LIST/todolist.html"],
["Day 2", "Digital Clock", "./public/digital_clock/digitalclock.html"],
["Day 3", "Indian Flag", "./public/indianflag/flag.html"],
["Day 4", "Dropdown Nav Bar", "./public/dropdown_navbar/index.html"],
["Day 5", "Animated Cursor", "./public/Animated-cursor/animated-cursor.html"],
["Day 6", "Auto Background Image Slider", "./public/Background-Image-sider/slider.html"],
["Day 7", "Typewriter", "./public/typewriter/typewriter.html"],
["Day 8", "Parallel-X Website", "./public/Parallel-x%20website/parallal.html"],
["Day 9", "Captcha Generator", "./public/captcha/captcha.html"],
["Day 10", "QR Code Generator", "./public/qr%20generator/qr.html"],
["Day 11", "Serve Website Using Express", "./public/index.html"],
["Day 12", "Nodemailer Contact Form", "./public/gmail_nodemailer/public/mail.html"],
["Day 13", "Login Form Using MERN", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/loginusingmern"],
["Day 14", "File Uploader", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/file_uploader"],
["Day 15", "Progress Bar", "./public/progress_bar/progress_bar.html"],
["Day 16", "Scroll Bar CSS", "./public/index.html"],
["Day 17", "Slider Using Swiper API", "./public/slider%20box/index.html"],
["Day 18", "Carousel Solar System", "./public/carousal/index.html"],
["Day 19", "Planto", "./public/plantwebsite/plant.html"],
["Day 20", "EveSparks", "https://evesparks.onrender.com/"],
["Day 21", "Video BG Slider Using React", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/travel_website"],
["Day 22", "Page Loader", "./public/pageloader/pageloader.html"],
["Day 23", "Jarvis Virtual Assistant", "./public/Jarvis-AI-main/index.html"],
["Day 24", "Chat Bot", "./public/AI%20ChatBot/chatbot.html"],
["Day 25", "Tic-Tac-Toe", "./public/TicTacToe/index.html"],
["Day 26", "Maze Game", "./public/Maze-Game-main/index.html"],
["Day 27", "Memory Game", "./public/MemoryGame/index.html"],
["Day 28", "Wordle", "./public/WORDLE/index.html"],
["Day 29", "Snake Game", "./public/snake_game/index.html"],
["Day 30", "Flappy-bird-game", "./public/Flappy-bird-main/index.html"],
["Day 31", "Password Manager", "./public/password%20manager/index.html"],
["DAY-32", "Missionaries & Cannibals", "./public/Missionaries&Cannibals/index.html"],
["Day 33", "Weather Forcasting", "./public/Weather%20Forcasting/index.html"],
["Day 34", "Email Validator", "./public/email%20validator/index.html"],
["Day 35", "Vanilla-JavaScript-Calculator", "./public/Vanilla-JavaScript-Calculator-master/index.html"],
["Day 36", "Medical App", "./public/Medical_App/index.html"],
["Day 37", "2048 Game", "./public/2048_game/index.html"],
["Day 38", "Github Profile Finder", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/github_profile_finder"],
["Day 39", "Notes App", "./public/notes-app/index.html"],
["Day 40", "Analog Clock", "./public/AnalogClock/index.html"],
["Day 41", "Scroll Dark Game", "./public/Scroll%20Game%20Dark%20Run/index.html"],
["Day 42", "Amazon App", "./public/Amazon_Clone/index.html"],
["Day 43", "Password Generator", "./public/Password_Generator/index.html"],
["Day 44", "BMI Calculator", "./public/BMI_Calculator/index.html"],
["Day 45", "Black Jack", "./public/BlackJack/blackJ.html"],
["Day 46", "Palindrome Generator", "./public/Palindrome_Generator/index.html"],
["Day 47", "Ping Pong Game", "./public/ping/index.html"],
["Day 48", "TextToVoiceConverter", "./public/TextToVoiceConverter/index.html"],
["Day 49", "Url Shortener", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/url_shortener"],
["Day 50", "Recipe Genie", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/Recipe-Genie"],
["Day 51", "Netflix Landing Page Clone", "./public/Netflix_Cloning/Index.html"],
["Day 52", "ClimaCode", "./public/ClimaCode%202.0/index.html"],
["Day 53", "E-Commerce Website with Simple Cart Functionality", "./public/e-commerce_cart/index.html"],
["Day 54", "Budget Tracker", "./public/Budget%20Tracker/index.html"],
["Day 55", "Cricket Game", "./public/cricket/index.html"],
["Day 56", "Pastebin using svelte", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/pastebin"],
["Day 57", "Glowing Social Media Icons", "./public/Social%20Media%20Glowing/index.html"],
["Day 58", "Music App", "./public/Music%20App/index.html"],
["Day 59", "Blog Page", "./public/Blog%20Page/index.html"],
["Day 60", "Marketing template website", "./public/marketing_website/index.html"],
["Day 61", "Hologram Button", "./public/Holo%20Button/index.html"],
["Day 62", "Solar System Explorer", "./public/Solar%20System%20Explorer%20in%20CSS%20only%20haml/template.html"],
["Day 63", "Image to Text App", "./public/Image-To-Text-App/index.html"],
["Day 64", "Zomato-clone", "./public/zomato-clone/zomato.html"],
["Day 65", "The Cube", "./public/The%20Cube/index.html"],
["Day 66", "Flask Authentication App", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/flask_auth_app"],
["Day 67", "Blog-Website", "./public/blog/main.html"],
["Day 68", "3d Rotating Card", "./public/3d%20cards/index.html"],
["Day 69", "Spotify Clone Project", "./public/spotify-clone%20-project/index.html"],
["Day 70", "Insect-Catch_Game", "./public/Insect-Catch-Game/index.html"],
["Day 71", "Quotely Laughs", "./public/Quotely-Laughs/index.html"],
["Day 72", "Contact Book", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/Contact%20Book"],
["Day 73", "Candy_Crush_Game", "./public/Candy_Crush_Game/index.html"],
["Day 74", "Stock Profit Calculator", "./public/Stock-Profit-Calculator/index.html"],
["Day 75", "code-space-game project", "./public/code-jump-space-game/index.html"],
["Day 76", "Animated Searchbar", "./public/Animated%20Searchbar/index.html"],
["Day 77", "Rock-Paper-Scissor-game project", "./public/Stone-Paper-Scissor/index.html"],
["Day 78", "NPM Package Search", "./public/NPM%20Package%20Search/index.html"],
["Day 79", "Linkedin Homepage Clone", "./public/Linkedin-Clone/index.html"],
["Day 80", "Resume Studio", "./public/ResumeStudio/index.html"],
["Day 81", "Simon Says Game", "./public/Simon_Says_Game/index.html"],
["Day 82", "Love Calculator Game", "./public/Love-Calculator/index.html"],
["Day 83", "Exchange Currency", "./public/Exchange_Currency/index.html"],
["Day 84", "Lights Out Puzzle", "./public/Lights_Out_Puzzle/index.html"],
["Day 85", "Image Search Engine", "./public/Image Search Engine/index.html"],
["Day 86", "Profile Card", "./public/3d profile Card/index.html"],
["Day 87", "Breakout game", "./public/Breakout game/index.html"],
["Day 88", "Job dashboard", "./public/Job dashboard/jobs.html"],
["Day 89", "N-Queen", "./public/N_Queen/index.html"],
["Day 90", "Quize App Timer", "./public/QuizeApp Timer/index1.html"],
["Day 91", "Voting Application Backend", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/Voting_Application_Backend"],
["Day 92", "Slide puzzle Game", "./public/Slide puzzle Game/index.html"],
["Day 93", "TextUtils", "https://github.com/dhairyagothi/100_days_100_web_project/tree/Main/public/Textutils"],
["Day 94", "Hangman Game", "./public/HangmanGame/index.html"],
["Day 95", "TodoList in React TS Tailwind", "./public/TodoList-React-TS-Tailwind/index.html"],
["Day 96", "HCL Color Generator", "./public/HCL Color Generator/index.html"],
["Day 97", "Time Capsule", "./public/Time-Capsule/index.html"],
["Day 98", "Virtual Piano", "./public/Virtual Piano/index.html"],
["Day 99", "NASA-APOD Extension", "./public/NASA-APOD/popup.html"],
["Day 100", "Text Saver Extension", "./public/Text_Saver_Ext/popup.html"],
["Day 101", "Personal Finance Tracker", "./public/FinanceTracker/index.html"],
["Day 102", "Travel Booking Website", "./public/Travel_booking_website/index.html"],
["Day 103", "Drumkit Game", "./public/Drumkit_Game/index.html"],
["Day 104", "Debug-Website", "./public/Debug-Website/index.html"],
["Day 105", "Periodic Table", "./public/Periodic Table/index.html"],
["Day 106", "Plants Website", "./public/Plants Website/index.html"],
["Day 107", "DocNow", "./public/DocNow/index.html"],
["Day 108", "expense_Tracker", "./public/expense_Tracker/index.html"],
["Day 109", "Mood Tracker", "./public/Mood Tracker/index.html"],
["Day 110", "CRYPTOSHOW", "./public/CRYPTOSHOW/index.html"],
["Day 111", "Whack-a-Mole Game", "./public/Whack-a-Mole Game/index.html"],
["Day 112", "Nykaa Clone Website", "./public/Nykaa-clone/index.html"],
["Day 113", "CPU Scheduler", "./public/CpuScheduler/index.html"],
["Day 114","EchoNotes","./public/EchoNotes/index.html"]
];
const tbody = document.getElementById('tableBody');
data.forEach(e => {
const row = document.createElement('tr');
const days = document.createElement('td');
const nameP = document.createElement('td');
const link = document.createElement('td');
const a = document.createElement('a');
days.innerText = e[0];
nameP.innerText = e[1];
a.href = e[2].trim();
a.innerHTML = 'View Demo <i class="fas fa-external-link-alt"></i>';
a.target = '_blank';
nameP.classList.add('project-name');
link.appendChild(a);
row.appendChild(days);
row.appendChild(nameP);
row.appendChild(link);
tbody.appendChild(row);
});
}
// Filter Projects
function filterProjects() {
const input = document.getElementById('searchInput');
const filter = input.value.toLowerCase();
const rows = document.querySelector('tbody').querySelectorAll('tr');
let hasResults = false;
rows.forEach(row => {
const projectName = row.querySelector('.project-name')?.innerText.toLowerCase();
if (projectName && projectName.includes(filter)) {
row.style.display = '';
hasResults = true;
} else {
row.style.display = 'none';
}
});
const noProjectsMessage = document.getElementById('no-projects');
if (hasResults) {
noProjectsMessage.style.display = 'none';
} else {
noProjectsMessage.style.display = 'block';
}
}
// Search on Enter key
const searchInput = document.getElementById('searchInput');
if (searchInput) {
searchInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
filterProjects();
}
});
}
// Scroll to Top Button
const scrollBtn = document.getElementById('scrollBtn');
if (scrollBtn) {
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
scrollBtn.classList.add('show');
} else {
scrollBtn.classList.remove('show');
}
});
scrollBtn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
// Initialize on DOM Load
document.addEventListener('DOMContentLoaded', () => {
initCanvas();
updateNavbar();
if (document.getElementById('tableBody')) fillTable();
if (document.getElementById('starCount')) fetchRepoStats();
});