×
@@ -93,6 +100,12 @@ $(function () {
getDistribution();
});
+ $(window).scroll(function () {
+ if ($(document).height() <= $(window).scrollTop() + $(window).height()) {
+ loadNextPages();
+ }
+ });
+
$("#saveCourse").click(function () {
saveCourse();
});
@@ -140,24 +153,25 @@ $(function () {
});
});
-function loadNextPages(inHTML) {
+function loadNextPages() {
chrome.storage.sync.get('loadAll', function (data) {
if (data.loadAll) {
$('[title*="next listing"]').remove();
- var html = $('
').html(inHTML).contents();
- let next = html.find("#next_nav_link");
- if (next.length) {
- let link = next.prop('href');
- console.log(link);
- chrome.runtime.sendMessage({
- method: "GET",
- action: "xhttp",
- url: link,
- data: ""
- }, function (response) {
+ let link = next.prop('href');
+ if (done && next && link) {
+ $("#nextlabel").css('display', 'inline-block');
+ $('.loader').css('display', 'inline-block');
+ done = false;
+ $.get(link, function (response) {
if (response) {
var nextpage = $('
').html(response).contents();
var current = $('tbody');
+ var last = current.find('.course_header>h2:last').text();
+ console.log(last);
+ next = nextpage.find("#next_nav_link");
+ done = true;
+ $("#nextlabel").hide();
+ $('.loader').hide();
nextpage.find('tbody>tr').each(function () {
if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
$(this).append(`
| `);
@@ -167,13 +181,42 @@ function loadNextPages(inHTML) {
// });
// }
}
- current.append($(this));
+ if (!($(this).find('td').hasClass("course_header") && last == $(this).find('td').text())) {
+ current.append($(this));
+ }
});
- loadNextPages(response);
+ update();
}
- })
- } else {
- update();
+ });
+ // chrome.runtime.sendMessage({
+ // method: "GET",
+ // action: "xhttp",
+ // url: link,
+ // data: ""
+ // }, function (response) {
+ // if (response) {
+ // var nextpage = $('
').html(response).contents();
+ // var current = $('tbody');
+ // var last = current.find('.course_header>h2:last').text();
+ // console.log(last);
+ // next = nextpage.find("#next_nav_link");
+ // done = true;
+ // nextpage.find('tbody>tr').each(function () {
+ // if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
+ // $(this).append(`
| `);
+ // // if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
+ // // $(this).find('td').each(function () {
+ // // $(this).css('background-color', '#E0E0E0');
+ // // });
+ // // }
+ // }
+ // if (!($(this).find('td').hasClass("course_header") && last == $(this).find('td').text())) {
+ // current.append($(this));
+ // }
+ // });
+ // update();
+ // }
+ // })
}
}
});
@@ -214,18 +257,12 @@ function update() {
unique: uniquenum
}, function (response) {
if (response.isConflict && data.courseConflictHighlight) {
- $(thisForm).find('td').each(function () {
- $(this).css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
- });
+ $(thisForm).find('td').css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
} else {
- $(thisForm).find('td').each(function () {
- $(this).css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
- });
+ $(thisForm).find('td').css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
}
if (response.alreadyContains) {
- $(thisForm).find('td').each(function () {
- $(this).css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
- });
+ $(thisForm).find('td').css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
}
});
}
diff --git a/js/popup.js b/js/popup.js
index 505905a8..5b5513e4 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -261,6 +261,9 @@ $("#importOrig").change(function (e) {
chrome.storage.sync.set({
savedCourses: impCourses
});
+ chrome.browserAction.setBadgeBackgroundColor({
+ color: '#bf5700'
+ });
chrome.browserAction.setBadgeText({ text: "" + impCourses.length });
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
@@ -370,6 +373,9 @@ function clear() {
});
}
});
+ chrome.browserAction.setBadgeBackgroundColor({
+ color: '#bf5700'
+ });
chrome.browserAction.setBadgeText({ text: "" });
$("#courseList").empty()
console.log("cleared");