optimization
This commit is contained in:
101
js/content.js
101
js/content.js
@@ -31,19 +31,19 @@ const fadetime = 150;
|
|||||||
const butdelay = 75;
|
const butdelay = 75;
|
||||||
//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
|
||||||
$(function () {
|
|
||||||
next = $("#next_nav_link");
|
next = $("#next_nav_link");
|
||||||
chrome.storage.sync.get('loadAll', function (data) {
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
if (data.loadAll) {
|
if (data.loadAll) {
|
||||||
$('[title*="next listing"]').remove();
|
$('[title*="next listing"]').remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loadDataBase();
|
loadDataBase();
|
||||||
//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>');
|
||||||
$("table").after(`<div style="text-align:center">
|
$("table").after(`<div style="text-align:center">
|
||||||
<div class="loader"></div>
|
<div class="loader" id='loader' ></div>
|
||||||
<br>
|
<br>
|
||||||
<h1 id="nextlabel"style="color: #FF9800;display:none;">Loading Courses</h1>
|
<h1 id="nextlabel"style="color: #FF9800;display:none;">Loading Courses</h1>
|
||||||
<h1 id="retrylabel"style="color: #F44336;display:none;">Failed to Load Courses</h1>
|
<h1 id="retrylabel"style="color: #F44336;display:none;">Failed to Load Courses</h1>
|
||||||
@@ -94,11 +94,11 @@ $(function () {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//update the conflicts
|
//update the conflicts
|
||||||
update(0);
|
update(0);
|
||||||
/*Handle the button clicks*/
|
/*Handle the button clicks*/
|
||||||
$("tbody").on('click', '.distButton', function () {
|
$("tbody").on('click', '#distButton', function () {
|
||||||
var row = $(this).closest('tr');
|
var row = $(this).closest('tr');
|
||||||
$('.modal-content').stop().animate({
|
$('.modal-content').stop().animate({
|
||||||
scrollTop: 0
|
scrollTop: 0
|
||||||
@@ -106,50 +106,50 @@ $(function () {
|
|||||||
$(this).blur();
|
$(this).blur();
|
||||||
getCourseInfo(row);
|
getCourseInfo(row);
|
||||||
getDistribution();
|
getDistribution();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).scroll(function () {
|
$(window).scroll(function () {
|
||||||
if ($(document).height() <= $(window).scrollTop() + $(window).height() + 130) {
|
if ($(document).height() <= $(window).scrollTop() + $(window).height() + 130) {
|
||||||
loadNextPages();
|
loadNextPages();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#saveCourse").click(function () {
|
$("#myModal").on('click', '#saveCourse', function () {
|
||||||
saveCourse();
|
saveCourse();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#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(`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`);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#rateMyProf").click(function () {
|
$("#rateMyProf").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(rmpLink);
|
window.open(rmpLink);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#eCIS").click(function () {
|
$("#eCIS").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(eCISLink);
|
window.open(eCISLink);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
$("#textbook").click(function () {
|
$("#textbook").click(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.open(textbookLink);
|
window.open(textbookLink);
|
||||||
}, 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(sem);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#retry").click(function () {
|
$("#retry").click(function () {
|
||||||
$("#retrylabel").hide();
|
$("#retrylabel").hide();
|
||||||
$('#retry').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();
|
||||||
@@ -157,15 +157,14 @@ $(function () {
|
|||||||
/*save course when hit enter*/
|
/*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 loadNextPages() {
|
function loadNextPages() {
|
||||||
chrome.storage.sync.get('loadAll', function (data) {
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
@@ -173,7 +172,7 @@ function loadNextPages() {
|
|||||||
let link = next.prop('href');
|
let link = next.prop('href');
|
||||||
if (done && next && link) {
|
if (done && next && link) {
|
||||||
$("#nextlabel").css('display', 'inline-block');
|
$("#nextlabel").css('display', 'inline-block');
|
||||||
$('.loader').css('display', 'inline-block');
|
$('#loader').css('display', 'inline-block');
|
||||||
done = false;
|
done = false;
|
||||||
$.get(link, function (response) {
|
$.get(link, function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
@@ -186,10 +185,11 @@ function loadNextPages() {
|
|||||||
next = nextpage.find("#next_nav_link");
|
next = nextpage.find("#next_nav_link");
|
||||||
done = true;
|
done = true;
|
||||||
$("#nextlabel").hide();
|
$("#nextlabel").hide();
|
||||||
$('.loader').hide();
|
$('#loader').hide();
|
||||||
var newrows = [];
|
var newrows = [];
|
||||||
nextpage.find('tbody>tr').each(function () {
|
nextpage.find('tbody>tr').each(function () {
|
||||||
if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
|
let hasCourseHead = $(this).find('td').hasClass("course_header");
|
||||||
|
if (!(hasCourseHead && $(this).has('th').length == 0)) {
|
||||||
$(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')) {
|
// if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
|
||||||
// $(this).find('td').each(function () {
|
// $(this).find('td').each(function () {
|
||||||
@@ -197,18 +197,19 @@ function loadNextPages() {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
if (!($(this).find('td').hasClass("course_header") && 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);
|
// console.log($('tbody tr').length + " " + $('tr>td.course_header').length);
|
||||||
update(oldlength + 1);
|
// update(oldlength + 1);
|
||||||
|
update(oldlength + 1)
|
||||||
}
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
done = true;
|
done = true;
|
||||||
$("#nextlabel").hide();
|
$("#nextlabel").hide();
|
||||||
$('.loader').hide();
|
$('#loader').hide();
|
||||||
$("#retrylabel").css('display', 'inline-block');
|
$("#retrylabel").css('display', 'inline-block');
|
||||||
$('#retry').css('display', 'inline-block');
|
$('#retry').css('display', 'inline-block');
|
||||||
});
|
});
|
||||||
@@ -306,7 +307,7 @@ function Course(coursename, unique, profname, datetimearr, status, link, registe
|
|||||||
function getCourseInfo(row) {
|
function getCourseInfo(row) {
|
||||||
console.log('WHAT');
|
console.log('WHAT');
|
||||||
semesterCode = new URL(window.location.href).pathname.split('/')[4];
|
semesterCode = new URL(window.location.href).pathname.split('/')[4];
|
||||||
$(".dateTimePlace").remove();
|
$("h2.dateTimePlace").remove();
|
||||||
$('table').find('tr').each(function () {
|
$('table').find('tr').each(function () {
|
||||||
if ($(this).find('td').hasClass("course_header")) {
|
if ($(this).find('td').hasClass("course_header")) {
|
||||||
coursename = $(this).find('td').text() + "";
|
coursename = $(this).find('td').text() + "";
|
||||||
@@ -324,12 +325,14 @@ function getCourseInfo(row) {
|
|||||||
}
|
}
|
||||||
var numlines = $(this).find('td[data-th="Days"]>span').length;
|
var numlines = $(this).find('td[data-th="Days"]>span').length;
|
||||||
datetimearr = [];
|
datetimearr = [];
|
||||||
|
var lines = [];
|
||||||
for (var i = 0; i < numlines; i++) {
|
for (var i = 0; i < numlines; i++) {
|
||||||
var date = $(this).find('td[data-th="Days"]>span:eq(' + i + ')').text();
|
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 time = $(this).find('td[data-th="Hour"]>span:eq(' + i + ')').text();
|
||||||
var place = $(this).find('td[data-th="Room"]>span:eq(' + i + ')').text();
|
var place = $(this).find('td[data-th="Room"]>span:eq(' + i + ')').text();
|
||||||
$("#topbuttons").before(`<h2 class="dateTimePlace">${makeLine(date, time, place)}</th>`);
|
lines.push($(`<h2 class="dateTimePlace">${makeLine(date, time, place)}</th>`));
|
||||||
}
|
}
|
||||||
|
$("#topbuttons").before(lines);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -338,7 +341,7 @@ function getCourseInfo(row) {
|
|||||||
coursename = $("#details h2").text();
|
coursename = $("#details h2").text();
|
||||||
var gotname = $("table").find("td[data-th='Instructor']").text();
|
var gotname = $("table").find("td[data-th='Instructor']").text();
|
||||||
if (gotname != "") {
|
if (gotname != "") {
|
||||||
profinit = $("table").find("td[data-th='Instructor']").text().split(", ")[1].substring(0, 1);
|
profinit = gotname.split(", ")[1].substring(0, 1);
|
||||||
} else {
|
} else {
|
||||||
profinit = "";
|
profinit = "";
|
||||||
}
|
}
|
||||||
@@ -456,16 +459,17 @@ function openDialog(dep, cls, sem, professor, res) {
|
|||||||
} else {
|
} else {
|
||||||
var semesters = res.values[0][18].split(",").reverse();
|
var semesters = res.values[0][18].split(",").reverse();
|
||||||
semesters.unshift('Aggregate');
|
semesters.unshift('Aggregate');
|
||||||
|
var sems = [];
|
||||||
for (var i = 0; i < semesters.length; i++) {
|
for (var i = 0; i < semesters.length; i++) {
|
||||||
$("#semesters").append(`<option value="${semesters[i]}">${semesters[i]}</option>`)
|
sems.push($(`<option value="${semesters[i]}">${semesters[i]}</option>`));
|
||||||
}
|
}
|
||||||
|
$("#semesters").append(sems);
|
||||||
data = res.values[0];
|
data = res.values[0];
|
||||||
}
|
}
|
||||||
var modal = document.getElementById('myModal');
|
var modal = document.getElementById('myModal');
|
||||||
var span = document.getElementsByClassName("close")[0];
|
var span = document.getElementsByClassName("close")[0];
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
|
|
||||||
$("#title").text(prettifyTitle());
|
|
||||||
var color = "black";
|
var color = "black";
|
||||||
if (status.includes("open")) {
|
if (status.includes("open")) {
|
||||||
color = "#4CAF50";
|
color = "#4CAF50";
|
||||||
@@ -474,7 +478,7 @@ function openDialog(dep, cls, sem, professor, res) {
|
|||||||
} else if (status.includes("closed") || status.includes("cancelled")) {
|
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||||
color = "#FF5722";
|
color = "#FF5722";
|
||||||
}
|
}
|
||||||
$("#title").append("<span style='color:" + color + ";font-size:medium;'>" + " #" + uniquenum + "</>");
|
$("#title").text(prettifyTitle()).append("<span style='color:" + color + ";font-size:medium;'>" + " #" + uniquenum + "</>");
|
||||||
|
|
||||||
if (typeof profinit != "undefined" && profinit.length > 1) {
|
if (typeof profinit != "undefined" && profinit.length > 1) {
|
||||||
profinit = profinit.substring(0, 1);
|
profinit = profinit.substring(0, 1);
|
||||||
@@ -675,7 +679,6 @@ function getDescription() {
|
|||||||
sentence = "<li class='descriptionli'>" + sentence + "</li>";
|
sentence = "<li class='descriptionli'>" + sentence + "</li>";
|
||||||
}
|
}
|
||||||
output += sentence;
|
output += sentence;
|
||||||
|
|
||||||
});
|
});
|
||||||
description = output;
|
description = output;
|
||||||
$("#description").animate({
|
$("#description").animate({
|
||||||
|
|||||||
Reference in New Issue
Block a user