load next pages

This commit is contained in:
sghsri
2018-12-11 21:46:27 -06:00
parent adad33c7ba
commit 47ce8feca1
2 changed files with 26 additions and 2 deletions

View File

@@ -29,6 +29,8 @@ const butdelay = 75;
//This extension may be super lit, but you know what's even more lit?
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
$(function () {
loadNextPages($("html").html());
$('[title*="next listing"]').remove();
loadDataBase();
//make heading and modal
if(!$("#kw_results_table").length){
@@ -47,7 +49,7 @@ $(function () {
//update the conflicts
update();
/*Handle the button clicks*/
$(".distButton").click(function () {
$("tbody").on('click','.distButton',function () {
var row = $(this).closest('tr');
getCourseInfo(row);
getDistribution();
@@ -97,6 +99,28 @@ $(function () {
});
});
function loadNextPages(inHTML){
var html = $('<div/>').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){
if(response){
var nextpage = $('<div/>').html(response).contents();
var current = $('tbody');
nextpage.find('tbody>tr').each(function(){
if(!($(this).find('td').hasClass("course_header") && $(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>`);
}
current.append($(this));
});
loadNextPages(response);
}
})
}
}
function saveCourse() {
var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl, registerlink);
chrome.runtime.sendMessage({

2
todo
View File

@@ -1,4 +1,4 @@
TODO as of 12/9/18
TODO as of 12/11/18
FEATURES:
- load all courses on first pages