updated the search to now do the semester, class, and level search, and put link to RIS on popup
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
48
js/popup.js
48
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<semester_names.length;i++){
|
||||
let name = semester_names[i];
|
||||
$("#semesters").append(`<option value='${semesters[name]}'>${name}</option>`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getDepartments() {
|
||||
chrome.runtime.sendMessage({
|
||||
command: "currentDepartments"
|
||||
}, function(response){
|
||||
let { departments } = response;
|
||||
console.log(departments);
|
||||
for(let i = 0; i<departments.length; i++){
|
||||
let abv = departments[i];
|
||||
$("#department").append(`<option value='${abv}'>${abv}</option>`);
|
||||
}
|
||||
$("#department").val('C S');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user