-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
151 lines (130 loc) · 5.16 KB
/
Copy pathscript.js
File metadata and controls
151 lines (130 loc) · 5.16 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
document.getElementById('searchInput').addEventListener('keyup', function() {
let filter = this.value.toUpperCase();
let cards = document.querySelectorAll('.card');
let noResultsMsg = document.getElementById('no-results');
let visibleCount = 0;
cards.forEach(card => {
let text = card.textContent || card.innerText;
if (text.toUpperCase().indexOf(filter) > -1) {
card.style.display = "";
visibleCount++;
} else {
card.style.display = "none";
}
});
// If search is active and nothing found, OR if the grid is just empty
if (visibleCount === 0 && grid.children.length > 0) {
noResultsMsg.style.display = "block";
} else if (grid.children.length === 0) {
noResultsMsg.style.display = "block";
} else {
noResultsMsg.style.display = "none";
}
});
// 1. Data Structure (Mimicking your folders)
const studyData = {
"ACE Engineering College": {
"CSD": {
"R-20": {
"1st Year": ["I-I-Syllabus.pdf", "I-II-Syllabus.pdf"],
"2nd Year": ["II-I-Syllabus.pdf", "II-II-Syllabus.pdf"],
"3rd Year": ["III-I-Syllabus.pdf", "III-II-Syllabus.pdf"],
"4th Year": ["IV-I-Syllabus.pdf", "IV-II-Syllabus.pdf"]
},
"R-22": { /* Add similar structure here */ }
},
"CSE": { /* Add branches here */ },
"IT": { /* Add branches here */ },
"CSE(AI & ML)": { /* Add branches here */ },
"IOT": { /* Add branches here */ },
"CIVIL": { /* Add branches here */ },
"MECH": { /* Add branches here */ },
"EEE": { /* Add branches here */ },
"ECE": { /* Add branches here */ }
},
"JNTUH": {
"CSD": {
"R-20": {
"1st Year": ["I-I-Syllabus.pdf", "I-II-Syllabus.pdf"],
"2nd Year": ["II-I-Syllabus.pdf", "II-II-Syllabus.pdf"],
"3rd Year": ["III-I-Syllabus.pdf", "III-II-Syllabus.pdf"],
"4th Year": ["IV-I-Syllabus.pdf", "IV-II-Syllabus.pdf"]
},
"R-22": { /* Add similar structure here */ }
},
"CSE": { /* Add branches here */ }
}
};
const grid = document.getElementById('contentGrid');
const breadcrumbs = document.getElementById('breadcrumbs');
// A helper function to handle empty states
function checkEmpty(container, dataKey) {
const noResultsMsg = document.getElementById('no-results');
// Check if data is null, undefined, or an empty object/array
if (!dataKey || Object.keys(dataKey).length === 0) {
container.innerHTML = ''; // Clear the grid
noResultsMsg.style.display = "block";
return true; // It is empty
} else {
noResultsMsg.style.display = "none";
return false; // It has data
}
}
// 2. Function to Render Colleges (Level 1)
function renderColleges() {
breadcrumbs.innerHTML = `<span onclick="renderColleges()">Colleges</span>`;
grid.innerHTML = '';
Object.keys(studyData).forEach(college => {
grid.innerHTML += `
<div class="card college-card" onclick="renderBranches('${college}')">
<h3>${college}</h3>
<p>Click to view Departments</p>
</div>`;
});
}
// 3. Function to Render Branches (Level 2)
function renderBranches(college) {
breadcrumbs.innerHTML = `<span onclick="renderColleges()">Colleges</span> > <span>${college}</span>`;
grid.innerHTML = '';
const branches = studyData[college];
if (checkEmpty(grid, branches)) return;
Object.keys(branches).forEach(branch => {
grid.innerHTML += `
<div class="card branch-card" onclick="renderRegulations('${college}', '${branch}')">
<h3>${branch}</h3>
<p>Click to view Available Regulations</p>
</div>`;
});
}
// 4. Function to Render Regulations (Level 3)
function renderRegulations(college, branch) {
breadcrumbs.innerHTML = `<span onclick="renderColleges()">Colleges</span> > <span onclick="renderBranches('${college}')">${college}</span> > <span>${branch}</span>`;
grid.innerHTML = '';
const regulations = studyData[college][branch];
if (checkEmpty(grid, regulations)) return;
Object.keys(regulations).forEach(reg => {
grid.innerHTML += `
<div class="card reg-card" onclick="renderYears('${college}', '${branch}', '${reg}')">
<h3>Regulation ${reg}</h3>
<p>Click to view Syllabus</p>
</div>`;
});
}
// 5. Function to Render Years & Files (Final Level)
function renderYears(college, branch, reg) {
grid.innerHTML = '';
const years = studyData[college][branch][reg];
if (checkEmpty(grid, years)) return;
for (let year in years) {
let filesHtml = years[year].map(file =>
`<a href="data/colleges/${college}/${branch}/${reg}/${file}" class="file-link" target="_blank">📄 ${file}</a>`
).join('');
grid.innerHTML += `
<div class="year-section">
<h3>${year}</h3>
<div class="file-list">${filesHtml}</div>
</div>`;
}
}
// Initialize the app
renderColleges();