fixed importing waitlist and importing courses from WL page
This commit is contained in:
20
js/import.js
20
js/import.js
@@ -16,7 +16,7 @@ $(function () {
|
|||||||
$("#import").click(function () {
|
$("#import").click(function () {
|
||||||
search_nodes = waitlist ? $(".tbg").last().find(".tbon>td:first-child") : $("tr>td:first-child");
|
search_nodes = waitlist ? $(".tbg").last().find(".tbon>td:first-child") : $("tr>td:first-child");
|
||||||
$(search_nodes).each(function () {
|
$(search_nodes).each(function () {
|
||||||
importCourse($(this));
|
importCourse($(this), true);
|
||||||
})
|
})
|
||||||
importButtonAnimation($(this));
|
importButtonAnimation($(this));
|
||||||
});
|
});
|
||||||
@@ -24,7 +24,7 @@ $(function () {
|
|||||||
$("#import_waitlist").click(function () {
|
$("#import_waitlist").click(function () {
|
||||||
search_nodes = $("tr.tb span:first-child");
|
search_nodes = $("tr.tb span:first-child");
|
||||||
$(search_nodes).each(function () {
|
$(search_nodes).each(function () {
|
||||||
importCourse($(this));
|
importCourse($(this), false);
|
||||||
})
|
})
|
||||||
importButtonAnimation($(this));
|
importButtonAnimation($(this));
|
||||||
});
|
});
|
||||||
@@ -61,17 +61,17 @@ function importButtonAnimation(button) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function importCourse(unique_node) {
|
function importCourse(unique_node, force) {
|
||||||
let unique = $(unique_node).text().replace(/\s/g, '');
|
let unique = $(unique_node).text().replace(/\s/g, '').substring(0,5);
|
||||||
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
||||||
buildAddCourse(link);
|
buildAddCourse(link, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildAddCourse(link) {
|
function buildAddCourse(link, force) {
|
||||||
$.get(link, function (response) {
|
$.get(link, function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
let simp_course = buildSimplifiedCourseObject(response, link);
|
let simp_course = buildSimplifiedCourseObject(response, link, force);
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "courseStorage",
|
command: "courseStorage",
|
||||||
course: simp_course,
|
course: simp_course,
|
||||||
@@ -86,7 +86,7 @@ function buildAddCourse(link) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildSimplifiedCourseObject(response, link) {
|
function buildSimplifiedCourseObject(response, link, force) {
|
||||||
let imported_course = getCourseObject(htmlToNode(response), link);
|
let imported_course = getCourseObject(htmlToNode(response), link);
|
||||||
let {
|
let {
|
||||||
full_name,
|
full_name,
|
||||||
@@ -97,7 +97,9 @@ function buildSimplifiedCourseObject(response, link) {
|
|||||||
register
|
register
|
||||||
} = curr_course;
|
} = curr_course;
|
||||||
let dtarr = getDayTimeArray(undefined, curr_course);
|
let dtarr = getDayTimeArray(undefined, curr_course);
|
||||||
|
if(force === true) {
|
||||||
|
status = "open" //forces the green status for courses a user is already registered for
|
||||||
|
}
|
||||||
return new Course(full_name, unique, prof_name, dtarr, status, individual, register);
|
return new Course(full_name, unique, prof_name, dtarr, status, individual, register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user