diff --git a/js/courseCatalog.js b/js/courseCatalog.js
index f4d9ad89..afc1a966 100644
--- a/js/courseCatalog.js
+++ b/js/courseCatalog.js
@@ -1,23 +1,7 @@
-var rmpLink;
-var next;
+var next = $("#next_nav_link");
var bottom;
-var eCISLink;
-var textbookLink;
-var coursename;
-var profname;
-var profinit;
-var uniquenum;
-var profurl;
-var registerlink;
-var department;
-var course_nbr;
-var datetimearr = [];
-var chart;
-var description;
-var status;
var semesterCode;
-var isIndividual = false;
-var done = true;
+var doneLoading = true;
var curr_course = {}
@@ -29,27 +13,14 @@ var curr_course = {}
console.log('UT Registration Plus is running on this page.');
semesterCode = new URL(window.location.href).pathname.split('/')[4];
+
+
$(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");
- 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;
- }
- }
-}
-
-
-next = $("#next_nav_link");
if (next) {
chrome.storage.sync.get('loadAll', function (data) {
if (data.loadAll) {
@@ -58,50 +29,18 @@ if (next) {
});
}
-
-
//make heading and modal
if (!$("#kw_results_table").length) {
$("table thead th:last-child").after('
Plus | ');
$("table").after(`
-
+
Loading Courses
Failed to Load Courses
`);
- var modhtml = `
-
-
×
-
-
-
Computer Fluency (C S 302)
-
with Bruce Porter
-
-
-
-
-
-
-
-
-
-
-
-
-
`;
- $("#container").prepend(modhtml);
+ $("#container").prepend(mainModal());
$("#myModal").prepend("save course popup...
");
//go through all the rows in the list
$('table').find('tr').each(function () {
@@ -239,7 +178,6 @@ function buildBasicCourseInfo(row, course_name, individual) {
}
-
function buildTimeTitle(course_info) {
$("h2.dateTimePlace").remove();
let {
@@ -283,43 +221,48 @@ function getCourseInfo(row) {
return curr_course;
}
+
+function toggleLoadingPage(loading) {
+ if (loading) {
+ $('#loader').css('display', 'inline-block');
+ $("#nextlabel").css('display', 'inline-block');
+ } else {
+ $('#loader').hide();
+ $("#nextlabel").hide();
+ }
+}
+
function loadNextPages() {
chrome.storage.sync.get('loadAll', function (data) {
if (data.loadAll) {
let link = next.prop('href');
- if (done && next && link) {
- $("#nextlabel").css('display', 'inline-block');
- $('#loader').css('display', 'inline-block');
- done = false;
+ 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;
- // console.log(oldlength);
var last = current.find('.course_header>h2:last').text();
- // console.log(last);
next = nextpage.find("#next_nav_link");
- done = true;
+ 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)) {
+ if (!(hasCourseHead && $(this).has('th').length == 0))
$(this).append(` | `);
- }
- if (!(hasCourseHead && last == $(this).find('td').text())) {
+ if (!(hasCourseHead && last == $(this).find('td').text()))
newrows.push($(this));
- }
});
current.append(newrows);
update(oldlength + 1)
}
}).fail(function () {
- done = true;
- $("#nextlabel").hide();
- $('#loader').hide();
+ doneLoading = true;
+ toggleLoadingPage(false);
$("#retrylabel").css('display', 'inline-block');
$('#retry').css('display', 'inline-block');
});
@@ -367,9 +310,7 @@ function toggleSnackbar() {
/* 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) {
chrome.storage.sync.get('courseConflictHighlight', function (data) {
- var red = 0;
- var black = 0;
- var green = 0;
+ let canHighlight = data.courseConflictHighlight;
$('table').find('tr').each(function (i) {
if (i >= start) {
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
@@ -380,24 +321,11 @@ function update(start) {
dtarr: getDayTimeArray(this),
unique: uniquenum
}, function (response) {
- var tds = $(thisForm).find('td');
- if (response.isConflict && data.courseConflictHighlight && !response.alreadyContains) {
- if (tds.css('color') != 'rgb(244, 67, 54)') {
- red++;
- tds.css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
- }
- } else if (!response.alreadyContains) {
- if (tds.css('color') != 'rgb(51, 51, 51)') {
- black++;
- tds.css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
- }
- }
- if (response.alreadyContains) {
- if (tds.css('color') != 'rgb(76, 175, 80)') {
- green++;
- tds.css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
- }
- }
+ let {
+ isConflict,
+ alreadyContains
+ } = response
+ updateTextHighlighting($(thisForm).find('td'), canHighlight, isConflict, alreadyContains);
});
}
}
@@ -405,6 +333,21 @@ function update(start) {
});
}
+function updateTextHighlighting(tds, canHighlight, isConflict, alreadyContains) {
+ if (isConflict && canHighlight && !alreadyContains) {
+ if (tds.css('color') != 'rgb(244, 67, 54)')
+ tds.css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
+ } else if (!alreadyContains) {
+ if (tds.css('color') != 'rgb(51, 51, 51)')
+ tds.css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
+ }
+ if (alreadyContains) {
+ if (tds.css('color') != 'rgb(76, 175, 80)')
+ tds.css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
+ }
+}
+
+
/* For a row, get the date-time-array for checking conflicts*/
function getDayTimeArray(row, course_info) {
var daytimearray = []
@@ -536,8 +479,8 @@ function close() {
}
function setChart(data) {
- //set up the chart
- chart = Highcharts.chart('chart', buildChartConfig(data), function (chart) { // on complete
+ // set up the chart
+ Highcharts.chart('chart', buildChartConfig(data), function (chart) { // on complete
if (data.length == 0) {
//if no data, then show the message and hide the series
chart.renderer.text('Could not find data for this Instructor teaching this Course.', 100, 120)
@@ -552,7 +495,6 @@ function setChart(data) {
ser.hide();
});
}
-
});
}
@@ -621,5 +563,6 @@ function updateLinks(course_info, first_name) {
function extractFirstName(response_node) {
let full_name = response_node.find('td[data-th="Instructor"]').text().split(', ');
let first = full_name[full_name.length - 1];
+ first = first.indexOf(' ') > 0 ? first.split(' ')[0] : first;
return capitalizeString(first);
}
\ No newline at end of file
diff --git a/js/qol.js b/js/qol.js
new file mode 100644
index 00000000..08a5b642
--- /dev/null
+++ b/js/qol.js
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 00000000..b2ed40b6
--- /dev/null
+++ b/js/templates.js
@@ -0,0 +1,32 @@
+function mainModal() {
+ return `
+
+
×
+
+
+
Computer Fluency (C S 302)
+
with Bruce Porter
+
+
+
+
+
+
+
+
+
+
+
+
+
`
+}
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 4f53263a..4d4c8a2f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -17,12 +17,12 @@
"content_scripts": [{
"css": ["css/styles.css"],
"js": ["js/lib/moment.min.js", "js/lib/highcharts.js", "js/lib/jquery-3.3.1.min.js", "js/lib/jquery.initialize.min.js", "js/config.js", "js/util.js",
- "js/courseCatalog.js"
+ "js/qol.js", "js/courseCatalog.js"
],
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
}, {
"css": ["css/styles.css"],
- "js": ["js/lib/moment.min.js", "js/lib/highcharts.js", "js/lib/jquery-3.3.1.min.js", "js/lib/jquery.initialize.min.js", "js/config.js", "js/util.js", "js/utPlanner.js"],
+ "js": ["js/lib/moment.min.js", "js/lib/highcharts.js", "js/lib/jquery-3.3.1.min.js", "js/lib/jquery.initialize.min.js", "js/config.js", "js/util.js", "js/templates.js", "js/utPlanner.js"],
"matches": ["https://utexas.collegescheduler.com/*"]
}, {
"css": ["css/styles.css"],