diff --git a/js/Template.js b/js/Template.js index 0e41409d..4f9c110a 100644 --- a/js/Template.js +++ b/js/Template.js @@ -147,9 +147,15 @@ class Template { static Import = class Import { - static button_text_default = "Import to UT Reg Plus"; + static button_text_default = "Import to UT Reg +"; + static waitlist_button_text_default = "Import Waitlists to UT Reg +"; + static button_success = "Courses Saved!"; static import_button() { - return `
`; + return `
`; + } + + static waitlist_import_button() { + return `
`; } } diff --git a/js/import.js b/js/import.js index 944b6a56..dc3c332c 100644 --- a/js/import.js +++ b/js/import.js @@ -3,9 +3,10 @@ var sem; $(function () { waitlist = !(window.location.href.includes('https://utdirect.utexas.edu/registration/classlist.WBX')); sem = waitlist ? $('[name="s_ccyys"]').val() : $("option[selected='selected']").val(); - if (waitlist) + if (waitlist) { $("[href='#top']").before(Template.Import.import_button()); - else + $("[name='wl_see_my_waitlists']").after(Template.Import.waitlist_import_button()); + } else $("table").after(Template.Import.import_button()); $("#import").prepend("
import snackbar..
"); @@ -14,15 +15,25 @@ $(function () { $(search_nodes).each(function () { importCourse($(this)); }) - importButtonAnimation(); + importButtonAnimation($(this)); + }); + + $("#import_waitlist").click(function () { + search_nodes = $("tr.tb span:first-child"); + $(search_nodes).each(function () { + importCourse($(this)); + }) + importButtonAnimation($(this)); }); }); -function importButtonAnimation() { - $("#import").text("Courses Saved!").css("background-color", Colors.open); +function importButtonAnimation(button) { + let is_waitlisted_button = $(button).attr('id') == "import_waitlist"; + let return_text = is_waitlisted_button ? Template.Import.waitlist_button_text_default : Template.Import.button_text_default; + $(button).text(Template.Import.button_success).css("background-color", Colors.open); setTimeout(function () { - $("#import").html(Template.Import.button_text_default).css('background-color', Colors.waitlisted); + $(button).html(return_text).css('background-color', Colors.waitlisted); }, 1000); } diff --git a/js/popup.js b/js/popup.js index 0445fc7c..f908478a 100644 --- a/js/popup.js +++ b/js/popup.js @@ -79,9 +79,9 @@ function formatShortenedCourseName(course) { return `${department} ${number} (${course.unique})`; } -$(document).click(function(event) { +$(document).click(function (event) { $target = $(event.target); - + // If we're not clicking on search button or search popup, and popup is visible, hide it if (!$target.closest('#search').length && !$target.closest('#search-popup').length && $('#search-popup').is(":visible")) { hideSearchPopup(); @@ -195,7 +195,6 @@ $('#export-class').click(function () { }); }); - function openCoursePage(sem, unique) { var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`; window.open(link); @@ -265,8 +264,8 @@ function handleRegister(clicked_item, curr_course) { status.includes("waitlisted") ? "Join Waitlist" : "Register"; let register_color = can_not_register ? Colors.closed : status.includes("waitlisted") ? Colors.waitlisted : Colors.open; - $(register_button).text(register_text).css('background-color', register_color); + if (!can_not_register) { $(register_button).click(function () { setCurrentTabUrl(registerlink); @@ -313,7 +312,6 @@ function handleEmpty() { } } - function copyButtonAnimation() { $(this).find('i').text('check'); $(this).stop(true, false).removeAttr('style').removeClass('shadow', {