open modal when hitting more info from popup or utplanner

This commit is contained in:
sghsri
2019-08-27 11:01:05 -05:00
parent 2c5a0945c7
commit 024d491e63
6 changed files with 46 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
var grades;
var current_semesters = {};
var should_open = false;
onStartup();
/* Handle messages and their commands from content and popup scripts*/
@@ -34,9 +34,19 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
break;
case "gradesQuery":
executeQuery(request.query, response);
break;
case "currentSemesters":
response({ semesters: current_semesters});
getCurrentSemesters();
break;
case "setOpen":
should_open = true;
chrome.tabs.create({ url: request.url});
break;
case "shouldOpen":
response({open : should_open});
should_open = false;
break;
default:
const xhr = new XMLHttpRequest();
const method = request.method ? request.method.toUpperCase() : "GET";

View File

@@ -47,9 +47,6 @@ chrome.storage.sync.get("savedCourses", function (data) {
});
});
function displayModal(data) {
$("#myModal").fadeIn(calendar_fade_time);
$("#colorStrip").css('background-color', data.color);
@@ -177,9 +174,7 @@ chrome.runtime.onMessage.addListener(
$("#info").click(() => {
setTimeout(() => {
window.open(curr_course.link);
}, button_delay);
openMoreInfoWithOpenModal(curr_course.link);
});

View File

@@ -2,12 +2,8 @@ console.log(`UT Registration Plus is running on this page: ${window.location.hre
var curr_course = {}
var semester_code = new URL(window.location.href).pathname.split('/')[4];
var done_loading = true;
updateListConflictHighlighting();
var next = $("#next_nav_link");
if (next) {
@@ -20,12 +16,6 @@ if (next) {
//This extension may be super lit, but you know what's even more lit?
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
$(window).scroll(function () {
if ($(document).height() <= $(window).scrollTop() + $(window).height() + 150)
loadNextPages();
});
if (document.querySelector('#fos_fl')) {
let params = (new URL(document.location)).searchParams;
let dep = params.get("fos_fl");
@@ -53,9 +43,18 @@ if (!$("#kw_results_table").length) {
});
}
if(isIndividualCoursePage()){
chrome.runtime.sendMessage({
command: "shouldOpen",
}, function (response) {
if(response.open){
$("#distButton").click();
}
});
}
updateListConflictHighlighting();
/*Handle the button clicks*/
$("body").on('click', '#distButton', function () {
var row = $(this).closest('tr');
$('.modal-content').stop().animate({
@@ -131,7 +130,7 @@ function getCourseInfo(row) {
let course_name = "";
let course_row = {}
let individual = undefined;
if ($("#textbook_button").length) {
if (isIndividualCoursePage()) {
course_name = $("#details h2").text();
course_row = $('table');
individual = document.URL;
@@ -562,6 +561,14 @@ function close() {
$("#snackbar").attr("class", "");
}
/*Listen for update mssage coming from popup or calendar or other course catalog pages*/
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.command == "updateCourseList") {
updateListConflictHighlighting(0);
}
}
);
$(document).keydown(function (e) {
/*Close Modal when hit escape*/
@@ -573,11 +580,8 @@ $(document).keydown(function (e) {
});
/*Listen for update mssage coming from popup or calendar or other course catalog pages*/
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.command == "updateCourseList") {
updateListConflictHighlighting(0);
}
}
);
$(window).scroll(function () {
if ($(document).height() <= $(window).scrollTop() + $(window).height() + 150)
loadNextPages();
});

View File

@@ -203,7 +203,7 @@ $('#export-class').click(function () {
function openCoursePage(sem, unique) {
var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
window.open(link);
openMoreInfoWithOpenModal(link);
}
$("#search-class").click(() => {
@@ -318,7 +318,7 @@ function subtractHours(curr_course){
function handleMoreInfo(clicked_item, curr_course) {
$(clicked_item).find("#listMoreInfo").click(function () {
window.open(curr_course.link);
openMoreInfoWithOpenModal(curr_course.link);
});
}

View File

@@ -111,6 +111,9 @@ function seperateCourseNameParts(name) {
}
}
function isIndividualCoursePage(){
return $("#textbook_button").length != 0;
}
@@ -139,6 +142,10 @@ function setCurrentTabUrl(link) {
});
}
function openMoreInfoWithOpenModal(link){
chrome.runtime.sendMessage({ command: "setOpen", url: link });
}
function semesterSort(semA, semB) {
let semOrder = {

View File

@@ -93,9 +93,7 @@ $("#textbook").click(function () {
});
$("#moreInfo").click(function () {
setTimeout(function () {
window.open(curr_course["individual"]);
}, Timing.button_delay);
openMoreInfoWithOpenModal(curr_course["individual"]);
});