From 47ce8feca1dbf388a49668aaafae4a66eb833786 Mon Sep 17 00:00:00 2001 From: sghsri Date: Tue, 11 Dec 2018 21:46:27 -0600 Subject: [PATCH] load next pages --- js/content.js | 26 +++++++++++++++++++++++++- todo | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/js/content.js b/js/content.js index 8aa86c43..4ba21778 100644 --- a/js/content.js +++ b/js/content.js @@ -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 = $('
').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 = $('
').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(``); + } + current.append($(this)); + }); + loadNextPages(response); + } + }) + } +} + function saveCourse() { var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl, registerlink); chrome.runtime.sendMessage({ diff --git a/todo b/todo index 56061043..126fb1e5 100644 --- a/todo +++ b/todo @@ -1,4 +1,4 @@ -TODO as of 12/9/18 +TODO as of 12/11/18 FEATURES: - load all courses on first pages