diff --git a/js/content.js b/js/content.js index 9947eb73..a85ea941 100644 --- a/js/content.js +++ b/js/content.js @@ -7,6 +7,7 @@ var profname; var profinit; var uniquenum; var profurl; +var registerlink; var department; var course_nbr; var datetimearr = []; @@ -95,7 +96,7 @@ $(function () { }); function saveCourse() { - var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl); + var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl, registerlink); chrome.runtime.sendMessage({ command: "courseStorage", course: c, @@ -177,13 +178,14 @@ function getDtarr(row) { } /*Course object for passing to background*/ -function Course(coursename, unique, profname, datetimearr, status, link) { +function Course(coursename, unique, profname, datetimearr, status, link, registerlink) { this.coursename = coursename; this.unique = unique; this.profname = profname; this.datetimearr = datetimearr; this.status = status; this.link = link; + this.registerlink = registerlink; } /*For a row, get all the course information and add the date-time-lines*/ @@ -196,6 +198,8 @@ function getCourseInfo(row) { } if ($(this).is(row)) { profurl = $(this).find('td[data-th="Unique"] a').prop('href'); + registerlink = $(this).find('td[data-th="Add"] a').prop('href'); + console.log(registerlink); uniquenum = $(this).find('td[data-th="Unique"]').text(); status = $(this).find('td[data-th="Status"]').text(); profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0]; diff --git a/js/popup.js b/js/popup.js index 708a9b89..f6e68e27 100644 --- a/js/popup.js +++ b/js/popup.js @@ -41,7 +41,7 @@ chrome.storage.sync.get('savedCourses', function (data) { if (profname == "") { profname = "Undecided Professor"; } - var listhtml = "
  • " + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "

  • "; + var listhtml = "
  • " + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "

  • "; $("#courseList").append(listhtml); } }); @@ -88,6 +88,12 @@ $(document).ready(function () { $(this).find("#listMoreInfo").click(function () { window.open(courses[$(this).closest("li").attr("id")].link); }); + $(this).find("#register").click(function () { + let registerlink = courses[$(this).closest("li").attr("id")].registerlink; + chrome.tabs.query({currentWindow: true, active: true}, function (tab) { + chrome.tabs.update(tab.id, {url: registerlink}); + }); + }); /* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/ $(this).find("#listRemove").click(function () { var thisForm = this;