");
- //go through all the rows in the list
+
+ // now add to the table
+ $("table thead th:last-child").after('
Plus
');
$('table').find('tr').each(function () {
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
- //if a course row, then add the extension button
- $(this).append(`
`);
+ $(this).append(Template.extensionButton());
}
});
}
-//update the conflicts
-update(0);
+
+
+
/*Handle the button clicks*/
$("body").on('click', '#distButton', function () {
var row = $(this).closest('tr');
@@ -99,27 +104,6 @@ $("#retry").click(function () {
});
-
-
-$(document).keydown(function (e) {
- /*Close Modal when hit escape*/
- if (e.keyCode == 27) {
- close();
- } else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
- saveCourse();
- }
-});
-
-/*Listen for update mssage coming from popup*/
-chrome.runtime.onMessage.addListener(
- function (request, sender, sendResponse) {
- if (request.command == "updateCourseList") {
- update(0);
- }
- }
-);
-
-
function sepNameParts(name) {
numIndex = name.search(/\d/);
department = name.substring(0, numIndex).trim();
@@ -234,18 +218,8 @@ function saveCourse() {
});
}
-
-function toggleSnackbar() {
- setTimeout(function () {
- $("#snackbar").attr("class", "show");
- }, 200);
- setTimeout(function () {
- $("#snackbar").attr("class", "");
- }, 3000);
-}
-
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
-function update(start) {
+function updateListConflictHighlighting(start = 0) {
chrome.storage.sync.get('courseConflictHighlight', function (data) {
let canHighlight = data.courseConflictHighlight;
$('table').find('tr').each(function (i) {
@@ -494,11 +468,60 @@ function getDescription(course_info) {
});
}
+function loadNextPages() {
+ chrome.storage.sync.get('loadAll', function (data) {
+ if (data.loadAll) {
+ let link = next.prop('href');
+ if (doneLoading && next && link) {
+ toggleLoadingPage(true);
+ $.get(link, function (response) {
+ if (response) {
+ var nextpage = $('').html(response).contents();
+ var current = $('tbody');
+ var oldlength = $('tbody tr').length;
+ var last = current.find('.course_header>h2:last').text();
+ next = nextpage.find("#next_nav_link");
+ toggleLoadingPage(false);
+ var newrows = [];
+ nextpage.find('tbody>tr').each(function () {
+ let hasCourseHead = $(this).find('td').hasClass("course_header");
+ if (!(hasCourseHead && $(this).has('th').length == 0))
+ $(this).append(Template.extensionButton());
+ if (!(hasCourseHead && last == $(this).find('td').text()))
+ newrows.push($(this));
+ });
+ current.append(newrows);
+ updateListConflictHighlighting(oldlength + 1)
+ }
+ }).fail(function () {
+ toggleLoadingPage(false);
+ $("#retrylabel").css('display', 'inline-block');
+ $('#retry').css('display', 'inline-block');
+ });
+ }
+ }
+ });
+}
+
+
+
+/*Listen for update mssage coming from popup*/
+chrome.runtime.onMessage.addListener(
+ function (request, sender, sendResponse) {
+ if (request.command == "updateCourseList") {
+ updateListConflictHighlighting(0);
+ }
+ }
+);
+
+
function toggleLoadingPage(loading) {
if (loading) {
+ doneLoading = false;
$('#loader').css('display', 'inline-block');
$("#nextlabel").css('display', 'inline-block');
} else {
+ doneLoading = true;
$('#loader').hide();
$("#nextlabel").hide();
}
@@ -522,45 +545,25 @@ function toggleDescriptionLoading(loading) {
}
}
-function loadNextPages() {
- chrome.storage.sync.get('loadAll', function (data) {
- if (data.loadAll) {
- let link = next.prop('href');
- if (doneLoading && next && link) {
- toggleLoadingPage(true);
- doneLoading = false;
- $.get(link, function (response) {
- if (response) {
- var nextpage = $('').html(response).contents();
- var current = $('tbody');
- var oldlength = $('tbody tr').length;
- var last = current.find('.course_header>h2:last').text();
- next = nextpage.find("#next_nav_link");
- doneLoading = true;
- $("#nextlabel").hide();
- $('#loader').hide();
- var newrows = [];
- nextpage.find('tbody>tr').each(function () {
- let hasCourseHead = $(this).find('td').hasClass("course_header");
- if (!(hasCourseHead && $(this).has('th').length == 0))
- $(this).append(extensionButton());
- if (!(hasCourseHead && last == $(this).find('td').text()))
- newrows.push($(this));
- });
- current.append(newrows);
- update(oldlength + 1)
- }
- }).fail(function () {
- doneLoading = true;
- toggleLoadingPage(false);
- $("#retrylabel").css('display', 'inline-block');
- $('#retry').css('display', 'inline-block');
- });
- }
- }
- });
+function toggleSnackbar() {
+ setTimeout(function () {
+ $("#snackbar").attr("class", "show");
+ }, 200);
+ setTimeout(function () {
+ $("#snackbar").attr("class", "");
+ }, 3000);
}
+$(document).keydown(function (e) {
+ /*Close Modal when hit escape*/
+ if (e.keyCode == 27) {
+ close();
+ } else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
+ saveCourse();
+ }
+});
+
+
function allowClosing() {
$('.close').click(function () {
close();
diff --git a/js/qol.js b/js/qol.js
deleted file mode 100644
index 08a5b642..00000000
--- a/js/qol.js
+++ /dev/null
@@ -1,11 +0,0 @@
-if (document.querySelector('#fos_fl')) {
- let params = (new URL(document.location)).searchParams;
- let dep = params.get("fos_fl");
- let level = params.get("level");
- if (dep && level) {
- if (dep.length == 3 && (level == 'U' || level == 'L' || level == 'G')) {
- document.querySelector('#fos_fl').value = dep;
- document.querySelector('#level').value = level;
- }
- }
-}
\ No newline at end of file
diff --git a/js/templates.js b/js/templates.js
deleted file mode 100644
index c8ba8b37..00000000
--- a/js/templates.js
+++ /dev/null
@@ -1,43 +0,0 @@
-function extensionButton() {
- return `
`
-}
-
-
-function mainModal() {
- return `
-
- ×
-
-
-
Computer Fluency (C S 302)
-
with Bruce Porter
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
`
-}
\ No newline at end of file
diff --git a/js/utplanner.js b/js/utplanner.js
index 2592e3a7..b3c54023 100644
--- a/js/utplanner.js
+++ b/js/utplanner.js
@@ -2,12 +2,12 @@ if ($('html').hasClass('gr__utexas_collegescheduler_com')) {
$.initialize("table.section-detail-grid", function () {
$(this).find('thead>tr').append('