diff --git a/css/popup.css b/css/popup.css index 18d7ee17..e74da9cb 100644 --- a/css/popup.css +++ b/css/popup.css @@ -36,7 +36,6 @@ background: #FF9800; } - /* Ripple magic */ .matbut{ position: relative; overflow: hidden; diff --git a/css/styles.css b/css/styles.css index 2d2fd3c0..a02d556f 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1,63 +1,62 @@ -/* The Modal (background) */ .modal { - display: none; /* Hidden by default */ - position: fixed; /* Stay in place */ - z-index: 1; /* Sit on top */ - padding-top: 100px; /* Location of the box */ - left: 0; - top: 0; - width: 100%; - height: 100%; /* Full height */ - background-color: rgb(0,0,0); /* Fallback color */ - background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + display: none; + position: fixed; + z-index: 1; + padding-top: 100px; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.4); } .modal-content { - background-color: #fefefe; - margin: auto; - max-height: 85%; - overflow-y: auto; - padding: 20px; - border: 1px solid #888; - width: 50%; + background-color: #fefefe; + margin: auto; + max-height: 85%; + overflow-y: auto; + padding: 20px; + border: 1px solid #888; + width: 50%; } /* The Close Button */ .close { - color: #aaaaaa; - float: right; - padding: 5px; - font-size: 28px; - font-weight: bold; + color: #aaaaaa; + float: right; + padding: 5px; + font-size: 28px; + font-weight: bold; } .title { - font-size: x-large; - font-weight: bold ; - padding-top: 5px; - padding-left: 5px; - margin:5px 0px 5px 0px; + font-size: x-large; + font-weight: bold ; + padding-top: 5px; + padding-left: 5px; + margin:5px 0px 5px 0px; } .description { - padding: 5px; - font-size: 15px; - font-weight: normal; + padding: 5px; + font-size: 15px; + font-weight: normal; } .profname { - margin-left: 5px; - padding-bottom: 5px; - font-size: medium; - margin-top: 10px; + margin-left: 5px; + padding-bottom: 5px; + font-size: medium; + margin-top: 10px; } .dateTimePlace { - margin-left: 5px; - font-size: smaller; - font-weight: bold; + margin-left: 5px; + font-size: smaller; + font-weight: bold; } #chart { @@ -65,43 +64,39 @@ max-width: 800px; height: 250px; margin: 0 auto - z-index:1; + z-index:1; } .card { - /* Add shadows to create the "card" effect */ - transition: 0.3s; - margin-bottom: 10px; - box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) + transition: 0.3s; + margin-bottom: 10px; + box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) } -/* On mouse-over, add a deeper shadow */ .card:hover { - box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19) + box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19) } -/* Add some padding inside the card container */ .cardcontainer { - padding: 2px 16px; - transition:width 300ms ease-in-out, height 300ms ease-in-out; + padding: 2px 16px; + transition:width 300ms ease-in-out, height 300ms ease-in-out; } .description { - padding: 10px; + padding: 10px; } .close:hover, .close:focus { - color: #000; - text-decoration: none; - cursor: pointer; + color: #000; + text-decoration: none; + cursor: pointer; } .topbuttons .matbut { - display:inline-block; + display:inline-block; } -/* Material style */ .matbut { border: none; outline: none; @@ -116,7 +111,6 @@ background: #FF9800; } -/* Ripple magic */ .matbut{ position: relative; overflow: hidden; @@ -140,15 +134,15 @@ 0% { transform: scale(0, 0); opacity: 1; -} -20% { + } + 20% { transform: scale(25, 25); opacity: 1; -} -100% { + } + 100% { opacity: 0; transform: scale(40, 40); -} + } } .matbut:focus:not(:active)::after { @@ -156,42 +150,42 @@ } #snackbar { - visibility: hidden; - min-width: 250px; - margin-left: -200px; - background-color: #333; - color: #fff; - border-radius: 2px; - padding: 16px; - position: fixed; - z-index: 1; - left: 50%; - bottom: 30px; + visibility: hidden; + min-width: 250px; + margin-left: -200px; + background-color: #333; + color: #fff; + border-radius: 2px; + padding: 16px; + position: fixed; + z-index: 1; + left: 50%; + bottom: 30px; } #snackbar.show { - visibility: visible; + visibility: visible; - -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; - animation: fadein 0.5s, fadeout 0.5s 2.5s; + -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; + animation: fadein 0.5s, fadeout 0.5s 2.5s; } @-webkit-keyframes fadein { - from {bottom: 0; opacity: 0;} - to {bottom: 30px; opacity: 1;} + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} } @keyframes fadein { - from {bottom: 0; opacity: 0;} - to {bottom: 30px; opacity: 1;} + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} } @-webkit-keyframes fadeout { - from {bottom: 30px; opacity: 1;} - to {bottom: 0; opacity: 0;} + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} } @keyframes fadeout { - from {bottom: 30px; opacity: 1;} - to {bottom: 0; opacity: 0;} + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} } \ No newline at end of file diff --git a/js/background.js b/js/background.js index b1d60863..ccb4e714 100644 --- a/js/background.js +++ b/js/background.js @@ -1,3 +1,4 @@ +/* Handle messages and their commands from content and popup scripts*/ chrome.runtime.onMessage.addListener(function(request, sender, response) { if(request.command == "courseStorage") { if(request.action == "add"){ @@ -30,13 +31,15 @@ chrome.runtime.onMessage.addListener(function(request, sender, response) { return true; }); - chrome.runtime.onInstalled.addListener(function() { +/* Initially set the course data in storage */ +chrome.runtime.onInstalled.addListener(function() { var arr = new Array(); chrome.storage.sync.set({savedCourses: arr}, function() { console.log('initial course list'); }); }); +/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/ function checkConflicts(sendResponse) { chrome.storage.sync.get('savedCourses', function(data) { var conflicts = []; @@ -58,6 +61,7 @@ function checkConflicts(sendResponse) { }); } +/* Find if the course at unique and with currdatearr is contained in the saved courses and if it conflicts with any other courses*/ function isSingleConflict(currdatearr, unique, sendResponse){ chrome.storage.sync.get('savedCourses', function(data) { var courses = data.savedCourses; @@ -80,6 +84,7 @@ function isSingleConflict(currdatearr, unique, sendResponse){ }); } +/* Check if conflict between two date-time-arrs*/ function isConflict(adtarr, bdtarr){ for(var i = 0; idefaultmessage.."); + //go through all the rows in the list $('table').find('tr').each(function(){ if(!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0){ //if a course row, then add the extension button and do something if that course has been "saved" var thisForm = this; $(this).append(''); var uniquenum = $(this).find('td[data-th="Unique"]').text(); - console.log(uniquenum); chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this),unique:uniquenum}, function(response) { if(response.isConflict){ - //DO SOMETHING IF ALREADY CONTAINS $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','#F44336'); $(this).css('text-decoration','line-through'); $(this).css('font-weight','normal'); @@ -45,7 +43,6 @@ $(document).ready( function() { } else { $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','black'); $(this).css('text-decoration','none'); $(this).css('font-weight','normal'); @@ -53,7 +50,6 @@ $(document).ready( function() { } if(response.alreadyContains){ $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','#4CAF50'); $(this).css('text-decoration','none'); $(this).css('font-weight','bold'); @@ -62,7 +58,7 @@ $(document).ready( function() { }); } }); - + /*Handle the button clicks*/ $(".distButton").click(function(){ var row = $(this).closest('tr'); getCourseInfo(row); @@ -95,12 +91,14 @@ $(document).ready( function() { window.open(eCISLink); }, butdelay); }); + /*Close Modal when hit escape*/ $(document).keydown(function(e) { if (e.keyCode == 27) { $("#myModal").fadeOut(fadetime); } $("#snackbar").attr("class",""); }); + /*Listen for update mssage coming from popup*/ chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { if (request.command == "update"){ @@ -109,17 +107,15 @@ $(document).ready( function() { }); }); +/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */ function update(){ $('table').find('tr').each(function(){ if(!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0){ - //if a course row, then add the extension button and do something if that course has been "saved" var thisForm = this; var uniquenum = $(this).find('td[data-th="Unique"]').text(); chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this),unique:uniquenum}, function(response) { if(response.isConflict){ - //DO SOMETHING IF ALREADY CONTAINS $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','#F44336'); $(this).css('text-decoration','line-through'); $(this).css('font-weight','normal'); @@ -127,7 +123,6 @@ function update(){ } else { $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','black'); $(this).css('text-decoration','none'); $(this).css('font-weight','normal'); @@ -135,18 +130,17 @@ function update(){ } if(response.alreadyContains){ $(thisForm).find('td').each(function(){ - // $(this).css('font-weight','bold'); $(this).css('color','#4CAF50'); $(this).css('text-decoration','none'); $(this).css('font-weight','bold'); }); } }); - } }); } +/* For a row, get the date-time-array for checking conflicts*/ function getDtarr(row){ var numlines = $(row).find('td[data-th="Days"]>span').length; var dtarr = []; @@ -170,6 +164,7 @@ function getDtarr(row){ return dtarr; } +/*Course object for passing to background*/ function Course(coursename, unique, profname,datetimearr, status, link){ this.coursename = coursename; this.unique = unique; @@ -179,6 +174,7 @@ function Course(coursename, unique, profname,datetimearr, status, link){ this.link = link; } +/*For a row, get all the course information and add the date-time-lines*/ function getCourseInfo(row){ $(".dateTimePlace").remove(); $('table').find('tr').each(function(){ @@ -201,11 +197,11 @@ function getCourseInfo(row){ var time = $(this).find('td[data-th="Hour"]>span:eq('+i+')').text(); var place = $(this).find('td[data-th="Room"]>span:eq('+i+')').text(); $("#topbuttons").before('

