From d8462fe4ccf2df2e99046f683c2f230969727a96 Mon Sep 17 00:00:00 2001 From: HW Computer Date: Sun, 23 Apr 2023 17:08:08 -0500 Subject: [PATCH] New database, json filtering and changed up synta;x a bit --- data/2022prefixes.json | 168 +++++++++++++++++++++++++++++++++++++++++ index.html | 12 +-- main.js | 48 ++++++------ 3 files changed, 199 insertions(+), 29 deletions(-) create mode 100644 data/2022prefixes.json diff --git a/data/2022prefixes.json b/data/2022prefixes.json new file mode 100644 index 0000000..9369d8e --- /dev/null +++ b/data/2022prefixes.json @@ -0,0 +1,168 @@ +[ + "AAS", + "ACC", + "ADV", + "AED", + "AET", + "AFR", + "AHC", + "ALD", + "AMS", + "ANS", + "ANT", + "ARA", + "ARC", + "ARE", + "ARH", + "ARI", + "ART", + "ASE", + "ASL", + "AST", + "B A", + "BAX", + "BCH", + "BDP", + "BGS", + "BIO", + "BME", + "C C", + "C E", + "C S", + "CDI", + "CH", + "CHE", + "CHI", + "CLD", + "CMS", + "COE", + "COM", + "CRP", + "CRW", + "CSE", + "CTI", + "D S", + "DCH", + "DES", + "DSC", + "E", + "E M", + "E S", + "ECE", + "ECO", + "EDC", + "EDP", + "EER", + "ELP", + "ENM", + "ENS", + "EUS", + "EVE", + "EVS", + "F A", + "FIN", + "FR", + "GEO", + "GER", + "GK", + "GOV", + "GRG", + "GSD", + "H E", + "H S", + "HCT", + "HDF", + "HDO", + "HEB", + "HED", + "HHM", + "HIN", + "HIS", + "HMN", + "I", + "I B", + "ILA", + "INF", + "IRG", + "ISP", + "ITD", + "ITL", + "J", + "J S", + "JPN", + "KIN", + "KOR", + "L A", + "LAH", + "LAR", + "LAS", + "LAT", + "LAW", + "LEB", + "LIN", + "M", + "M E", + "M S", + "MAL", + "MAN", + "MAS", + "MEL", + "MES", + "MIS", + "MKT", + "MNS", + "MOL", + "MSE", + "MUS", + "N", + "N S", + "NEU", + "NOR", + "NSC", + "NTR", + "O M", + "ORI", + "P A", + "P R", + "P S", + "PBH", + "PED", + "PGE", + "PGS", + "PHL", + "PHM", + "PHY", + "POR", + "PRC", + "PRS", + "PSY", + "R E", + "R M", + "R S", + "REE", + "RHE", + "RIM", + "RTF", + "RUS", + "S S", + "S W", + "SAB", + "SDS", + "SED", + "SLH", + "SOC", + "SPC", + "SPN", + "STA", + "STC", + "SUS", + "T C", + "T D", + "TXA", + "U D", + "UGS", + "URB", + "UTL", + "UTS", + "WGS" + ] \ No newline at end of file diff --git a/index.html b/index.html index 01f89b8..48af147 100644 --- a/index.html +++ b/index.html @@ -37,13 +37,13 @@
- +

- - -

- + +

+ +

+



diff --git a/main.js b/main.js index a5fdd9f..5c75725 100644 --- a/main.js +++ b/main.js @@ -11,29 +11,27 @@ const ctx = document.getElementById("gradeBar"); Parse the name */ function parseName() { - let className = ''; - let classNum = ''; - let department = ''; - className = document.getElementById('courseName').value; - // classNum = document.getElementById('courseNum').value; - department = document.getElementById('courseField').value; - if(department.length > 3) { - alert("Invalid Prefix"); - return; - } - if(className == '' && department == '') { + let className = document.getElementById('courseName').value; + let classNum = document.getElementById('courseNum').value; + let department = document.getElementById('courseField').value; + if(!className && !classNum && !department) { alert("At least fill out the form..."); return; } + if(department.length != 3) { + alert("Invalid Department"); + return; + } if(className == '' || department == '') { return; } - console.log(department, 0, className); - PapaParse(department, 0, className); + console.log(department, classNum, className); + PapaParse(department, classNum, className); } async function PapaParse(department, num, name) { let cData = ''; + // await fetch('https://derec4.github.io/UT-Grade-Dist/2022prefixes.json'); await fetch('https://derec4.github.io/UT-Grade-Dist/2022%20Fall.json') .then(res => res.json()) .then(data => { @@ -42,20 +40,24 @@ async function PapaParse(department, num, name) { .then(() => { // console.log(cData); }); - // await fetch('/data/2022 Fall.json') - // .then(res => res.json()) - // .then(data => { - // cData = data; - // }) - // .then(() => { - // console.log(cData); - // }); + if(cData.filter(cData => cData["Course Prefix"].includes(department.toUpperCase())).length == 0) { alert("Invalid Prefix"); return; + } + const selectedClass = ''; + if(cData.filter(cData => cData["Course Prefix"].includes(department.toUpperCase())) + .filter(cData => cData["Course Number"].includes(num.toUpperCase)) + .filter(cData => cData["Course Title"].includes(name.toUpperCase())).length == 0) { + // Possible that the class name was typed wrong; try again with just the course number + selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department.toUpperCase())) + .filter(cData => cData["Course Title"].includes(name.toUpperCase())); + } else { + selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department.toUpperCase())) + .filter(cData => cData["Course Number"].includes(num.toUpperCase)) + .filter(cData => cData["Course Title"].includes(name.toUpperCase())) } - const selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department.toUpperCase())) - .filter(cData => cData["Course Title"].includes(name.toUpperCase())); + console.log(selectedClass); let gradeDist = { "A": 0,