reformated and reorganized, cleaned up course catalog script
This commit is contained in:
@@ -3,31 +3,37 @@
|
|||||||
<head>
|
<head>
|
||||||
<link rel='stylesheet' href='css/fullcalendar.min.css' />
|
<link rel='stylesheet' href='css/fullcalendar.min.css' />
|
||||||
<link rel='stylesheet' href='css/_materialFullCalendar.css' />
|
<link rel='stylesheet' href='css/_materialFullCalendar.css' />
|
||||||
<script src='js/jquery-3.3.1.min.js'></script>
|
<script src='js/lib/jquery-3.3.1.min.js'></script>
|
||||||
<script src='js/moment.min.js'></script>
|
<script src='js/lib/moment.min.js'></script>
|
||||||
<script src='js/fullcalendar.min.js'></script>
|
<script src='js/lib/fullcalendar.min.js'></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div style='display:flex'>
|
<div style='display:flex'>
|
||||||
<div id='calendar' style="flex-grow: 1"></div>
|
<div id='calendar' style="flex-grow: 1"></div>
|
||||||
<div class="card" id="header" style="text-align:center;margin:5px 0px 0px 15px;display: inline-table;padding-bottom: 5px;">
|
<div class="card" id="header"
|
||||||
<h1 id='hours' style="font-size:30px;font-weight:500; border-bottom: 3px solid black;display: inline-block;padding-bottom: 5px;margin-bottom: 5px;">0
|
style="text-align:center;margin:5px 0px 0px 15px;display: inline-table;padding-bottom: 5px;">
|
||||||
|
<h1 id='hours'
|
||||||
|
style="font-size:30px;font-weight:500; border-bottom: 3px solid black;display: inline-block;padding-bottom: 5px;margin-bottom: 5px;">
|
||||||
|
0
|
||||||
hours</h1>
|
hours</h1>
|
||||||
<h1 id='num' style="font-size:20px;font-weight:500; margin: 2px;">0
|
<h1 id='num' style="font-size:20px;font-weight:500; margin: 2px;">0
|
||||||
Courses</h1>
|
Courses</h1>
|
||||||
<br>
|
<br>
|
||||||
<div style="margin:5px;display: flex;flex-direction: column;">
|
<div style="margin:5px;display: flex;flex-direction: column;">
|
||||||
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;white-space: nowrap;text-align: center;">Clear
|
<button id="clear" class="matbut"
|
||||||
|
style="font-size:medium; background:#4CAF50;margin: 10px;white-space: nowrap;text-align: center;">Clear
|
||||||
All</button>
|
All</button>
|
||||||
<button id="save" class="matbut" style="font-size:medium; background:#FF9800;margin: 10px;white-space: nowrap;text-align: center;">Save
|
<button id="save" class="matbut"
|
||||||
|
style="font-size:medium; background:#FF9800;margin: 10px;white-space: nowrap;text-align: center;">Save
|
||||||
as PNG</button>
|
as PNG</button>
|
||||||
<button id="export" class="matbut" style="font-size:medium; background:#FF0000;margin: 10px;white-space: nowrap;text-align: center;">Export
|
<button id="export" class="matbut"
|
||||||
|
style="font-size:medium; background:#FF0000;margin: 10px;white-space: nowrap;text-align: center;">Export
|
||||||
Cal</button>
|
Cal</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src='js/html2canvas.min.js'></script>
|
<script src='js/lib/html2canvas.min.js'></script>
|
||||||
<script src='js/ics.min.js'></script>
|
<script src='js/lib/ics.min.js'></script>
|
||||||
<script src='js/calendar.js'></script>
|
<script src='js/calendar.js'></script>
|
||||||
@@ -20,11 +20,22 @@ var isIndividual = false;
|
|||||||
var done = true;
|
var done = true;
|
||||||
|
|
||||||
|
|
||||||
|
var curr_course = {}
|
||||||
|
|
||||||
|
|
||||||
//This extension may be super lit, but you know what's even more lit?
|
//This extension may be super lit, but you know what's even more lit?
|
||||||
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
|
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
|
||||||
|
|
||||||
console.log('UT Registration Plus is running on this page.');
|
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')) {
|
if (document.querySelector('#fos_fl')) {
|
||||||
let params = (new URL(document.location)).searchParams;
|
let params = (new URL(document.location)).searchParams;
|
||||||
let dep = params.get("fos_fl");
|
let dep = params.get("fos_fl");
|
||||||
@@ -47,6 +58,8 @@ if (next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//make heading and modal
|
//make heading and modal
|
||||||
if (!$("#kw_results_table").length) {
|
if (!$("#kw_results_table").length) {
|
||||||
$("table thead th:last-child").after('<th scope=col>Plus</th>');
|
$("table thead th:last-child").after('<th scope=col>Plus</th>');
|
||||||
@@ -89,17 +102,12 @@ if (!$("#kw_results_table").length) {
|
|||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
$("#container").prepend(modhtml);
|
$("#container").prepend(modhtml);
|
||||||
$("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>");
|
$("#myModal").prepend("<div id='snackbar'>save course popup...</div>");
|
||||||
//go through all the rows in the list
|
//go through all the rows in the list
|
||||||
$('table').find('tr').each(function () {
|
$('table').find('tr').each(function () {
|
||||||
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
|
if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) {
|
||||||
//if a course row, then add the extension button
|
//if a course row, then add the extension button
|
||||||
$(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom; display:block;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`);
|
$(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom; display:block;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`);
|
||||||
// if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
|
|
||||||
// $(this).find('td').each(function () {
|
|
||||||
// $(this).css('background-color', '#E0E0E0');
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,15 +120,10 @@ $("body").on('click', '#distButton', function () {
|
|||||||
scrollTop: 0
|
scrollTop: 0
|
||||||
}, 500);
|
}, 500);
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
getCourseInfo(row);
|
curr_course = getCourseInfo(row);
|
||||||
getDistribution();
|
getDistribution(curr_course);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).scroll(function () {
|
|
||||||
if ($(document).height() <= $(window).scrollTop() + $(window).height() + 150) {
|
|
||||||
loadNextPages();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#myModal").on('click', '#saveCourse', function () {
|
$("#myModal").on('click', '#saveCourse', function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@@ -130,28 +133,28 @@ $("#myModal").on('click', '#saveCourse', function () {
|
|||||||
|
|
||||||
$("#Syllabi").click(function () {
|
$("#Syllabi").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(`https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=${department}&course_number=${course_nbr}&course_title=&unique=&instructor_first=&instructor_last=${profname}&course_type=In+Residence&search=Search`);
|
window.open(curr_course["links"]["syllabi"]);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#rateMyProf").click(function () {
|
$("#rateMyProf").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(rmpLink);
|
window.open(curr_course["links"]["rate_my_prof"]);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#eCIS").click(function () {
|
$("#eCIS").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(eCISLink);
|
window.open(curr_course["links"]["ecis"]);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#textbook").click(function () {
|
$("#textbook").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(textbookLink);
|
window.open(curr_course["links"]["textbook"]);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#semesters").on('change', function () {
|
$("#semesters").on('change', function () {
|
||||||
var sem = $(this).val();
|
var sem = $(this).val();
|
||||||
sem = sem == "Aggregate" ? undefined : sem;
|
sem = sem == "Aggregate" ? undefined : sem;
|
||||||
getDistribution(sem);
|
getDistribution(curr_course, sem);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#retry").click(function () {
|
$("#retry").click(function () {
|
||||||
@@ -159,22 +162,126 @@ $("#retry").click(function () {
|
|||||||
$(this).hide();
|
$(this).hide();
|
||||||
loadNextPages();
|
loadNextPages();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).keydown(function (e) {
|
$(document).keydown(function (e) {
|
||||||
/*Close Modal when hit escape*/
|
/*Close Modal when hit escape*/
|
||||||
if (e.keyCode == 27) {
|
if (e.keyCode == 27) {
|
||||||
close();
|
close();
|
||||||
} else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
|
} else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
|
||||||
/*save course when hit enter*/
|
|
||||||
saveCourse();
|
saveCourse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*Listen for update mssage coming from popup*/
|
/*Listen for update mssage coming from popup*/
|
||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
function (request, sender, sendResponse) {
|
function (request, sender, sendResponse) {
|
||||||
if (request.command == "updateCourseList") {
|
if (request.command == "updateCourseList") {
|
||||||
update(0);
|
update(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
function sepNameParts(name) {
|
||||||
|
numIndex = name.search(/\d/);
|
||||||
|
department = name.substring(0, numIndex).trim();
|
||||||
|
number = name.substring(numIndex, name.indexOf(" ", numIndex)).trim();
|
||||||
|
name = capitalizeString(name.substring(name.indexOf(" ", numIndex)).trim());
|
||||||
|
return [name, department, number];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function buildCourseLinks(course_info) {
|
||||||
|
let {
|
||||||
|
department,
|
||||||
|
number,
|
||||||
|
unique,
|
||||||
|
prof_name
|
||||||
|
} = course_info
|
||||||
|
links = {
|
||||||
|
"textbook": `https://www.universitycoop.com/adoption-search-results?sn=${semesterCode}__${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`,
|
||||||
|
//default ones (before first name can be used)
|
||||||
|
"rate_my_prof": "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255",
|
||||||
|
"ecis": "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?"
|
||||||
|
}
|
||||||
|
course_info["links"] = links;
|
||||||
|
return course_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildBasicCourseInfo(row, course_name, individual) {
|
||||||
|
let namedata = sepNameParts(course_name)
|
||||||
|
let instructor_text = $(row).find('td[data-th="Instructor"]').text();
|
||||||
|
let has_initial = instructor_text.indexOf(',') > 0;
|
||||||
|
course_info = {
|
||||||
|
"full_name": course_name,
|
||||||
|
"name": namedata[0],
|
||||||
|
"department": namedata[1],
|
||||||
|
"number": namedata[2],
|
||||||
|
"individual": individual ? individual : $(row).find('td[data-th="Unique"] a').prop('href'),
|
||||||
|
"register": $(row).find('td[data-th="Add"] a').prop('href'),
|
||||||
|
"unique": $(row).find('td[data-th="Unique"]').text(),
|
||||||
|
"status": $(row).find('td[data-th="Status"]').text(),
|
||||||
|
"prof_name": instructor_text ? has_initial ? capitalizeString(instructor_text.split(', ')[0]) : capitalizeString(instructor_text) : "Undecided",
|
||||||
|
"initial": instructor_text && has_initial ? instructor_text.split(', ')[1].substring(0, 1) : "",
|
||||||
|
"time_data": {
|
||||||
|
"days": $(row).find('td[data-th="Days"]>span').toArray().map(x => $(x).text().trim()),
|
||||||
|
"times": $(row).find('td[data-th="Hour"]>span').toArray().map(x => $(x).text().trim()),
|
||||||
|
"places": $(row).find('td[data-th="Room"]>span').toArray().map(x => $(x).text().trim())
|
||||||
|
},
|
||||||
|
"links": {}
|
||||||
|
}
|
||||||
|
return buildCourseLinks(course_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function buildTimeTitle(course_info) {
|
||||||
|
$("h2.dateTimePlace").remove();
|
||||||
|
let {
|
||||||
|
days,
|
||||||
|
times,
|
||||||
|
places
|
||||||
|
} = course_info["time_data"]
|
||||||
|
datetimearr = [];
|
||||||
|
var lines = [];
|
||||||
|
for (var i = 0; i < days.length; i++) {
|
||||||
|
var date = days[i];
|
||||||
|
var time = times[i];
|
||||||
|
var place = places[i];
|
||||||
|
lines.push($(`<h2 class="dateTimePlace">${makeLine(date, time, place)}</th>`));
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*For a row, get all the course information and add the date-time-lines*/
|
||||||
|
function getCourseInfo(row) {
|
||||||
|
let course_name = "";
|
||||||
|
let course_row = {}
|
||||||
|
let individual = undefined;
|
||||||
|
if ($("#textbook_button").length) {
|
||||||
|
course_name = $("#details h2").text();
|
||||||
|
course_row = $('table');
|
||||||
|
individual = document.URL;
|
||||||
|
} else {
|
||||||
|
$('table').find('tr').each(function () {
|
||||||
|
if ($(this).find('td').hasClass("course_header")) {
|
||||||
|
course_name = $(this).find('td').text() + "";
|
||||||
|
}
|
||||||
|
if ($(this).is(row)) {
|
||||||
|
course_row = row;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
curr_course = buildBasicCourseInfo(course_row, course_name, individual);
|
||||||
|
getDescription(curr_course);
|
||||||
|
return curr_course;
|
||||||
|
}
|
||||||
|
|
||||||
function loadNextPages() {
|
function loadNextPages() {
|
||||||
chrome.storage.sync.get('loadAll', function (data) {
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
@@ -201,19 +308,12 @@ function loadNextPages() {
|
|||||||
let hasCourseHead = $(this).find('td').hasClass("course_header");
|
let hasCourseHead = $(this).find('td').hasClass("course_header");
|
||||||
if (!(hasCourseHead && $(this).has('th').length == 0)) {
|
if (!(hasCourseHead && $(this).has('th').length == 0)) {
|
||||||
$(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`);
|
$(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`);
|
||||||
// if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
|
|
||||||
// $(this).find('td').each(function () {
|
|
||||||
// $(this).css('background-color', '#E0E0E0');
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
if (!(hasCourseHead && last == $(this).find('td').text())) {
|
if (!(hasCourseHead && last == $(this).find('td').text())) {
|
||||||
newrows.push($(this));
|
newrows.push($(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
current.append(newrows);
|
current.append(newrows);
|
||||||
// console.log($('tbody tr').length + " " + $('tr>td.course_header').length);
|
|
||||||
// update(oldlength + 1);
|
|
||||||
update(oldlength + 1)
|
update(oldlength + 1)
|
||||||
}
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
@@ -229,25 +329,39 @@ function loadNextPages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveCourse() {
|
function saveCourse() {
|
||||||
var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl, registerlink);
|
let {
|
||||||
|
full_name,
|
||||||
|
unique,
|
||||||
|
prof_name,
|
||||||
|
status,
|
||||||
|
individual,
|
||||||
|
register
|
||||||
|
} = curr_course;
|
||||||
|
let dtarr = getDayTimeArray(undefined, curr_course);
|
||||||
|
|
||||||
|
var c = new Course(full_name, unique, prof_name, dtarr, status, individual, register);
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "courseStorage",
|
command: "courseStorage",
|
||||||
course: c,
|
course: c,
|
||||||
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
|
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
|
|
||||||
$("#saveCourse").text(response.label);
|
$("#saveCourse").text(response.label);
|
||||||
$("#snackbar").text(response.done);
|
$("#snackbar").text(response.done);
|
||||||
|
toggleSnackbar();
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toggleSnackbar() {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("#snackbar").attr("class", "show");
|
$("#snackbar").attr("class", "show");
|
||||||
}, 200);
|
}, 200);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("#snackbar").attr("class", "");
|
$("#snackbar").attr("class", "");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
command: "updateCourseList"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
||||||
@@ -261,23 +375,19 @@ function update(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 thisForm = this;
|
||||||
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
||||||
// console.log(uniquenum);
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "isSingleConflict",
|
command: "isSingleConflict",
|
||||||
dtarr: getDtarr(this),
|
dtarr: getDayTimeArray(this),
|
||||||
unique: uniquenum
|
unique: uniquenum
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
var tds = $(thisForm).find('td');
|
var tds = $(thisForm).find('td');
|
||||||
// console.log(tds.css('color'));
|
|
||||||
if (response.isConflict && data.courseConflictHighlight && !response.alreadyContains) {
|
if (response.isConflict && data.courseConflictHighlight && !response.alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(244, 67, 54)') {
|
if (tds.css('color') != 'rgb(244, 67, 54)') {
|
||||||
console.log('made red ' + uniquenum);
|
|
||||||
red++;
|
red++;
|
||||||
tds.css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
|
tds.css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
|
||||||
}
|
}
|
||||||
} else if (!response.alreadyContains) {
|
} else if (!response.alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(51, 51, 51)') {
|
if (tds.css('color') != 'rgb(51, 51, 51)') {
|
||||||
console.log('made black ' + uniquenum);
|
|
||||||
black++;
|
black++;
|
||||||
tds.css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
|
tds.css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
|
||||||
}
|
}
|
||||||
@@ -285,7 +395,6 @@ function update(start) {
|
|||||||
if (response.alreadyContains) {
|
if (response.alreadyContains) {
|
||||||
if (tds.css('color') != 'rgb(76, 175, 80)') {
|
if (tds.css('color') != 'rgb(76, 175, 80)') {
|
||||||
green++;
|
green++;
|
||||||
console.log('made green ' + uniquenum);
|
|
||||||
tds.css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
|
tds.css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,199 +402,80 @@ function update(start) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//console.log(`red: ${red} black: ${black} green: ${green}`);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For a row, get the date-time-array for checking conflicts*/
|
/* For a row, get the date-time-array for checking conflicts*/
|
||||||
function getDtarr(row) {
|
function getDayTimeArray(row, course_info) {
|
||||||
var numlines = $(row).find('td[data-th="Days"]>span').length;
|
var daytimearray = []
|
||||||
var dtarr = [];
|
let days = course_info ? course_info["time_data"]["days"] : $(row).find('td[data-th="Days"]>span').toArray().map(x => $(x).text().trim());
|
||||||
for (var i = 0; i < numlines; i++) {
|
let times = course_info ? course_info["time_data"]["times"] : $(row).find('td[data-th="Hour"]>span').toArray().map(x => $(x).text().trim());
|
||||||
var date = $(row).find('td[data-th="Days"]>span:eq(' + i + ')').text();
|
let places = course_info ? course_info["time_data"]["places"] : $(row).find('td[data-th="Room"]>span').toArray().map(x => $(x).text().trim());
|
||||||
var time = $(row).find('td[data-th="Hour"]>span:eq(' + i + ')').text();
|
for (var i = 0; i < days.length; i++) {
|
||||||
var place = $(row).find('td[data-th="Room"]>span:eq(' + i + ')').text();
|
let date = days[i];
|
||||||
|
let time = times[i];
|
||||||
|
let place = places[i];
|
||||||
for (var j = 0; j < date.length; j++) {
|
for (var j = 0; j < date.length; j++) {
|
||||||
var letter = date.charAt(j);
|
let letter = date.charAt(j);
|
||||||
var day = "";
|
|
||||||
if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
|
if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
|
||||||
dtarr.push(["TH", convertTime(time), place]);
|
daytimearray.push(["TH", convertTime(time), place]);
|
||||||
} else {
|
} else {
|
||||||
if (letter != "H") {
|
if (letter != "H")
|
||||||
dtarr.push([letter, convertTime(time), place]);
|
daytimearray.push([letter, convertTime(time), place]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return daytimearray;
|
||||||
return dtarr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Course object for passing to background*/
|
|
||||||
function Course(coursename, unique, profname, datetimearr, status, link, registerlink) {
|
|
||||||
this.coursename = coursename;
|
|
||||||
this.unique = unique;
|
|
||||||
this.profname = profname;
|
|
||||||
this.datetimearr = datetimearr;
|
|
||||||
this.status = status;
|
|
||||||
this.link = link;
|
|
||||||
this.registerlink = registerlink;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*For a row, get all the course information and add the date-time-lines*/
|
|
||||||
function getCourseInfo(row) {
|
|
||||||
console.log(row);
|
|
||||||
semesterCode = new URL(window.location.href).pathname.split('/')[4];
|
|
||||||
$("h2.dateTimePlace").remove();
|
|
||||||
$('table').find('tr').each(function () {
|
|
||||||
if ($(this).find('td').hasClass("course_header")) {
|
|
||||||
coursename = $(this).find('td').text() + "";
|
|
||||||
}
|
|
||||||
if ($(this).is(row)) {
|
|
||||||
profurl = $(this).find('td[data-th="Unique"] a').prop('href');
|
|
||||||
registerlink = $(this).find('td[data-th="Add"] a').prop('href');
|
|
||||||
// console.log(registerlink);
|
|
||||||
uniquenum = $(this).find('td[data-th="Unique"]').text();
|
|
||||||
status = $(this).find('td[data-th="Status"]').text();
|
|
||||||
profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0];
|
|
||||||
profinit = $(this).find('td[data-th="Instructor"]').text().split(', ')[1];
|
|
||||||
if (profname.indexOf(" ") == 0) {
|
|
||||||
profname = profname.substring(1);
|
|
||||||
}
|
|
||||||
var numlines = $(this).find('td[data-th="Days"]>span').length;
|
|
||||||
datetimearr = [];
|
|
||||||
var lines = [];
|
|
||||||
for (var i = 0; i < numlines; i++) {
|
|
||||||
var date = $(this).find('td[data-th="Days"]>span:eq(' + i + ')').text();
|
|
||||||
var time = $(this).find('td[data-th="Hour"]>span:eq(' + i + ')').text();
|
|
||||||
var place = $(this).find('td[data-th="Room"]>span:eq(' + i + ')').text();
|
|
||||||
lines.push($(`<h2 class="dateTimePlace">${makeLine(date, time, place)}</th>`));
|
|
||||||
}
|
|
||||||
$("#topbuttons").before(lines);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/*Handle if on the individual course page, ie if the textbook button exists*/
|
|
||||||
if ($("#textbook_button").length) {
|
|
||||||
coursename = $("#details h2").text();
|
|
||||||
var gotname = $("table").find("td[data-th='Instructor']").text();
|
|
||||||
if (gotname != "") {
|
|
||||||
profinit = gotname.split(", ")[1].substring(0, 1);
|
|
||||||
} else {
|
|
||||||
profinit = "";
|
|
||||||
}
|
|
||||||
profurl = document.URL;
|
|
||||||
// console.log(profurl);
|
|
||||||
}
|
|
||||||
getDescription();
|
|
||||||
department = coursename.substring(0, coursename.search(/\d/) - 2);
|
|
||||||
course_nbr = coursename.substring(coursename.search(/\d/), coursename.indexOf(" ", coursename.search(/\d/)));
|
|
||||||
textbookLink = `https://www.universitycoop.com/adoption-search-results?sn=${semesterCode}__${department}__${course_nbr}__${uniquenum}`
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the day-time-arr and make the text for the date-time-line*/
|
|
||||||
function makeLine(date, time, place) {
|
function makeLine(date, time, place) {
|
||||||
var arr = [];
|
var arr = seperateDays(date)
|
||||||
var output = "";
|
var output = prettifyDaysText(arr)
|
||||||
for (var i = 0; i < date.length; i++) {
|
|
||||||
var letter = date.charAt(i);
|
|
||||||
var day = "";
|
|
||||||
if (letter == "T" && i < date.length - 1 && date.charAt(i + 1) == "H") {
|
|
||||||
arr.push(days.get("TH"));
|
|
||||||
datetimearr.push(["TH", convertTime(time), place]);
|
|
||||||
} else {
|
|
||||||
if (letter != "H") {
|
|
||||||
arr.push(days.get(letter));
|
|
||||||
datetimearr.push([letter, convertTime(time), place]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
var building = place.substring(0, place.search(/\d/) - 1);
|
var building = place.substring(0, place.search(/\d/) - 1);
|
||||||
if (building == "") {
|
building = building == "" ? "Undecided Location" : building;
|
||||||
building = "Undecided Location";
|
|
||||||
}
|
|
||||||
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}</>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Convert time to 24hour format*/
|
function badData(course_data, res) {
|
||||||
function convertTime(time) {
|
return typeof res == 'undefined' || course_data["prof_name"] == "Undecided";
|
||||||
var converted = time.replace(/\./g, '').split("-");
|
|
||||||
for (var i = 0; i < 2; i++) {
|
|
||||||
converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm");
|
|
||||||
}
|
|
||||||
return converted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Query the grades database*/
|
/*Query the grades database*/
|
||||||
function getDistribution(sem) {
|
function getDistribution(course_data, sem) {
|
||||||
var query;
|
// showLoading(true);
|
||||||
if (!sem) {
|
let query = buildQuery(course_data, sem);
|
||||||
query = "select * from agg";
|
|
||||||
} else {
|
|
||||||
query = "select * from grades";
|
|
||||||
}
|
|
||||||
query += " where dept like '%" + department + "%'";
|
|
||||||
query += " and prof like '%" + profname.replace(/'/g, "") + "%'";
|
|
||||||
query += " and course_nbr like '%" + course_nbr + "%'";
|
|
||||||
if (sem) {
|
|
||||||
query += "and sem like '%" + sem + "%'";
|
|
||||||
}
|
|
||||||
query += "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc";
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "gradesQuery",
|
command: "gradesQuery",
|
||||||
query: query
|
query: query
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
var res = response.data;
|
var res = response.data;
|
||||||
if (!sem) {
|
if (!sem) {
|
||||||
openDialog(department, coursename, "aggregate", profname, res);
|
openDialog(course_data, res);
|
||||||
} else {
|
} else {
|
||||||
var data;
|
var data = badData(course_data, res) ? [] : res.values[0];
|
||||||
if (typeof res == 'undefined' || profname == "") {
|
|
||||||
data = [];
|
|
||||||
} else {
|
|
||||||
data = res.values[0];
|
|
||||||
}
|
|
||||||
setChart(data);
|
setChart(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Open the modal and show all the data*/
|
|
||||||
function openDialog(dep, cls, sem, professor, res) {
|
function buildTitle(course_data) {
|
||||||
$("#myModal").fadeIn(fadetime);
|
return `${course_data["name"]} (${course_data["department"]} ${course_data["number"]})`
|
||||||
//initial text on the "save course button"
|
}
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
command: "alreadyContains",
|
function buildProfTitle(course_data) {
|
||||||
unique: uniquenum
|
const {
|
||||||
}, function (response) {
|
initial,
|
||||||
if (response.alreadyContains) {
|
prof_name
|
||||||
$("#saveCourse").text("Remove Course -");
|
} = course_data;
|
||||||
} else {
|
return `with ${initial?initial+". ":""}${prof_name}`;
|
||||||
$("#saveCourse").text("Add Course +");
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
//set if no grade distribution
|
function buildSemestersDropdown(course_data, res) {
|
||||||
var data;
|
|
||||||
$("#semesters").empty();
|
$("#semesters").empty();
|
||||||
if (typeof res == 'undefined' || profname == "") {
|
if (badData(course_data, res)) {
|
||||||
$("#semesters").append("<option>No Data</option>")
|
$("#semesters").append("<option>No Data</option>")
|
||||||
data = [];
|
|
||||||
} else {
|
} else {
|
||||||
var semesters = res.values[0][18].split(",");
|
var semesters = res.values[0][18].split(",");
|
||||||
semesters.sort(semesterSort);
|
semesters.sort(semesterSort);
|
||||||
@@ -495,43 +485,49 @@ function openDialog(dep, cls, sem, professor, res) {
|
|||||||
sems.push($(`<option value="${semesters[i]}">${semesters[i]}</option>`));
|
sems.push($(`<option value="${semesters[i]}">${semesters[i]}</option>`));
|
||||||
}
|
}
|
||||||
$("#semesters").append(sems);
|
$("#semesters").append(sems);
|
||||||
data = res.values[0];
|
|
||||||
}
|
}
|
||||||
var modal = document.getElementById('myModal');
|
}
|
||||||
var span = document.getElementsByClassName("close")[0];
|
|
||||||
modal.style.display = "block";
|
|
||||||
|
|
||||||
var color = "black";
|
|
||||||
if (status.includes("open")) {
|
|
||||||
color = "#4CAF50";
|
|
||||||
} else if (status.includes("waitlisted")) {
|
|
||||||
color = "#FF9800"
|
|
||||||
} else if (status.includes("closed") || status.includes("cancelled")) {
|
|
||||||
color = "#FF5722";
|
|
||||||
}
|
|
||||||
$("#title").text(prettifyTitle()).append("<span style='color:" + color + ";font-size:medium;'>" + " #" + uniquenum + "</>");
|
|
||||||
|
|
||||||
if (typeof profinit != "undefined" && profinit.length > 1) {
|
/*Open the modal and show all the data*/
|
||||||
profinit = profinit.substring(0, 1);
|
function openDialog(course_info, res) {
|
||||||
}
|
$("#title").text(buildTitle(course_info))
|
||||||
var name;
|
$("#topbuttons").before(buildTimeTitle(course_info));
|
||||||
if (profname == "") {
|
$("#profname").text(buildProfTitle(course_info));
|
||||||
name = "Undecided Professor ";
|
$("#myModal").fadeIn(fadetime);
|
||||||
|
//initial text on the "save course button"
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "alreadyContains",
|
||||||
|
unique: course_info["unique"]
|
||||||
|
}, function (response) {
|
||||||
|
if (response.alreadyContains) {
|
||||||
|
$("#saveCourse").text("Remove Course -");
|
||||||
} else {
|
} else {
|
||||||
name = prettifyName();
|
$("#saveCourse").text("Add Course +");
|
||||||
}
|
}
|
||||||
$("#profname").text("with " + name);
|
});
|
||||||
|
|
||||||
|
buildSemestersDropdown(course_info, res)
|
||||||
|
var data = []
|
||||||
|
if (!badData(course_info, res))
|
||||||
|
data = res.values[0];
|
||||||
|
let status_color = getStatusColor(course_info["status"]);
|
||||||
//close button
|
//close button
|
||||||
span.onclick = function () {
|
allowClosing();
|
||||||
close();
|
|
||||||
}
|
|
||||||
setChart(data);
|
setChart(data);
|
||||||
// When clicks anywhere outside of the modal, close it
|
|
||||||
window.onclick = function (event) {
|
}
|
||||||
if (event.target == modal) {
|
|
||||||
|
function allowClosing() {
|
||||||
|
$('.close').click(function () {
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
$('#myModal').click(function (event) {
|
||||||
|
if (event.target.id == 'myModal') {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
@@ -560,83 +556,70 @@ function setChart(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Format the title*/
|
function buildFormattedDescription(description_lines) {
|
||||||
function prettifyTitle() {
|
let description = ""
|
||||||
val = department.length + course_nbr.length + 3;
|
for (let i in description_lines) {
|
||||||
output = coursename.substring(val).replace(/\b\w*/g, function (txt) {
|
let sentence = description_lines[i];
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
if (sentence.indexOf("Prerequisite") == 0)
|
||||||
});
|
sentence = `<li style='font-weight: bold;' class='descriptionli'>${sentence}</li>`;
|
||||||
return output + " (" + department + " " + course_nbr + ")";
|
else if (sentence.indexOf("May be") >= 0)
|
||||||
}
|
sentence = `<li style='font-style: italic;' class='descriptionli'>${sentence}</li>`;
|
||||||
/* Format the Professor Name */
|
else if (sentence.indexOf("Restricted to") == 0)
|
||||||
function prettifyName() {
|
sentence = `<li style='color:red;' class='descriptionli'>${sentence}</li>`;
|
||||||
var fixedprofinit = "";
|
else
|
||||||
if (profinit) {
|
sentence = `<li class='descriptionli'>${sentence}</li>`;
|
||||||
fixedprofinit = profinit + ". ";
|
description += sentence;
|
||||||
}
|
}
|
||||||
return fixedprofinit + profname.replace(/\w\S*/g, function (txt) {
|
if (!description)
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
description = "<p style='color:red;font-style:bold'>There was an error. Please refresh the page and/or log back in using your UT EID and password.</p>"
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function displayDescription(description) {
|
||||||
|
$("#description").animate({
|
||||||
|
'opacity': 0
|
||||||
|
}, 200, function () {
|
||||||
|
$(this).html(description).animate({
|
||||||
|
'opacity': 1
|
||||||
|
}, 200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Get the course description from the profurl and highlight the important elements, as well as set the eCIS, and rmp links.*/
|
/*Get the course description from the profurl and highlight the important elements, as well as set the eCIS, and rmp links.*/
|
||||||
function getDescription() {
|
function getDescription(course_info) {
|
||||||
// console.log(window.location.href);
|
console.log('getting description for ')
|
||||||
// console.log(profurl);
|
|
||||||
console.log('hello');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: profurl,
|
url: course_info["individual"],
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
console.log(profurl);
|
response_node = $('<div/>').html(response).contents();
|
||||||
var output = "";
|
description_lines = response_node.find('#details > p').toArray().map(x => $(x).text());
|
||||||
var object = $('<div/>').html(response).contents();
|
displayDescription(buildFormattedDescription(description_lines));
|
||||||
object.find('#details > p').each(function () {
|
let first_name = extractFirstName(response_node);
|
||||||
var sentence = $(this).text();
|
updateLinks(course_info, first_name);
|
||||||
if (sentence.indexOf("Prerequisite") == 0) {
|
|
||||||
sentence = "<li style='font-weight: bold;' class='descriptionli'>" + sentence + "</li>";
|
|
||||||
} else if (sentence.indexOf("May be") >= 0) {
|
|
||||||
sentence = "<li style='font-style: italic;' class='descriptionli'>" + sentence + "</li>";
|
|
||||||
} else if (sentence.indexOf("Restricted to") == 0) {
|
|
||||||
sentence = "<li style='color:red;' class='descriptionli'>" + sentence + "</li>";
|
|
||||||
} else {
|
|
||||||
sentence = "<li class='descriptionli'>" + sentence + "</li>";
|
|
||||||
}
|
|
||||||
output += sentence;
|
|
||||||
});
|
|
||||||
description = output;
|
|
||||||
console.log(response);
|
|
||||||
if (!description) {
|
|
||||||
description = "<p style='color:red;font-style:bold'>There was an error. Please refresh the page and/or log back in using your UT EID and password.</p>"
|
|
||||||
}
|
|
||||||
$("#description").animate({
|
|
||||||
'opacity': 0
|
|
||||||
}, 200, function () {
|
|
||||||
$(this).html(description).animate({
|
|
||||||
'opacity': 1
|
|
||||||
}, 200);
|
|
||||||
});
|
|
||||||
var first = object.find('td[data-th="Instructor"]').text();
|
|
||||||
first = first.substring(first.indexOf(", "), first.indexOf(" ", first.indexOf(", ") + 2));
|
|
||||||
first = first.substring(2);
|
|
||||||
rmpLink = `http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query=${first} ${profname};&facetSearch=true`;
|
|
||||||
if (profname == "") {
|
|
||||||
eCISLink = `http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept=${department}&s_in_search_course_num=${course_nbr}`;
|
|
||||||
} else {
|
|
||||||
eCISLink = `http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?&s_in_action_sw=S&s_in_search_type_sw=N&s_in_search_name=${profname.substring(0, 1) + profname.substring(1).toLowerCase()}%2C%20${first.substring(0, 1) + first.substring(1).toLowerCase()}`;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
description = "<p style='color:red;font-style:bold'>You have been logged out. Please refresh the page and log back in using your UT EID and password.</p>"
|
description = "<p style='color:red;font-style:bold'>You have been logged out. Please refresh the page and log back in using your UT EID and password.</p>"
|
||||||
$("#description").animate({
|
displayDescription(description);
|
||||||
'opacity': 0
|
|
||||||
}, 200, function () {
|
|
||||||
$(this).html(description).animate({
|
|
||||||
'opacity': 1
|
|
||||||
}, 200);
|
|
||||||
});
|
|
||||||
rmpLink = "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255";
|
|
||||||
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateLinks(course_info, first_name) {
|
||||||
|
let {
|
||||||
|
prof_name,
|
||||||
|
number
|
||||||
|
} = course_info;
|
||||||
|
course_info["first_name"] = first_name;
|
||||||
|
course_info["links"]["rate_my_prof"] = `http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query=${first_name} ${prof_name};&facetSearch=true`;
|
||||||
|
course_info["links"]["ecis"] = profname ? `http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?&s_in_action_sw=S&s_in_search_type_sw=N&s_in_search_name=${prof_name}%2C%20${first_name}` :
|
||||||
|
`http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept=${department}&s_in_search_course_num=${number}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractFirstName(response_node) {
|
||||||
|
let full_name = response_node.find('td[data-th="Instructor"]').text().split(', ');
|
||||||
|
let first = full_name[full_name.length - 1];
|
||||||
|
return capitalizeString(first);
|
||||||
|
}
|
||||||
0
js/ics.min.js → js/lib/ics.min.js
vendored
0
js/ics.min.js → js/lib/ics.min.js
vendored
0
js/moment.min.js → js/lib/moment.min.js
vendored
0
js/moment.min.js → js/lib/moment.min.js
vendored
79
js/util.js
79
js/util.js
@@ -14,6 +14,18 @@ const semOrder = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getStatusColor(status) {
|
||||||
|
let color = "black";
|
||||||
|
if (status.includes("open")) {
|
||||||
|
color = "#4CAF50";
|
||||||
|
} else if (status.includes("waitlisted")) {
|
||||||
|
color = "#FF9800"
|
||||||
|
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||||
|
color = "#FF5722";
|
||||||
|
}
|
||||||
|
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"] + "%'";
|
||||||
@@ -25,6 +37,73 @@ function buildQuery(course_data, sem) {
|
|||||||
return query + "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc";
|
return query + "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Course object for passing to background*/
|
||||||
|
function Course(coursename, unique, profname, datetimearr, status, link, registerlink) {
|
||||||
|
this.coursename = coursename;
|
||||||
|
this.unique = unique;
|
||||||
|
this.profname = profname;
|
||||||
|
this.datetimearr = datetimearr;
|
||||||
|
this.status = status;
|
||||||
|
this.link = link;
|
||||||
|
this.registerlink = registerlink;
|
||||||
|
}
|
||||||
|
|
||||||
|
function capitalizeString(string) {
|
||||||
|
//if one word, and if multiple words:
|
||||||
|
let output = "";
|
||||||
|
words = string.split(/[. ,\/ -]/);
|
||||||
|
for (let i in words) {
|
||||||
|
word = words[i];
|
||||||
|
capitalizedWord = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
||||||
|
output += capitalizedWord + " ";
|
||||||
|
}
|
||||||
|
return output.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function seperateDays(date) {
|
||||||
|
let arr = [];
|
||||||
|
for (var i = 0; i < date.length; i++) {
|
||||||
|
let letter = date.charAt(i);
|
||||||
|
if (letter == "T" && i < date.length - 1 && date.charAt(i + 1) == "H") {
|
||||||
|
arr.push(days.get("TH"));
|
||||||
|
} else {
|
||||||
|
if (letter != "H") {
|
||||||
|
arr.push(days.get(letter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*Convert time to 24hour format*/
|
||||||
|
function convertTime(time) {
|
||||||
|
var converted = time.replace(/\./g, '').split("-");
|
||||||
|
for (var i = 0; i < 2; i++) {
|
||||||
|
converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm");
|
||||||
|
}
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 semesterSort(semA, semB) {
|
function semesterSort(semA, semB) {
|
||||||
let aName = semA.split(' ')[0];
|
let aName = semA.split(' ')[0];
|
||||||
|
|||||||
@@ -102,12 +102,9 @@ function openDialog(course_data, res) {
|
|||||||
$("#profname").text(buildProfTitle(course_data));
|
$("#profname").text(buildProfTitle(course_data));
|
||||||
$("#myModal").fadeIn(fadetime);
|
$("#myModal").fadeIn(fadetime);
|
||||||
buildSemestersDropdown(course_data, res)
|
buildSemestersDropdown(course_data, res)
|
||||||
var data;
|
var data = []
|
||||||
if (badData(course_data, res)) {
|
if (!badData(course_data, res))
|
||||||
data = [];
|
|
||||||
} else {
|
|
||||||
data = res.values[0];
|
data = res.values[0];
|
||||||
}
|
|
||||||
setChart(data);
|
setChart(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,9 +169,7 @@ function buildTimeTitle(times) {
|
|||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
|
||||||
$("#myModal").fadeOut(fadetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeLine(date, time, place) {
|
function makeLine(date, time, place) {
|
||||||
var arr = seperateDays(date)
|
var arr = seperateDays(date)
|
||||||
@@ -185,20 +180,7 @@ function makeLine(date, time, place) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function seperateDays(date) {
|
|
||||||
let arr = [];
|
|
||||||
for (var i = 0; i < date.length; i++) {
|
|
||||||
let letter = date.charAt(i);
|
|
||||||
if (letter == "T" && i < date.length - 1 && date.charAt(i + 1) == "H") {
|
|
||||||
arr.push(days.get("TH"));
|
|
||||||
} else {
|
|
||||||
if (letter != "H") {
|
|
||||||
arr.push(days.get(letter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
function prettifyDaysText(arr) {
|
function prettifyDaysText(arr) {
|
||||||
var output = "";
|
var output = "";
|
||||||
@@ -239,3 +221,7 @@ function setChart(data) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
$("#myModal").fadeOut(fadetime);
|
||||||
|
}
|
||||||
@@ -16,24 +16,24 @@
|
|||||||
],
|
],
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"css": ["css/styles.css"],
|
"css": ["css/styles.css"],
|
||||||
"js": ["js/moment.min.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/jquery.initialize.min.js", "js/config.js", "js/util.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/content.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/moment.min.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/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/utPlanner.js"],
|
||||||
"matches": ["https://utexas.collegescheduler.com/*"]
|
"matches": ["https://utexas.collegescheduler.com/*"]
|
||||||
}, {
|
}, {
|
||||||
"css": ["css/styles.css"],
|
"css": ["css/styles.css"],
|
||||||
"js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/import.js"],
|
"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": [
|
||||||
"grades.db", "images/disticon.png"
|
"grades.db", "images/disticon.png"
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["js/jquery-3.3.1.min.js", "js/sql-memory-growth.js", "js/background.js", "js/moment.min.js"],
|
"scripts": ["js/lib/jquery-3.3.1.min.js", "js/lib/sql-memory-growth.js", "js/lib/moment.min.js", "js/background.js"],
|
||||||
"persistent": true
|
"persistent": true
|
||||||
},
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
|
|||||||
@@ -12,16 +12,18 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2 style="padding: 5px 16px 5px 16px; font-weight: normal;display: inline-block;text-align:left;">Conflict
|
<h2 style="padding: 5px 16px 5px 16px; font-weight: normal;display: inline-block;text-align:left;">Conflict
|
||||||
Highlighting</h2>
|
Highlighting</h2>
|
||||||
<button id="togglecourseConflictHighlight" class="matbut" style="float:right; display:inline-block;font-size:medium;background:#F44336;">Turn
|
<button id="togglecourseConflictHighlight" class="matbut"
|
||||||
|
style="float:right; display:inline-block;font-size:medium;background:#F44336;">Turn
|
||||||
Off</button>
|
Off</button>
|
||||||
<h2 style="padding: 5px 16px 16px 16px; font-weight: normal;display: inline-block;text-align:left;">Scroll To
|
<h2 style="padding: 5px 16px 16px 16px; font-weight: normal;display: inline-block;text-align:left;">Scroll To
|
||||||
Load More Courses</h2>
|
Load More Courses</h2>
|
||||||
<button id="toggleloadAll" class="matbut" style="float: right;display:inline-block;font-size:medium;background:#F44336;">Turn
|
<button id="toggleloadAll" class="matbut"
|
||||||
|
style="float: right;display:inline-block;font-size:medium;background:#F44336;">Turn
|
||||||
Off</button>
|
Off</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p>
|
<p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p>
|
||||||
<script src="js/jquery-3.3.1.min.js"></script>
|
<script src="js/lib/jquery-3.3.1.min.js"></script>
|
||||||
<script src="js/options.js"></script>
|
<script src="js/options.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -83,8 +83,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="js/jquery-3.3.1.min.js"></script>
|
<script src="js/lib/jquery-3.3.1.min.js"></script>
|
||||||
<script src="js/moment.min.js"></script>
|
<script src="js/lib/moment.min.js"></script>
|
||||||
<script src="js/popup.js"></script>
|
<script src="js/popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user