optimization

This commit is contained in:
10001shh
2019-01-10 16:24:15 -06:00
parent 5d76d08d5d
commit 648c217d98

View File

@@ -85,6 +85,8 @@ $(function () {
/*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({ scrollTop: 0 }, 0);
$(this).blur();
getCourseInfo(row); getCourseInfo(row);
getDistribution(); getDistribution();
}); });
@@ -121,8 +123,7 @@ $(function () {
$(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) {
$("#myModal").fadeOut(fadetime); close();
$("#snackbar").attr("class", "");
} else if (e.keyCode == 13 && $('#myModal').is(':visible')) { } else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
/*save course when hit enter*/ /*save course when hit enter*/
saveCourse(); saveCourse();
@@ -183,11 +184,12 @@ function saveCourse() {
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);
setTimeout(function () { setTimeout(function () {
$("#snackbar").attr("class", "show"); $("#snackbar").attr("class", "show");
}, 300); }, 150);
setTimeout(function () { setTimeout(function () {
$("#snackbar").attr("class", ""); $("#snackbar").attr("class", "");
}, 3000); }, 3000);
@@ -265,6 +267,7 @@ function Course(coursename, unique, profname, datetimearr, status, link, registe
/*For a row, get all the course information and add the date-time-lines*/ /*For a row, get all the course information and add the date-time-lines*/
function getCourseInfo(row) { function getCourseInfo(row) {
console.log('WHAT');
semesterCode = new URL(window.location.href).pathname.split('/')[4]; semesterCode = new URL(window.location.href).pathname.split('/')[4];
$(".dateTimePlace").remove(); $(".dateTimePlace").remove();
$('table').find('tr').each(function () { $('table').find('tr').each(function () {
@@ -393,7 +396,7 @@ function getDistribution(sem) {
/*Open the modal and show all the data*/ /*Open the modal and show all the data*/
function openDialog(dep, cls, sem, professor, res) { function openDialog(dep, cls, sem, professor, res) {
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(100);
//initial text on the "save course button" //initial text on the "save course button"
@@ -448,20 +451,21 @@ function openDialog(dep, cls, sem, professor, res) {
$("#profname").text("with " + name); $("#profname").text("with " + name);
//close button //close button
span.onclick = function () { span.onclick = function () {
$("#myModal").fadeOut(200); close();
$("#snackbar").attr("class", "");
} }
setChart(data); setChart(data);
// When clicks anywhere outside of the modal, close it // When clicks anywhere outside of the modal, close it
window.onclick = function (event) { window.onclick = function (event) {
if (event.target == modal) { if (event.target == modal) {
$("#myModal").fadeOut(fadetime); close();
$("#snackbar").attr("class", "");
} }
} }
} }
function close() {
$("#myModal").fadeOut(fadetime);
$("#snackbar").attr("class", "");
}
function setChart(data) { function setChart(data) {
//set up the chart //set up the chart
@@ -608,6 +612,7 @@ function prettifyName() {
function getDescription() { function getDescription() {
// console.log(window.location.href); // console.log(window.location.href);
// console.log(profurl); // console.log(profurl);
console.log('hello');
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
method: "GET", method: "GET",
action: "xhttp", action: "xhttp",