From de43d0e445e2fa81c6928bc7b97d60aca0dd8278 Mon Sep 17 00:00:00 2001 From: Derek Chen Date: Wed, 3 May 2023 22:09:34 -0500 Subject: [PATCH] Huh it works?!? --- docs/main.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/main.js b/docs/main.js index 5f5fb27..81e4001 100644 --- a/docs/main.js +++ b/docs/main.js @@ -69,21 +69,32 @@ async function PapaParse(department, num, name, sem, unique) { .then(res => res.json()) .then(data => { cData = data; }); let selectedClass = ''; - if(sem.substring(0,2)==='s2') { - - } if(unique) { selectedClass = cData.filter(cData => cData['Section Number'] == unique); } else { - selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department)) - .filter(cData => cData["Course Number"] == num.toString().toUpperCase()) - .filter(cData => cData["Course Title"].includes(name)); - if(selectedClass.length == 0) { - // Possible that the class name was typed wrong; try again with just the course number - console.log("Invalid name; trying again with just the course number"); + 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"] == num.toString().toUpperCase()); - } + .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 { + selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department)) + .filter(cData => cData["Course Number"] == num.toString().toUpperCase()) + .filter(cData => cData["Course Title"].includes(name)); + if (selectedClass.length == 0) { + // Possible that the class name was typed wrong; try again with just the course number + 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"] == num.toString().toUpperCase()); + } + } + } if(selectedClass.length == 0) { // Still can't find anything? Just exit without making a chart and alert that nothing could be found