cleaned up code
This commit is contained in:
@@ -34,9 +34,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src='js/config.js'></script>
|
||||||
<script src='js/lib/html2canvas.min.js'></script>
|
<script src='js/lib/html2canvas.min.js'></script>
|
||||||
<script src='js/lib/ics.min.js'></script>
|
<script src='js/lib/ics.min.js'></script>
|
||||||
<script src='js/config.js'></script>
|
|
||||||
<script src='js/util.js'></script>
|
<script src='js/util.js'></script>
|
||||||
<script src='js/Template.js'></script>
|
<script src='js/Template.js'></script>
|
||||||
<script src='js/calendar.js'></script>
|
<script src='js/calendar.js'></script>
|
||||||
@@ -308,21 +308,17 @@ function updateStatus(sendResponse) {
|
|||||||
var object = $('<div/>').html(result).contents();
|
var object = $('<div/>').html(result).contents();
|
||||||
let newstatus = object.find('[data-th="Status"]').text();
|
let newstatus = object.find('[data-th="Status"]').text();
|
||||||
let registerlink = object.find('td[data-th="Add"] a');
|
let registerlink = object.find('td[data-th="Add"] a');
|
||||||
if (registerlink) {
|
if (registerlink)
|
||||||
registerlink = registerlink.attr('href');
|
registerlink = registerlink.attr('href');
|
||||||
}
|
|
||||||
var haschanged = (newstatus == oldstatus && registerlink == oldlink);
|
var haschanged = (newstatus == oldstatus && registerlink == oldlink);
|
||||||
if (!haschanged) {
|
if (!haschanged)
|
||||||
console.log(c.unique + ' updated from ' + oldstatus + " to " + newstatus + " and " + oldlink + " to " + registerlink);
|
console.log(c.unique + ' updated from ' + oldstatus + " to " + newstatus + " and " + oldlink + " to " + registerlink);
|
||||||
}
|
|
||||||
nochange &= haschanged;
|
nochange &= haschanged;
|
||||||
c.registerlink = registerlink;
|
c.registerlink = registerlink;
|
||||||
c.status = newstatus;
|
c.status = newstatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log('Not logged into UT Coursebook. Could not update class statuses.');
|
console.log('Not logged into UT Coursebook. Could not update class statuses.');
|
||||||
@@ -333,9 +329,6 @@ function updateStatus(sendResponse) {
|
|||||||
savedCourses: courses
|
savedCourses: courses
|
||||||
});
|
});
|
||||||
console.log('updated status');
|
console.log('updated status');
|
||||||
} else {
|
|
||||||
// console.log('no change');
|
|
||||||
}
|
}
|
||||||
// console.log("updated status' and registerlinks");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,6 @@ var curr_course = {}
|
|||||||
|
|
||||||
$("#calendar").after(Template.calendarModal());
|
$("#calendar").after(Template.calendarModal());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chrome.storage.sync.get("savedCourses", function (data) {
|
chrome.storage.sync.get("savedCourses", function (data) {
|
||||||
// Iterate through each saved course and add to 'event'
|
// Iterate through each saved course and add to 'event'
|
||||||
saved_courses = data.savedCourses;
|
saved_courses = data.savedCourses;
|
||||||
@@ -75,14 +73,13 @@ function setUpModal() {
|
|||||||
|
|
||||||
function setRegisterButton(status, registerlink) {
|
function setRegisterButton(status, registerlink) {
|
||||||
if (canNotRegister(status, registerlink))
|
if (canNotRegister(status, registerlink))
|
||||||
$("#register").text("Can't Register").css("background-color", "#FF5722");
|
$("#register").text("Can't Register").css("background-color", Colors.closed);
|
||||||
else if (status.includes("waitlisted"))
|
else if (status.includes("waitlisted"))
|
||||||
$("#register").text("Join Waitlist").css("background-color", "#FF9800");
|
$("#register").text("Join Waitlist").css("background-color", Colors.waitlisted);
|
||||||
else
|
else
|
||||||
$("#register").text("Register").css("background-color", "#4CAF50");
|
$("#register").text("Register").css("background-color", Colors.open);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function canNotRegister(status, registerlink) {
|
function canNotRegister(status, registerlink) {
|
||||||
return status.includes("closed") || status.includes("cancelled") || !status || !registerlink
|
return status.includes("closed") || status.includes("cancelled") || !status || !registerlink
|
||||||
}
|
}
|
||||||
@@ -100,15 +97,15 @@ function buildTimeTitle(datetimearr) {
|
|||||||
|
|
||||||
|
|
||||||
// Iterate through each saved course and add to 'event'
|
// Iterate through each saved course and add to 'event'
|
||||||
function buildEventSource(savedCourses) {
|
function buildEventSource(saved_courses) {
|
||||||
color_counter = 0;
|
color_counter = 0;
|
||||||
let event_source = [];
|
let event_source = [];
|
||||||
var hours = 0;
|
var hours = 0;
|
||||||
for (let i = 0; i < savedCourses.length; i++) {
|
for (let i = 0; i < saved_courses.length; i++) {
|
||||||
let {
|
let {
|
||||||
coursename,
|
coursename,
|
||||||
datetimearr
|
datetimearr
|
||||||
} = savedCourses[i];
|
} = saved_courses[i];
|
||||||
let number = seperateCourseNameParts(coursename).number;
|
let number = seperateCourseNameParts(coursename).number;
|
||||||
hours += parseInt(number.charAt(0));
|
hours += parseInt(number.charAt(0));
|
||||||
for (let j = 0; j < datetimearr.length; j++) {
|
for (let j = 0; j < datetimearr.length; j++) {
|
||||||
@@ -118,11 +115,15 @@ function buildEventSource(savedCourses) {
|
|||||||
}
|
}
|
||||||
color_counter++;
|
color_counter++;
|
||||||
}
|
}
|
||||||
$("#hours").text(hours + " Hours");
|
displayMetaData(hours, saved_courses);
|
||||||
$("#num").text(savedCourses.length + " Courses");
|
|
||||||
return event_source;
|
return event_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayMetaData(hours, saved_courses) {
|
||||||
|
$("#hours").text(hours + " Hours");
|
||||||
|
$("#num").text(saved_courses.length + " Courses");
|
||||||
|
}
|
||||||
|
|
||||||
//create the event object for every section
|
//create the event object for every section
|
||||||
function setEventForSection(session, colorCounter, i) {
|
function setEventForSection(session, colorCounter, i) {
|
||||||
let full_day = days.get(session[0]);
|
let full_day = days.get(session[0]);
|
||||||
@@ -178,8 +179,6 @@ chrome.runtime.onMessage.addListener(
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#info").click(() => {
|
$("#info").click(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.open(curr_course.link);
|
window.open(curr_course.link);
|
||||||
|
|||||||
13
js/config.js
13
js/config.js
@@ -11,8 +11,14 @@ class Colors {
|
|||||||
'#FF5252', '#E91E63', '#009688', '#00BCD4',
|
'#FF5252', '#E91E63', '#009688', '#00BCD4',
|
||||||
'#4E342E', '#424242', '#9E9E9E'
|
'#4E342E', '#424242', '#9E9E9E'
|
||||||
];
|
];
|
||||||
}
|
static open = "#4CAF50";
|
||||||
|
static waitlisted = "#FF9800";
|
||||||
|
static closed = "#FF5722";
|
||||||
|
|
||||||
|
static highlight_conflict = "#F44336";
|
||||||
|
static highlight_default = "#333333";
|
||||||
|
static highlight_saved = "#4CAF50";
|
||||||
|
}
|
||||||
|
|
||||||
class Export {
|
class Export {
|
||||||
static png_options = {
|
static png_options = {
|
||||||
@@ -21,4 +27,9 @@ class Export {
|
|||||||
removeContainer: true,
|
removeContainer: true,
|
||||||
async: true,
|
async: true,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Text {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
console.log(`UT Registration Plus is running on this page: ${window.location.href}`);
|
console.log(`UT Registration Plus is running on this page: ${window.location.href}`);
|
||||||
|
|
||||||
var curr_course = {}
|
var curr_course = {}
|
||||||
var semesterCode = new URL(window.location.href).pathname.split('/')[4];
|
|
||||||
var doneLoading = true;
|
|
||||||
|
var semester_code = new URL(window.location.href).pathname.split('/')[4];
|
||||||
|
var done_loading = true;
|
||||||
updateListConflictHighlighting();
|
updateListConflictHighlighting();
|
||||||
|
|
||||||
|
|
||||||
@@ -64,45 +66,6 @@ $("body").on('click', '#distButton', function () {
|
|||||||
getDistribution(curr_course);
|
getDistribution(curr_course);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#myModal").on('click', '#saveCourse', function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
saveCourse();
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#Syllabi").click(function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
window.open(curr_course["links"]["syllabi"]);
|
|
||||||
}, Timing.button_delay);
|
|
||||||
});
|
|
||||||
$("#rateMyProf").click(function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
window.open(curr_course["links"]["rate_my_prof"]);
|
|
||||||
}, Timing.button_delay);
|
|
||||||
});
|
|
||||||
$("#eCIS").click(function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
window.open(curr_course["links"]["ecis"]);
|
|
||||||
}, Timing.button_delay);
|
|
||||||
});
|
|
||||||
$("#textbook").click(function () {
|
|
||||||
setTimeout(function () {
|
|
||||||
window.open(curr_course["links"]["textbook"]);
|
|
||||||
}, Timing.button_delay);
|
|
||||||
});
|
|
||||||
$("#semesters").on('change', function () {
|
|
||||||
let sem = $(this).val();
|
|
||||||
sem = sem == "Aggregate" ? undefined : sem;
|
|
||||||
getDistribution(curr_course, sem);
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#retry").click(function () {
|
|
||||||
$("#retrylabel").hide();
|
|
||||||
$(this).hide();
|
|
||||||
loadNextPages();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateLinks(course_info, first_name) {
|
function updateLinks(course_info, first_name) {
|
||||||
let {
|
let {
|
||||||
@@ -124,7 +87,7 @@ function buildCourseLinks(course_info) {
|
|||||||
prof_name
|
prof_name
|
||||||
} = course_info
|
} = course_info
|
||||||
links = {
|
links = {
|
||||||
"textbook": `https://www.universitycoop.com/adoption-search-results?sn=${semesterCode}__${department}__${number}__${unique}`,
|
"textbook": `https://www.universitycoop.com/adoption-search-results?sn=${semester_code}__${department}__${number}__${unique}`,
|
||||||
"syllabi": `https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=${department}&course_number=${number}&course_title=&unique=&instructor_first=&instructor_last=${prof_name}&course_type=In+Residence&search=Search`,
|
"syllabi": `https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=${department}&course_number=${number}&course_title=&unique=&instructor_first=&instructor_last=${prof_name}&course_type=In+Residence&search=Search`,
|
||||||
//default ones (before first name can be used)
|
//default ones (before first name can be used)
|
||||||
"rate_my_prof": "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255",
|
"rate_my_prof": "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255",
|
||||||
@@ -221,18 +184,18 @@ function updateListConflictHighlighting(start = 0) {
|
|||||||
$('table').find('tr').each(function (i) {
|
$('table').find('tr').each(function (i) {
|
||||||
if (i >= start) {
|
if (i >= start) {
|
||||||
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
|
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
|
||||||
var thisForm = this;
|
var this_form = this;
|
||||||
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
var unique = $(this).find('td[data-th="Unique"]').text();
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "isSingleConflict",
|
command: "isSingleConflict",
|
||||||
dtarr: getDayTimeArray(this),
|
dtarr: getDayTimeArray(this),
|
||||||
unique: uniquenum
|
unique: unique
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
let {
|
let {
|
||||||
isConflict,
|
isConflict,
|
||||||
alreadyContains
|
alreadyContains
|
||||||
} = response
|
} = response
|
||||||
updateTextHighlighting($(thisForm).find('td'), canHighlight, isConflict, alreadyContains);
|
updateTextHighlighting($(this_form).find('td'), canHighlight, isConflict, alreadyContains);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,23 +204,24 @@ function updateListConflictHighlighting(start = 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateTextHighlighting(tds, canHighlight, isConflict, alreadyContains) {
|
function updateTextHighlighting(tds, canHighlight, isConflict, alreadyContains) {
|
||||||
|
let current_color = rgb2hex(tds.css('color'));
|
||||||
if (isConflict && canHighlight && !alreadyContains) {
|
if (isConflict && canHighlight && !alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(244, 67, 54)')
|
if (current_color != Colors.highlight_conflict)
|
||||||
tds.css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
|
tds.css('color', Colors.highlight_conflict).css('text-decoration', 'line-through').css('font-weight', 'normal');
|
||||||
} else if (!alreadyContains) {
|
} else if (!alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(51, 51, 51)')
|
if (tds.css('color') != Colors.highlight_default)
|
||||||
tds.css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
|
tds.css('color', Colors.highlight_default).css('text-decoration', 'none').css('font-weight', 'normal');
|
||||||
}
|
}
|
||||||
if (alreadyContains) {
|
if (alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(76, 175, 80)')
|
if (tds.css('color') != Colors.highlight_saved)
|
||||||
tds.css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
|
tds.css('color', Colors.highlight_saved).css('text-decoration', 'none').css('font-weight', 'bold');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* For a row, get the date-time-array for checking conflicts*/
|
/* For a row, get the date-time-array for checking conflicts*/
|
||||||
function getDayTimeArray(row, course_info) {
|
function getDayTimeArray(row, course_info) {
|
||||||
var daytimearray = []
|
var day_time_array = []
|
||||||
let days = course_info ? course_info["time_data"]["days"] : $(row).find('td[data-th="Days"]>span').toArray().map(x => $(x).text().trim());
|
let days = course_info ? course_info["time_data"]["days"] : $(row).find('td[data-th="Days"]>span').toArray().map(x => $(x).text().trim());
|
||||||
let times = course_info ? course_info["time_data"]["times"] : $(row).find('td[data-th="Hour"]>span').toArray().map(x => $(x).text().trim());
|
let times = course_info ? course_info["time_data"]["times"] : $(row).find('td[data-th="Hour"]>span').toArray().map(x => $(x).text().trim());
|
||||||
let places = course_info ? course_info["time_data"]["places"] : $(row).find('td[data-th="Room"]>span').toArray().map(x => $(x).text().trim());
|
let places = course_info ? course_info["time_data"]["places"] : $(row).find('td[data-th="Room"]>span').toArray().map(x => $(x).text().trim());
|
||||||
@@ -268,20 +232,20 @@ function getDayTimeArray(row, course_info) {
|
|||||||
for (var j = 0; j < date.length; j++) {
|
for (var j = 0; j < date.length; j++) {
|
||||||
let letter = date.charAt(j);
|
let letter = date.charAt(j);
|
||||||
if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
|
if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
|
||||||
daytimearray.push(["TH", convertTime(time), place]);
|
day_time_array.push(["TH", convertTime(time), place]);
|
||||||
} else {
|
} else {
|
||||||
if (letter != "H")
|
if (letter != "H")
|
||||||
daytimearray.push([letter, convertTime(time), place]);
|
day_time_array.push([letter, convertTime(time), place]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return daytimearray;
|
return day_time_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertDateTimeArrToLine(date, time, place) {
|
function convertDateTimeArrToLine(date, time, place) {
|
||||||
var arr = seperateDays(date)
|
let arr = seperateDays(date)
|
||||||
var output = prettifyDaysText(arr)
|
let output = prettifyDaysText(arr)
|
||||||
var building = place.substring(0, place.search(/\d/) - 1);
|
let building = place.substring(0, place.search(/\d/) - 1);
|
||||||
building = building == "" ? "Undecided Location" : building;
|
building = building == "" ? "Undecided Location" : building;
|
||||||
return `${output} at ${time.replace(/\./g, '').replace(/\-/g, ' to ')} in <a style='font-size:medium' target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${building}</>`;
|
return `${output} at ${time.replace(/\./g, '').replace(/\-/g, ' to ')} in <a style='font-size:medium' target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${building}</>`;
|
||||||
}
|
}
|
||||||
@@ -319,9 +283,8 @@ function buildTimeTitle(course_info) {
|
|||||||
times,
|
times,
|
||||||
places
|
places
|
||||||
} = course_info["time_data"]
|
} = course_info["time_data"]
|
||||||
datetimearr = [];
|
|
||||||
var lines = [];
|
var lines = [];
|
||||||
for (var i = 0; i < days.length; i++) {
|
for (let i = 0; i < days.length; i++) {
|
||||||
var date = days[i];
|
var date = days[i];
|
||||||
var time = times[i];
|
var time = times[i];
|
||||||
var place = places[i];
|
var place = places[i];
|
||||||
@@ -382,7 +345,6 @@ function openDialog(course_info, res) {
|
|||||||
//close button
|
//close button
|
||||||
allowClosing();
|
allowClosing();
|
||||||
setChart(data);
|
setChart(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setChart(data) {
|
function setChart(data) {
|
||||||
@@ -468,26 +430,26 @@ function loadNextPages() {
|
|||||||
chrome.storage.sync.get('loadAll', function (data) {
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
if (data.loadAll) {
|
if (data.loadAll) {
|
||||||
let link = next.prop('href');
|
let link = next.prop('href');
|
||||||
if (doneLoading && next && link) {
|
if (done_loading && next && link) {
|
||||||
toggleLoadingPage(true);
|
toggleLoadingPage(true);
|
||||||
$.get(link, function (response) {
|
$.get(link, function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
var nextpage = $('<div/>').html(response).contents();
|
var next_page = $('<div/>').html(response).contents();
|
||||||
var current = $('tbody');
|
var current = $('tbody');
|
||||||
var oldlength = $('tbody tr').length;
|
var old_length = $('tbody tr').length;
|
||||||
var last = current.find('.course_header>h2:last').text();
|
var last = current.find('.course_header>h2:last').text();
|
||||||
next = nextpage.find("#next_nav_link");
|
next = next_page.find("#next_nav_link");
|
||||||
toggleLoadingPage(false);
|
toggleLoadingPage(false);
|
||||||
var newrows = [];
|
var new_rows = [];
|
||||||
nextpage.find('tbody>tr').each(function () {
|
next_page.find('tbody>tr').each(function () {
|
||||||
let hasCourseHead = $(this).find('td').hasClass("course_header");
|
let has_course_header = $(this).find('td').hasClass("course_header");
|
||||||
if (!(hasCourseHead && $(this).has('th').length == 0))
|
if (!(has_course_header && $(this).has('th').length == 0))
|
||||||
$(this).append(Template.extensionButton());
|
$(this).append(Template.extensionButton());
|
||||||
if (!(hasCourseHead && last == $(this).find('td').text()))
|
if (!(has_course_header && last == $(this).find('td').text()))
|
||||||
newrows.push($(this));
|
new_rows.push($(this));
|
||||||
});
|
});
|
||||||
current.append(newrows);
|
current.append(new_rows);
|
||||||
updateListConflictHighlighting(oldlength + 1)
|
updateListConflictHighlighting(old_length + 1)
|
||||||
}
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
toggleLoadingPage(false);
|
toggleLoadingPage(false);
|
||||||
@@ -499,7 +461,43 @@ function loadNextPages() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#myModal").on('click', '#saveCourse', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
saveCourse();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#Syllabi").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["syllabi"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
$("#rateMyProf").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["rate_my_prof"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
$("#eCIS").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["ecis"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
$("#textbook").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["textbook"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
$("#semesters").on('change', function () {
|
||||||
|
let sem = $(this).val();
|
||||||
|
sem = sem == "Aggregate" ? undefined : sem;
|
||||||
|
getDistribution(curr_course, sem);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#retry").click(function () {
|
||||||
|
$("#retrylabel").hide();
|
||||||
|
$(this).hide();
|
||||||
|
loadNextPages();
|
||||||
|
});
|
||||||
|
|
||||||
/*Listen for update mssage coming from popup*/
|
/*Listen for update mssage coming from popup*/
|
||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
@@ -513,11 +511,11 @@ chrome.runtime.onMessage.addListener(
|
|||||||
|
|
||||||
function toggleLoadingPage(loading) {
|
function toggleLoadingPage(loading) {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
doneLoading = false;
|
done_loading = false;
|
||||||
$('#loader').css('display', 'inline-block');
|
$('#loader').css('display', 'inline-block');
|
||||||
$("#nextlabel").css('display', 'inline-block');
|
$("#nextlabel").css('display', 'inline-block');
|
||||||
} else {
|
} else {
|
||||||
doneLoading = true;
|
done_loading = true;
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
$("#nextlabel").hide();
|
$("#nextlabel").hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,24 +6,23 @@ $(function () {
|
|||||||
console.log(window.location.href);
|
console.log(window.location.href);
|
||||||
var importbutton = "<button class='matbut' id='import' style='margin:20px 0px 20px 0px;'><span style='font-size:small'>Import into </span><b>UT Reg Plus<b></h2></button><br>";
|
var importbutton = "<button class='matbut' id='import' style='margin:20px 0px 20px 0px;'><span style='font-size:small'>Import into </span><b>UT Reg Plus<b></h2></button><br>";
|
||||||
waitlist = !(window.location.href.includes('https://utdirect.utexas.edu/registration/classlist.WBX'));
|
waitlist = !(window.location.href.includes('https://utdirect.utexas.edu/registration/classlist.WBX'));
|
||||||
if(waitlist){
|
if (waitlist) {
|
||||||
sem = $('[name="s_ccyys"]').val();
|
sem = $('[name="s_ccyys"]').val();
|
||||||
$("[href='#top']").before(importbutton);
|
$("[href='#top']").before(importbutton);
|
||||||
} else {
|
} else {
|
||||||
sem = $("option[selected='selected']").val();
|
sem = $("option[selected='selected']").val();
|
||||||
$("table").after(importbutton);
|
$("table").after(importbutton);
|
||||||
}
|
}
|
||||||
console.log(sem);
|
|
||||||
$("#import").prepend("<div id='snackbar'>defaultmessage..</div>");
|
$("#import").prepend("<div id='snackbar'>defaultmessage..</div>");
|
||||||
$("#import").click(function () {
|
$("#import").click(function () {
|
||||||
if(waitlist){
|
if (waitlist) {
|
||||||
$(".tbg").last().find(".tbon>td:first-child").each(function () {
|
$(".tbg").last().find(".tbon>td:first-child").each(function () {
|
||||||
let unique = $(this).text().replace(/\s/g, '');
|
let unique = $(this).text().replace(/\s/g, '');
|
||||||
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
||||||
getInfo();
|
getInfo();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$("tr>td:first-child").each(function(){
|
$("tr>td:first-child").each(function () {
|
||||||
let unique = $(this).text().replace(/\s/g, '');
|
let unique = $(this).text().replace(/\s/g, '');
|
||||||
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
|
||||||
getInfo();
|
getInfo();
|
||||||
|
|||||||
31
js/util.js
31
js/util.js
@@ -6,26 +6,20 @@ const days = new Map([
|
|||||||
["F", "Friday"]
|
["F", "Friday"]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const semOrder = {
|
|
||||||
"Spring": 0,
|
|
||||||
"Fall": 1,
|
|
||||||
"Summer": 2,
|
|
||||||
"Winter": 3
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getStatusColor(status) {
|
function getStatusColor(status) {
|
||||||
let color = "black";
|
let color = "black";
|
||||||
if (status.includes("open")) {
|
if (status.includes("open")) {
|
||||||
color = "#4CAF50";
|
color = Colors.open;
|
||||||
} else if (status.includes("waitlisted")) {
|
} else if (status.includes("waitlisted")) {
|
||||||
color = "#FF9800"
|
color = Colors.waitlisted;
|
||||||
} else if (status.includes("closed") || status.includes("cancelled")) {
|
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||||
color = "#FF5722";
|
color = Colors.closed;
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function buildQuery(course_data, sem) {
|
function buildQuery(course_data, sem) {
|
||||||
let query = !sem ? "select * from agg" : "select * from grades";
|
let query = !sem ? "select * from agg" : "select * from grades";
|
||||||
query += " where dept like '%" + course_data["department"] + "%'";
|
query += " where dept like '%" + course_data["department"] + "%'";
|
||||||
@@ -106,6 +100,12 @@ function prettifyDaysText(arr) {
|
|||||||
|
|
||||||
|
|
||||||
function semesterSort(semA, semB) {
|
function semesterSort(semA, semB) {
|
||||||
|
let semOrder = {
|
||||||
|
"Spring": 0,
|
||||||
|
"Fall": 1,
|
||||||
|
"Summer": 2,
|
||||||
|
"Winter": 3
|
||||||
|
}
|
||||||
let aName = semA.split(' ')[0];
|
let aName = semA.split(' ')[0];
|
||||||
let aYear = parseInt(semA.split(' ')[1]);
|
let aYear = parseInt(semA.split(' ')[1]);
|
||||||
let bName = semB.split(' ')[0];
|
let bName = semB.split(' ')[0];
|
||||||
@@ -298,4 +298,13 @@ function reformatDateTime(dtl1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rgb2hex(rgb) {
|
||||||
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||||
|
|
||||||
|
function hex(x) {
|
||||||
|
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||||||
|
}
|
||||||
|
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
||||||
}
|
}
|
||||||
@@ -144,8 +144,6 @@ function buildTimeTitle(times) {
|
|||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function makeLine(date, time, place) {
|
function makeLine(date, time, place) {
|
||||||
var arr = seperateDays(date)
|
var arr = seperateDays(date)
|
||||||
var output = prettifyDaysText(arr)
|
var output = prettifyDaysText(arr)
|
||||||
@@ -154,28 +152,6 @@ function makeLine(date, time, place) {
|
|||||||
return `${output} at ${time.replace(/\./g, '').replace(/\-/g, ' to ')} in <a style='font-size:medium' target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${building}</>`;
|
return `${output} at ${time.replace(/\./g, '').replace(/\-/g, ' to ')} in <a style='font-size:medium' target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${building}</>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function prettifyDaysText(arr) {
|
|
||||||
var output = "";
|
|
||||||
if (arr.length > 2) {
|
|
||||||
for (var i = 0; i < arr.length; i++) {
|
|
||||||
if (i < arr.length - 1)
|
|
||||||
output += arr[i] + ", "
|
|
||||||
if (i == arr.length - 2)
|
|
||||||
output += "and ";
|
|
||||||
if (i == arr.length - 1)
|
|
||||||
output += arr[i];
|
|
||||||
}
|
|
||||||
} else if (arr.length == 2) {
|
|
||||||
output = arr[0] + " and " + arr[1];
|
|
||||||
} else {
|
|
||||||
output = arr[0];
|
|
||||||
}
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
|
|
||||||
function setChart(data) {
|
function setChart(data) {
|
||||||
//set up the chart
|
//set up the chart
|
||||||
toggleChartLoading(false);
|
toggleChartLoading(false);
|
||||||
|
|||||||
@@ -16,19 +16,19 @@
|
|||||||
],
|
],
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"css": ["css/styles.css"],
|
"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": ["js/config.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/util.js",
|
||||||
"js/Template.js", "js/courseCatalog.js"
|
"js/Template.js", "js/courseCatalog.js"
|
||||||
],
|
],
|
||||||
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
|
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
|
||||||
}, {
|
}, {
|
||||||
"css": ["css/styles.css"],
|
"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": ["js/config.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/util.js",
|
||||||
"js/Template.js", "js/utPlanner.js"
|
"js/Template.js", "js/utPlanner.js"
|
||||||
],
|
],
|
||||||
"matches": ["https://utexas.collegescheduler.com/*"]
|
"matches": ["https://utexas.collegescheduler.com/*"]
|
||||||
}, {
|
}, {
|
||||||
"css": ["css/styles.css"],
|
"css": ["css/styles.css"],
|
||||||
"js": ["js/lib/moment.min.js", "js/lib/sql-memory-growth.js", "js/lib/highcharts.js", "js/lib/jquery-3.3.1.min.js", "js/import.js"],
|
"js": ["js/config.js", "js/lib/moment.min.js", "js/lib/sql-memory-growth.js", "js/lib/highcharts.js", "js/lib/jquery-3.3.1.min.js", "js/import.js"],
|
||||||
"matches": ["https://utdirect.utexas.edu/registrar/waitlist/wl_see_my_waitlists.WBX", "https://utdirect.utexas.edu/registration/classlist.WBX*"]
|
"matches": ["https://utdirect.utexas.edu/registrar/waitlist/wl_see_my_waitlists.WBX", "https://utdirect.utexas.edu/registration/classlist.WBX*"]
|
||||||
}],
|
}],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
|
|||||||
Reference in New Issue
Block a user