forked from shalonjovan/VidyaGyan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollege-dashboard.html
More file actions
719 lines (663 loc) · 37.9 KB
/
Copy pathcollege-dashboard.html
File metadata and controls
719 lines (663 loc) · 37.9 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>College Information Dashboard - VidyaGyan</title>
<!-- Use the Inter font from Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Chart.js CDN for creating the histograms -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');
body {
font-family: 'Inter', sans-serif;
background-color: #f0f2f5;
}
/* Hide scrollbar for navigation tabs but allow scrolling */
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
.scrollbar-hide {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.tab-link.active {
border-bottom: 2px solid #1f2937;
color: #1f2937;
font-weight: 600;
}
.stat-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.stat-card-green {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
color: white;
}
.stat-card-orange {
background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
color: white;
}
.chart-container {
position: relative;
height: 300px;
margin: 20px 0;
}
.placement-summary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 12px;
padding: 24px;
margin-bottom: 24px;
}
.year-stats {
background: white;
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
margin: 16px 0;
}
/* Custom CSS for the Chatbot Button */
#chatbot-button {
position: fixed;
bottom: 50px;
right: 50px;
width: 90px;
height: 90px;
border-radius: 50%;
overflow: hidden;
box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
cursor: pointer;
transition: all 0.3s ease;
border: 3px solid #6366f1;
}
#chatbot-button:hover {
transform: scale(1.1);
box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}
#chatbot-button img {
width: 90%;
height: 90%;
object-fit: contain;
border-radius: 50%;
}
</style>
</head>
<body>
<!-- Header Navigation Bar -->
<header class="relative z-20 w-full p-2 flex justify-between items-center text-white bg-gray-900">
<div class="flex items-center space-x-2">
<!-- Mobile Menu Button -->
<button id="menu-btn" class="text-white focus:outline-none md:hidden">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 12h16m-7 6h7"></path>
</svg>
</button>
<!-- Logo and Site Name -->
<div class="flex items-center space-x-2">
<a href="index.html">
<img src="./assets/mainlogo.png" alt="VidyaGyan Logo" class="w-10 h-10">
</a>
<span class="text-3xl font-bold text-white">VidyaGyan</span>
</div>
</div>
<!-- Desktop Navigation Links -->
<nav class="hidden md:flex items-center space-x-4 text-base">
<a href="career_paths.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Career Paths</a>
<a href="roadmaps/roadmap.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Roadmaps</a>
<a href="colleges.html"
class="text-white px-3 py-2 rounded-lg bg-gray-800 transition-colors duration-200">Colleges</a>
<a href="exams.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Exams</a>
<a href="resources.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Resources</a>
<a href="study_groups.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Study Groups</a>
<a href="scholarship.html"
class="text-white px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">Scholarships</a>
</nav>
<!-- Action Buttons (Home, Profile, and For You) -->
<div class="hidden md:flex items-center space-x-4">
<a href="home.html"
class="flex items-center space-x-2 text-white hover:text-gray-200 px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">
<!-- Home Icon -->
<img src="assets/home.png" alt="Home" class="w-8 h-8">
</a>
<a href="profile.html"
class="flex items-center space-x-2 text-white hover:text-gray-200 px-3 py-2 rounded-lg hover:bg-gray-800 transition-colors duration-200">
<!-- Profile Icon -->
<img src="assets/profile.jpg" alt="Profile" class="w-8 h-8">
</a>
<a href="foryou.html"
class="text-sm px-6 py-3 rounded-full border-2 border-blue-500 text-blue-500 hover:text-white hover:bg-blue-500 transition-colors duration-300">For You</a>
</div>
</header>
<!-- Chatbot Button -->
<a href="chat.html" id="chatbot-button" title="Chat with us!">
<img src="./assets/images/chat.jpeg" alt="Chatbot" />
</a>
<!-- Main container where the single college block will be injected dynamically -->
<div id="colleges-container" class="space-y-12">
<!-- The JavaScript will generate and insert the college content here -->
</div>
<!-- Footer -->
<footer class="bg-gray-900 text-gray-300 py-8 mt-16">
<div class="max-w-6xl mx-auto px-6">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<!-- VidyaGyan Info Column -->
<div class="col-span-1 md:col-span-1">
<div class="flex items-center mb-4">
<img src="./assets/mainlogo.png" alt="VidyaGyan Logo" class="w-12 h-12 mr-3">
<h3 class="text-white font-bold text-xl">VidyaGyan</h3>
</div>
<p class="text-gray-400 text-sm mb-4">Your all-in-one platform for academic and career guidance.</p>
<div class="space-y-2">
<div class="flex items-center space-x-2">
<svg class="w-4 h-4 text-gray-400" fill="currentColor" viewBox="0 0 24 24">
<path d="M22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6zm-2 0l-8 5-8-5h16zm0 12H4V8l8 5 8-5v10z"/>
</svg>
<a href="mailto:team.blastorz@gmail.com" class="text-gray-400 hover:text-white text-sm transition-colors">
team.blastorz@gmail.com
</a>
</div>
<div class="flex items-center space-x-2">
<svg class="w-4 h-4 text-gray-400" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
</svg>
<a href="members.html" class="text-gray-400 hover:text-white text-sm transition-colors">
Team Info
</a>
</div>
</div>
</div>
<!-- Navigation Column -->
<div class="col-span-1">
<h4 class="text-white font-semibold text-lg mb-3">Navigation</h4>
<ul class="space-y-2">
<li><a href="home.html" class="text-gray-400 hover:text-white text-sm transition-colors">Home</a></li>
<li><a href="profile.html" class="text-gray-400 hover:text-white text-sm transition-colors">Profile</a></li>
<li><a href="foryou.html" class="text-gray-400 hover:text-white text-sm transition-colors">For You</a></li>
<li><a href="career_paths.html" class="text-gray-400 hover:text-white text-sm transition-colors">Career Paths</a></li>
</ul>
</div>
<!-- Resources Column -->
<div class="col-span-1">
<h4 class="text-white font-semibold text-lg mb-3">Resources</h4>
<ul class="space-y-2">
<li><a href="colleges.html" class="text-gray-400 hover:text-white text-sm transition-colors">Colleges</a></li>
<li><a href="roadmaps/roadmap.html" class="text-gray-400 hover:text-white text-sm transition-colors">Roadmaps</a></li>
<li><a href="exams.html" class="text-gray-400 hover:text-white text-sm transition-colors">Exams</a></li>
<li><a href="resources.html" class="text-gray-400 hover:text-white text-sm transition-colors">Study Materials</a></li>
</ul>
</div>
<!-- Community Column -->
<div class="col-span-1">
<h4 class="text-white font-semibold text-lg mb-3">Community</h4>
<ul class="space-y-2">
<li><a href="study_groups.html" class="text-gray-400 hover:text-white text-sm transition-colors">Study Groups</a></li>
<li><a href="scholarship.html" class="text-gray-400 hover:text-white text-sm transition-colors">Scholarships</a></li>
<li><a href="login.html" class="text-gray-400 hover:text-white text-sm transition-colors">Login</a></li>
<li><a href="signup.html" class="text-gray-400 hover:text-white text-sm transition-colors">Sign Up</a></li>
</ul>
</div>
</div>
<!-- Copyright -->
<div class="border-t border-gray-700 mt-6 pt-4 text-center">
<p class="text-gray-400 text-sm">
Copyright © 2025 - Team Blastorz 💥
</p>
</div>
</div>
</footer>
<script>
// College data will be loaded from external JSON file
let collegeData = [];
// Function to get URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// Function to load JSON data from external file
async function loadCollegeData() {
try {
const fieldParam = getUrlParameter('data');
let currentField = 'college-data'; // Default file name
if (fieldParam) {
currentField = fieldParam;
}
const response = await fetch(`${currentField}.json`);
collegeData = await response.json();
renderSingleCollege();
} catch (error) {
console.error('Error loading college data:', error);
const container = document.getElementById('colleges-container');
container.innerHTML = `<div class="p-8 text-center text-gray-500">
<p>Failed to load college data. Please check the file name and try again.</p>
</div>`;
}
}
// Function to create a college card HTML string from a data object
function createCollegeCard(college) {
const badgesHtml = college.badges.map(badge => `
<span class="bg-blue-100 text-blue-800 font-medium px-2 py-0.5 rounded-full text-xs">${badge}</span>
`).join('');
// Get the first content key to show by default
const firstSection = Object.keys(college.content)[0];
const navigationLinksHtml = Object.keys(college.content).map(section => `
<a href="#" id="${college.id}-${section.replace(/\s/g, '')}-link" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300 ${section === firstSection ? 'active' : ''}" data-college-id="${college.id}" data-section="${section}">
${section}
</a>
`).join('');
return `
<div id="${college.id}-card" class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Banner and Logo Section -->
<div class="relative">
<!-- Banner Image -->
<img src="${college.bannerUrl}"
onerror="this.onerror=null; this.src='https://placehold.co/1200x250';"
alt="${college.name} Banner"
class="w-full h-40 md:h-64 object-cover">
<!-- Logo Overlay -->
<div class="absolute bottom-4 left-4 md:bottom-8 md:left-8 bg-white p-2 md:p-3 rounded-xl shadow-lg">
<img src="${college.logoUrl}"
onerror="this.onerror=null; this.src='https://placehold.co/80x80';"
alt="${college.name} Logo"
class="w-16 h-16 md:w-20 md:h-20 rounded-lg object-cover">
</div>
</div>
<div class="p-6 md:p-8">
<!-- College Info and Badges Section -->
<div class="flex flex-col md:flex-row md:items-center justify-between space-y-4 md:space-y-0 md:space-x-8 mb-6">
<!-- College Details -->
<div class="flex-grow">
<h1 class="text-2xl md:text-3xl font-bold text-gray-900 mb-1">${college.name}: ${college.tagline}</h1>
<p class="text-gray-500 text-sm mb-2">${college.address}</p>
<!-- Ratings and Badges -->
<div class="flex flex-wrap items-center space-x-2 text-sm text-gray-500">
<span class="flex items-center">
<span class="text-yellow-400">★</span> ${college.ratings}
</span>
<span class="text-gray-400">|</span>
${badgesHtml}
</div>
</div>
</div>
<!-- Navigation Tabs -->
<div class="flex space-x-6 border-b border-gray-200 overflow-x-auto whitespace-nowrap scrollbar-hide">
${navigationLinksHtml}
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Placements">Placements</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Admissions">Admissions</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Cut-Offs">Cut-Offs</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Rankings">Rankings</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Infrastructure">Infrastructure</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Faculty">Faculty</a>
<a href="#" class="tab-link py-2 text-gray-500 hover:text-gray-900 transition duration-300" data-college-id="${college.id}" data-section="Scholarships">Scholarships</a>
</div>
<!-- Content area for tabs -->
<div class="mt-6" id="${college.id}-content">
<!-- Content will be injected here by JavaScript -->
</div>
<!-- Last updated timestamp -->
<p class="text-gray-400 text-sm mt-4">Last updated on ${college.lastUpdated || '31 Aug 25'}</p>
</div>
</div>
`;
}
// Function to render the content for a specific tab
function renderContent(collegeId, section) {
const college = collegeData.find(c => c.id === collegeId);
const contentDiv = document.getElementById(`${college.id}-content`);
if (!college || !contentDiv) {
console.error("College data or content div not found.");
return;
}
// Clear previous content
contentDiv.innerHTML = '';
// Switch content based on the section
switch (section) {
case "Placements":
const latestYear = college.placements.salaryByYear.labels[college.placements.salaryByYear.labels.length - 1];
const latestHighest = college.placements.salaryByYear.highestSalary[college.placements.salaryByYear.highestSalary.length - 1];
const latestAverage = college.placements.salaryByYear.averageSalary[college.placements.salaryByYear.averageSalary.length - 1];
// Calculate placement percentage (assuming from salary distribution)
const latestDistribution = college.placements.salaryDistribution[latestYear];
const totalPlaced = latestDistribution.data.reduce((a, b) => a + b, 0);
const highSalaryCount = latestDistribution.data[latestDistribution.data.length - 1] + latestDistribution.data[latestDistribution.data.length - 2];
contentDiv.innerHTML = `
<div class="space-y-8">
<!-- Placement Summary Cards -->
<div class="placement-summary">
<h2 class="text-2xl font-bold mb-6">Placement Highlights ${latestYear}</h2>
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
<div class="text-center">
<div class="text-3xl font-bold">₹${(latestHighest / 100000).toFixed(1)}L</div>
<div class="text-sm opacity-90">Highest Package</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold">₹${(latestAverage / 100000).toFixed(1)}L</div>
<div class="text-sm opacity-90">Average Package</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold">${totalPlaced}+</div>
<div class="text-sm opacity-90">Students Placed</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold">${Math.round((highSalaryCount / totalPlaced) * 100)}%</div>
<div class="text-sm opacity-90">Above 10L Package</div>
</div>
</div>
</div>
<!-- Year-wise Statistics -->
<div class="year-stats">
<h3 class="text-xl font-semibold text-gray-800 mb-4">Year-wise Placement Statistics</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
${college.placements.salaryByYear.labels.map((year, index) => {
const highest = college.placements.salaryByYear.highestSalary[index];
const average = college.placements.salaryByYear.averageSalary[index];
const distribution = college.placements.salaryDistribution[year];
const placed = distribution.data.reduce((a, b) => a + b, 0);
return `
<div class="bg-gray-50 p-4 rounded-lg">
<div class="text-lg font-semibold text-gray-800 mb-2">${year}</div>
<div class="space-y-2 text-sm">
<div class="flex justify-between">
<span class="text-gray-600">Highest:</span>
<span class="font-medium">₹${(highest / 100000).toFixed(1)}L</span>
</div>
<div class="flex justify-between">
<span class="text-gray-600">Average:</span>
<span class="font-medium">₹${(average / 100000).toFixed(1)}L</span>
</div>
<div class="flex justify-between">
<span class="text-gray-600">Placed:</span>
<span class="font-medium">${placed} students</span>
</div>
</div>
</div>
`;
}).join('')}
</div>
</div>
<!-- Charts Section -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Salary Trends Chart -->
<div class="bg-white p-6 rounded-lg shadow-sm">
<h3 class="text-xl font-semibold text-gray-800 mb-4">Salary Trends Over Years</h3>
<div class="chart-container">
<canvas id="${college.id}-salary-trends-chart"></canvas>
</div>
</div>
<!-- Salary Distribution Chart -->
<div class="bg-white p-6 rounded-lg shadow-sm">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-semibold text-gray-800">Salary Distribution</h3>
<select id="${college.id}-year-select" class="rounded-md border border-gray-300 px-3 py-1 text-sm">
${Object.keys(college.placements.salaryDistribution).map(year => `<option value="${year}">${year}</option>`).join('')}
</select>
</div>
<div class="chart-container">
<canvas id="${college.id}-distribution-chart"></canvas>
</div>
</div>
</div>
<!-- Detailed Breakdown -->
<div class="bg-white p-6 rounded-lg shadow-sm">
<h3 class="text-xl font-semibold text-gray-800 mb-4">Placement Analysis by Salary Range</h3>
<div class="overflow-x-auto">
<table class="w-full table-auto">
<thead>
<tr class="border-b border-gray-200">
<th class="text-left py-3 px-2 font-semibold text-gray-800">Year</th>
<th class="text-center py-3 px-2 font-semibold text-gray-800">0-5L</th>
<th class="text-center py-3 px-2 font-semibold text-gray-800">5-10L</th>
<th class="text-center py-3 px-2 font-semibold text-gray-800">10-20L</th>
<th class="text-center py-3 px-2 font-semibold text-gray-800">>20L</th>
<th class="text-center py-3 px-2 font-semibold text-gray-800">Total</th>
</tr>
</thead>
<tbody>
${Object.keys(college.placements.salaryDistribution).map(year => {
const data = college.placements.salaryDistribution[year].data;
const total = data.reduce((a, b) => a + b, 0);
return `
<tr class="border-b border-gray-100 hover:bg-gray-50">
<td class="py-3 px-2 font-medium">${year}</td>
<td class="text-center py-3 px-2">${data[0]} <span class="text-sm text-gray-500">(${Math.round(data[0]/total*100)}%)</span></td>
<td class="text-center py-3 px-2">${data[1]} <span class="text-sm text-gray-500">(${Math.round(data[1]/total*100)}%)</span></td>
<td class="text-center py-3 px-2">${data[2]} <span class="text-sm text-gray-500">(${Math.round(data[2]/total*100)}%)</span></td>
<td class="text-center py-3 px-2">${data[3]} <span class="text-sm text-gray-500">(${Math.round(data[3]/total*100)}%)</span></td>
<td class="text-center py-3 px-2 font-semibold">${total}</td>
</tr>
`;
}).join('')}
</tbody>
</table>
</div>
</div>
</div>
`;
// Render the charts
renderCharts(college);
break;
case "College Info":
case "Courses":
case "Fees":
case "Reviews":
case "Admissions":
case "Cut-Offs":
case "Rankings":
case "Infrastructure":
case "Faculty":
case "Compare":
case "Scholarships":
contentDiv.innerHTML = college.content[section] || `<div class="bg-white p-6 md:p-8 rounded-lg shadow-sm mt-4"><p class="text-gray-700 leading-relaxed">Content for ${section} is not available yet.</p></div>`;
break;
default:
contentDiv.innerHTML = `<div class="bg-white p-6 md:p-8 rounded-lg shadow-sm mt-4"><p class="text-gray-700 leading-relaxed">Content not found.</p></div>`;
}
}
// Function to render the charts for the Placements section
function renderCharts(college) {
// Combined Salary Trends Chart
const salaryTrendsCtx = document.getElementById(`${college.id}-salary-trends-chart`).getContext('2d');
new Chart(salaryTrendsCtx, {
type: 'line',
data: {
labels: college.placements.salaryByYear.labels,
datasets: [
{
label: 'Highest Salary (₹L)',
data: college.placements.salaryByYear.highestSalary.map(salary => salary / 100000),
backgroundColor: 'rgba(79, 70, 229, 0.1)',
borderColor: '#4f46e5',
borderWidth: 3,
fill: true,
tension: 0.4,
pointBackgroundColor: '#4f46e5',
pointBorderColor: '#ffffff',
pointBorderWidth: 2,
pointRadius: 6
},
{
label: 'Average Salary (₹L)',
data: college.placements.salaryByYear.averageSalary.map(salary => salary / 100000),
backgroundColor: 'rgba(34, 197, 94, 0.1)',
borderColor: '#22c55e',
borderWidth: 3,
fill: true,
tension: 0.4,
pointBackgroundColor: '#22c55e',
pointBorderColor: '#ffffff',
pointBorderWidth: 2,
pointRadius: 6
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
},
tooltip: {
mode: 'index',
intersect: false,
callbacks: {
label: function(context) {
return context.dataset.label + ': ₹' + context.parsed.y.toFixed(1) + 'L';
}
}
}
},
scales: {
x: {
grid: {
display: false
}
},
y: {
beginAtZero: true,
grid: {
color: 'rgba(0, 0, 0, 0.1)'
},
ticks: {
callback: function(value) {
return '₹' + value + 'L';
}
}
}
},
interaction: {
intersect: false,
mode: 'index'
}
}
});
const yearSelect = document.getElementById(`${college.id}-year-select`);
const distributionCtx = document.getElementById(`${college.id}-distribution-chart`).getContext('2d');
let distributionChart;
function updateDistributionChart(year) {
const data = college.placements.salaryDistribution[year];
if (distributionChart) {
distributionChart.destroy();
}
distributionChart = new Chart(distributionCtx, {
type: 'doughnut',
data: {
labels: data.labels,
datasets: [{
label: `Students Placed in ${year}`,
data: data.data,
backgroundColor: [
'#ef4444',
'#f59e0b',
'#10b981',
'#3b82f6'
],
borderColor: [
'#dc2626',
'#d97706',
'#059669',
'#2563eb'
],
borderWidth: 2,
hoverOffset: 8
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom',
labels: {
padding: 20,
usePointStyle: true
}
},
tooltip: {
callbacks: {
label: function(context) {
const total = context.dataset.data.reduce((a, b) => a + b, 0);
const percentage = Math.round((context.parsed / total) * 100);
return `${context.label}: ${context.parsed} students (${percentage}%)`;
}
}
}
}
}
});
}
// Initial chart render with latest year
const latestYear = Object.keys(college.placements.salaryDistribution).pop();
yearSelect.value = latestYear;
updateDistributionChart(latestYear);
// Update chart on year selection change
yearSelect.addEventListener('change', (event) => {
updateDistributionChart(event.target.value);
});
}
// Function to render a single college
function renderSingleCollege() {
const container = document.getElementById('colleges-container');
container.innerHTML = '';
if (collegeData.length > 0) {
const college = collegeData[0];
container.innerHTML = createCollegeCard(college);
setupEventListeners(college);
} else {
container.innerHTML = `<div class="p-8 text-center text-gray-500">
<p>No college data found.</p>
</div>`;
}
}
// Function to set up all event listeners for the single college card
function setupEventListeners(college) {
// Set up event listeners for all navigation links for the given college
document.querySelectorAll(`#${college.id}-card .tab-link`).forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const collegeId = e.target.getAttribute('data-college-id');
const section = e.target.getAttribute('data-section');
// Remove 'active' class from all links for this college
document.querySelectorAll(`#${collegeId}-card .tab-link`).forEach(l => l.classList.remove('active'));
// Add 'active' class to the clicked link
e.target.classList.add('active');
renderContent(collegeId, section);
});
});
// Initial rendering of content for the first section
const firstSection = Object.keys(college.content)[0];
renderContent(college.id, firstSection);
}
// Load data when page loads
window.onload = function() {
loadCollegeData();
};
</script>
<script>
const menuBtn = document.getElementById('menu-btn');
const sidebar = document.getElementById('sidebar');
menuBtn.addEventListener('click', () => {
sidebar.classList.toggle('open');
});
</script>
</body>
</html>