diff --git a/css/popup.css b/css/popup.css index 78c093b1..97367cc0 100644 --- a/css/popup.css +++ b/css/popup.css @@ -283,7 +283,7 @@ input[type=number]::-webkit-outer-spin-button { .select-style { border: 1px solid #979797; - margin: 10px 0px; + margin: 5px 0px; border-radius: 5px; display: none; background: transparent no-repeat 90% 50%; @@ -324,7 +324,7 @@ input[type=number]::-webkit-outer-spin-button { outline: none; } -#class_id_input { +.class_id_input { display: none; border: 1px solid #979797; border-radius: 5px; @@ -332,7 +332,7 @@ input[type=number]::-webkit-outer-spin-button { padding: 5px 8px; } -#class_id_input::placeholder { +.class_id_input::placeholder { color: rgba(0, 0, 45, 0.48); } diff --git a/js/background.js b/js/background.js index 4658eec2..07c86149 100644 --- a/js/background.js +++ b/js/background.js @@ -1,5 +1,6 @@ var grades; var current_semesters = {}; +var departments = []; var should_open = false; onStartup(); @@ -39,6 +40,9 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) { response({ semesters: current_semesters}); getCurrentSemesters(); break; + case "currentDepartments": + response({departments: departments}); + break; case "setOpen": should_open = true; chrome.tabs.create({ url: request.url}); @@ -117,9 +121,9 @@ function onStartup(){ updateBadge(true); loadDataBase() getCurrentSemesters(); + getCurrentDepartments(); } - function getCurrentSemesters(){ $.get('https://registrar.utexas.edu/schedules', function (response) { if (response) { @@ -150,6 +154,19 @@ function getCurrentSemesters(){ } +function getCurrentDepartments(){ + $.get('https://catalog.utexas.edu/undergraduate/appendix-b/', function(response){ + if(response){; + departments = []; + htmlToNode(response).find('.column1').each(function(i){ + if(i > 0){ + let abv = $(this).text(); + departments.push(abv); + } + }); + } + }); +} function updateBadge(first, new_changes) { if (new_changes) { @@ -401,4 +418,3 @@ function loadBinaryFile(path, success) { }; xhr.send(); }; - diff --git a/js/popup.js b/js/popup.js index 18ddbf4f..237d3470 100644 --- a/js/popup.js +++ b/js/popup.js @@ -2,6 +2,7 @@ var courses; setCourseList(); getSemesters(); +getDepartments(); var can_remove = true; @@ -105,9 +106,9 @@ $("#clear").click(function () { showEmpty(); }); -$("#schedule").click(function () { +$("#RIS").click(function () { chrome.tabs.create({ - 'url': 'https://registrar.utexas.edu/schedules' + 'url': 'https://utdirect.utexas.edu/registrar/ris.WBX' }); }); @@ -201,22 +202,16 @@ $('#export-class').click(function () { }); }); -function openCoursePage(sem, unique) { - var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`; - openMoreInfoWithOpenModal(link); +function openSearch(semester, department, level) { + var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester}/results/?fos_fl=${department}&level=${level}&search_type_main=FIELD` + chrome.tabs.create({ url: link}); } $("#search-class").click(() => { - var unique_id = $("#class_id_input").val(); - if (!isNaN(unique_id)) { - if (unique_id.length == 5) { - let selected_semester = $("#semesters").find(":selected").val(); - openCoursePage(selected_semester, unique_id); - $("#class_id_input").val(''); - return; - } - } - alert("Oops, check your input. Class IDs should have 5 digits!"); + let semester = $("#semesters").find(":selected").val(); + let department = $("#department").find(":selected").val(); + let level = $("#level").find(":selected").val(); + openSearch(semester, department, level); }); $("#options_button").click(function () { @@ -367,9 +362,10 @@ function showEmpty() { function hideSearchPopup() { $("#search>i").text('search'); - $("#class_id_input").hide(); $("#semcon").hide(); + $("#depcon").hide(); $("#semesters").hide(); + $("#levcon").hide(); $("#search-popup").addClass('hide'); } @@ -378,7 +374,8 @@ function showSearchPopup() { $("#class_id_input").show(); $("#semesters").show(); $("#semcon").show(); - $('#class_id_input').focus(); + $("#depcon").show(); + $("#levcon").show(); $("#search-popup").removeClass('hide'); } @@ -397,11 +394,24 @@ function getSemesters() { command: "currentSemesters" }, function(response){ let { semesters } = response; - console.log(semesters); let semester_names = Object.keys(semesters); for(let i = 0; i${name}`); } }); -} \ No newline at end of file +} + +function getDepartments() { + chrome.runtime.sendMessage({ + command: "currentDepartments" + }, function(response){ + let { departments } = response; + console.log(departments); + for(let i = 0; i${abv}`); + } + $("#department").val('C S'); + }); +} diff --git a/popup.html b/popup.html index 88ec9ac2..cc8313b6 100644 --- a/popup.html +++ b/popup.html @@ -12,7 +12,7 @@
- +
@@ -34,7 +34,7 @@

17 hr

-
+
- +
+ +
+
+ +
+ @@ -91,4 +105,4 @@ - \ No newline at end of file +