Huh it works?!?

This commit is contained in:
2023-05-03 22:09:34 -05:00
parent 7e992624f9
commit de43d0e445

View File

@@ -69,11 +69,20 @@ async function PapaParse(department, num, name, sem, unique) {
.then(res => res.json()) .then(res => res.json())
.then(data => { cData = data; }); .then(data => { cData = data; });
let selectedClass = ''; let selectedClass = '';
if(sem.substring(0,2)==='s2') {
}
if(unique) { if(unique) {
selectedClass = cData.filter(cData => cData['Section Number'] == unique); selectedClass = cData.filter(cData => cData['Section Number'] == unique);
} else {
if(sem.substring(0,2)==='s2') {
console.log("Summer Semester Detected");
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
.filter(cData => cData["Course Number"].includes(num.toString().toUpperCase()))
.filter(cData => cData["Course Title"].includes(name));
if (selectedClass.length == 0) {
// summer names are weird
console.log("Invalid name; trying again with just the course number");
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
.filter(cData => cData["Course Number"].includes(num.toString().toUpperCase()))
}
} else { } else {
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department)) selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
.filter(cData => cData["Course Number"] == num.toString().toUpperCase()) .filter(cData => cData["Course Number"] == num.toString().toUpperCase())
@@ -85,6 +94,8 @@ async function PapaParse(department, num, name, sem, unique) {
.filter(cData => cData["Course Number"] == num.toString().toUpperCase()); .filter(cData => cData["Course Number"] == num.toString().toUpperCase());
} }
} }
}
if(selectedClass.length == 0) { if(selectedClass.length == 0) {
// Still can't find anything? Just exit without making a chart and alert that nothing could be found // Still can't find anything? Just exit without making a chart and alert that nothing could be found
alert("No data found. Try again :("); alert("No data found. Try again :(");