register button

This commit is contained in:
sghsri
2018-08-30 16:52:38 -05:00
parent 737493869f
commit 226ca88808
2 changed files with 13 additions and 3 deletions

View File

@@ -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];

View File

@@ -41,7 +41,7 @@ chrome.storage.sync.get('savedCourses', function (data) {
if (profname == "") {
profname = "Undecided Professor";
}
var listhtml = "<li id='" + i + "'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:" + color + "''><h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'><b>" + department + " " + course_nbr + "<span style='font-size:medium'>" + " with </span><span style='font-size:medium'>" + profname + " (" + courses[i].unique + ")" + "</span></b></h4><p style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>&#9660;</p></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px 5px 0px 15px;font-size:small;background-color:#FFCDD2;'>" + makeLine(i) + "</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>";
var listhtml = "<li id='" + i + "'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:" + color + "''><h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'><b>" + department + " " + course_nbr + "<span style='font-size:medium'>" + " with </span><span style='font-size:medium'>" + profname + " (" + courses[i].unique + ")" + "</span></b></h4><p style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>&#9660;</p></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px 5px 0px 15px;font-size:small;background-color:#FFCDD2;'>" + makeLine(i) + "</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='register' style='float:right;background:#4CAF50; margin:5px;'>Register</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>";
$("#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;