'+makeLine(date,time,place)+''); - // makeLine(date,time,place); } return false; } }); + /*Handle if on the individual course page*/ if(typeof coursename == 'undefined'){ coursename = $("#details h2").text(); profinit = profinit.substring(0,1); @@ -216,7 +212,7 @@ function getCourseInfo(row){ course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/))); } -//THIS CODE IS EXTREMELY MESSY, CLEAN UP GACK +/* Make the day-time-arr and make the text for the date-time-line*/ function makeLine(date, time, place){ var arr = []; var output = ""; @@ -260,6 +256,7 @@ function makeLine(date, time, place){ return output + " at "+time.replace(/\./g,'').replace(/\-/g,' to ')+" in "+""+building+""; } +/*Convert time to 24hour format*/ function convertTime(time){ var converted = time.replace(/\./g,'').split("-"); for(var i = 0; i<2;i++){ @@ -267,6 +264,8 @@ function convertTime(time){ } return converted; } + +/*Query the grades database*/ function getDistribution(){ var query = "select * from agg"; query += " where dept like '%"+department+"%'"; @@ -278,8 +277,10 @@ function getDistribution(){ openDialog(department,coursename,"aggregate",profname,res); } +/*Open the modal and show all the data*/ function openDialog(dep,cls,sem,professor,res){ $("#myModal").fadeIn(fadetime); + //initial text on the "save course button" chrome.runtime.sendMessage({command: "alreadyContains",unique: uniquenum}, function(response) { if(response.alreadyContains){ $("#saveCourse").text("Remove Course -"); @@ -288,6 +289,7 @@ function openDialog(dep,cls,sem,professor,res){ $("#saveCourse").text("Add Course +"); } }); + //set if no grade distribution var data; if(typeof res == 'undefined'){ data = []; @@ -295,6 +297,7 @@ function openDialog(dep,cls,sem,professor,res){ else{ data = res.values[0]; } + //if undefined professor, then pick the distribution for the prof with the largest number of overall student entries var title = null if(profname == "" && typeof res != 'undefined'){ title = res.values[0][1]; @@ -324,11 +327,12 @@ function openDialog(dep,cls,sem,professor,res){ name = profinit+". "+profname.substring(0,1)+profname.substring(1).toLowerCase(); } $("#profname").text("with "+ name); - + //close button span.onclick = function() { $("#myModal").fadeOut(200); $("#snackbar").attr("class",""); } + //set up the chart chart = Highcharts.chart('chart', { chart: { type: 'column', @@ -397,10 +401,10 @@ function openDialog(dep,cls,sem,professor,res){ series: [{ name: 'Grades', data: [{y: data[6], color: '#4CAF50'}, {y: data[7], color: '#8BC34A'}, {y: data[8], color: '#CDDC39'}, {y: data[9], color: '#FFEB3B'}, {y: data[10], color: '#FFC107'}, {y: data[11], color: '#FFA000'}, {y: data[12], color: '#F57C00'}, {y: data[13], color: '#FF5722'}, {y: data[14], color: '#FF5252'}, {y: data[15], color: '#E64A19'}, {y: data[16], color: '#F44336'}, {y: data[17], color: '#D32F2F'}] - }] -}, function(chart) { // on complete + }, function(chart) { // on complete if(data.length == 0){ + //if no data, then show the message and hide the series chart.renderer.text('Could not find distribution for this Instructor teaching this Course', 100, 120) .css({ fontSize: '20px', @@ -414,25 +418,25 @@ function openDialog(dep,cls,sem,professor,res){ }); } -}); // When the user clicks anywhere outside of the modal, close it +}); // When clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { $("#myModal").fadeOut(fadetime); $("#snackbar").attr("class",""); - } } } +/*Format the title*/ function prettifyTitle(){ val = department.length+course_nbr.length+3; output = coursename.substring(val).replace(/\b\w*/g, function(txt){ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); - return output + " ("+department+" "+course_nbr+")"; } +/*Get the course description from the profurl and highlight the important elements, as well as set the eCIS, and rmp links.*/ function getDescription(){ chrome.runtime.sendMessage({ method: "GET", @@ -452,7 +456,6 @@ function getDescription(){ sentence = "
  • "+sentence+"
  • "; } else if(sentence.indexOf("Restricted to") == 0){ - //console.log(sentence); sentence = "
  • "+sentence+"
  • "; } else{ @@ -482,15 +485,15 @@ function getDescription(){ } +/* Load the database*/ function loadDataBase(){ sql = window.SQL; loadBinaryFile('grades.db', function(data){ var sqldb = new SQL.Database(data); - // Database is ready - grades = sqldb; - //console.log(grades.exec(query)[0]); + grades = sqldb; }); } +/* load the database from file */ function loadBinaryFile(path,success) { var xhr = new XMLHttpRequest(); xhr.open("GET", chrome.extension.getURL(path), true); diff --git a/js/popup.js b/js/popup.js index b8978203..0fb2b847 100644 --- a/js/popup.js +++ b/js/popup.js @@ -1,52 +1,56 @@ var courses; +// get the courses from storage chrome.storage.sync.get('savedCourses', function(data) { + //find, build, and show the messages for the conflicts in the saved courses chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { var isConflicted = []; - if(response.isConflict){ - var between = response.between; - var text = ""; - for(var i = 0; i"+text+""); - } - }); - courses = data.savedCourses; - if(courses.length != 0){ - $("#empty").hide(); + if(response.isConflict){ + var between = response.between; + var text = ""; + for(var i = 0; i"+text+""); + } + }); + courses = data.savedCourses; + if(courses.length != 0){ + $("#empty").hide(); + } + // build and append the course list element + for(var i = 0; i

    "+department + " "+course_nbr+""+" with "+profname+" ("+courses[i].unique+")"+"

    "; - $("#courseList").append(listhtml); + else if(status.includes("waitlisted")){ + color = "#FF9800" } + else if(status.includes("closed") || status.includes("cancelled")){ + color = "#F44336"; + } + var department = courses[i].coursename.substring(0,courses[i].coursename.search(/\d/)-2); + var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/),courses[i].coursename.indexOf(" ",courses[i].coursename.search(/\d/))); + var profname = courses[i].profname.substring(0,1)+courses[i].profname.substring(1).toLowerCase(); + var listhtml = "
  • "+department + " "+course_nbr+""+" with "+profname+" ("+courses[i].unique+")"+"

  • "; + $("#courseList").append(listhtml); + } }); +/* prettify the name for the conflict messages*/ function getSimpleName(coursename, unique){ var department = coursename.substring(0,coursename.search(/\d/)-2); var course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/))); return department+" "+course_nbr+" ("+unique+")"; } +/* Update the conflict messages */ function updateConflicts(){ chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { var isConflicted = []; @@ -66,18 +70,18 @@ function updateConflicts(){ }); } +/* Handle the button clicks */ $(document).ready(function() { $("#courseList li").click(function(){ - //GACKY FIX $(this).find("#listMoreInfo").click(function(){ - window.open(courses[$(this).closest("li").attr("id")].link); + window.open(courses[$(this).closest("li").attr("id")].link); }); + /* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/ $(this).find("#listRemove").click(function(){ + $(thisForm).closest("ul").find("> p").remove(); var thisForm = this; chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) { $(thisForm).closest("li").fadeOut(200); - console.log($(thisForm).closest("ul").children(":visible").length); - $(thisForm).closest("ul").find("> p").remove(); if($(thisForm).closest("ul").children(':visible').length===1){ $("#courseList").fadeOut(300,function(){ $("#empty").fadeIn(200); @@ -85,29 +89,30 @@ $(document).ready(function() { } updateConflicts(); chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); + chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); }); }); }); + /* Show the times popout and more info options*/ if($(this).find("#moreInfo").is(":hidden")){ $(this).find("#moreInfo").fadeIn(200); - //alert("hello"); } else{ $(this).find("#moreInfo").fadeOut(200); } }); $("#clear").click(function(){ - clear(); + clear(); }); $("#schedule").click(function(){ - chrome.tabs.create({ 'url': 'https://utexas.collegescheduler.com/entry'}); + chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'}); }); $("#open").click(function(){ chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id }); }); }); +/* convert from the dtarr and maek the time lines*/ function makeLine(index){ var datetimearr = courses[index].datetimearr; //converted times back @@ -116,23 +121,17 @@ function makeLine(index){ datetimearr[i][1][0] = moment(datetimearr[i][1][0], ["HH:mm"]).format("h:mm A"); datetimearr[i][1][1] = moment(datetimearr[i][1][1], ["HH:mm"]).format("h:mm A"); } - //console.log(datetimearr[0][0]); for(var i = 0; i: "+timearr[i].split(",")[0]+" to "+timearr[i].split(",")[1]+"
    "; } @@ -140,14 +139,14 @@ function makeLine(index){ } +/*Clear the list and the storage of courses*/ function clear(){ chrome.storage.sync.set({savedCourses: []}); chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); + chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); }); console.log("cleared"); $("#courseList").fadeOut(300,function(){ - $("#empty").fadeIn(200); - + $("#empty").fadeIn(200); }); } \ No newline at end of file diff --git a/manifest.json b/manifest.json index f0d5ce87..0a8d2f3f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "manifest_version": 2, - "name": "UT Course Extension", + "name": "UT Registration Plus", "version": "0.1.0", - "description": "Chrome Extension to show more information on the UT Course catalog", + "description": "Improves the course registration process at the University of Texas at Austin!", "permissions": [ "tabs", "declarativeContent", "storage", diff --git a/popup.html b/popup.html index 8739abb8..8474c537 100644 --- a/popup.html +++ b/popup.html @@ -8,15 +8,16 @@

      Doesn't Look Like Anything To Me.
      - (No Courses Saved)

      - - - - - + (No Courses Saved) +

      + + + + +