more fixes

This commit is contained in:
Sriram Hariharan
2018-07-16 01:31:11 -05:00
parent fba16edeca
commit 5f13c60923
7 changed files with 121 additions and 173 deletions

View File

@@ -12,6 +12,7 @@ var datetimearr = [];
var chart;
var description;
var status;
const days = new Map([["M" ,"Monday"],
["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"],
["F", "Friday"]]);
@@ -29,7 +30,7 @@ $(document).ready( 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('<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom; display:block;" width="25" height="25" src='+chrome.extension.getURL('disticon.png')+' /></td>');
$(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('disticon.png')+' /></td>');
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, function(response) {
if(response.isConflict){
//DO SOMETHING IF ALREADY CONTAINS
@@ -82,6 +83,12 @@ $(document).ready( function() {
}
$("#snackbar").attr("class","");
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.command == "update"){
update();
}
});
});
function update(){
@@ -111,7 +118,6 @@ function update(){
function getDtarr(row){
var numlines = $(row).find('td[data-th="Days"]>span').length;
console.log("Numlines: "+numlines);
var dtarr = [];
for(var i=0; i<numlines;i++){
var date = $(row).find('td[data-th="Days"]>span:eq('+i+')').text();
@@ -131,7 +137,6 @@ function getDtarr(row){
}
}
}
console.log(dtarr);
return dtarr;
}
@@ -154,7 +159,6 @@ function getCourseInfo(row){
profurl = $(this).find('td[data-th="Unique"] a').prop('href');
uniquenum = $(this).find('td[data-th="Unique"]').text();
status = $(this).find('td[data-th="Status"]').text();
console.log(status);
profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0];
profinit = $(this).find('td[data-th="Instructor"]').text().split(', ')[1];
if(profname.indexOf(" ") == 0){
@@ -169,20 +173,16 @@ function getCourseInfo(row){
$("#topbuttons").before('<h2 class="dateTimePlace">'+makeLine(date,time,place)+'</th>');
// makeLine(date,time,place);
}
console.log(datetimearr);
return false;
}
});
if(typeof coursename == 'undefined'){
coursename = $("#details h2").text();
console.log(profname+" "+profinit);
profinit = profinit.substring(0,1);
profurl = document.URL;
}
//console.log(coursename);
getDescription();
department = coursename.substring(0,coursename.search(/\d/)-2);
//console.log(department);
course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/)));
}
@@ -240,12 +240,10 @@ function convertTime(time){
function getDistribution(){
var query = "select * from agg";
query += " where dept like '%"+department+"%'";
query += " and prof like '%"+profname+"%'";
query += " and prof like '%"+profname.replace(/'/g, "")+"%'";
query += " and course_nbr like '%"+course_nbr+"%'";
query += "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc";
// console.log(query);
var res = grades.exec(query)[0];
// console.log(res);
var output = "";
openDialog(department,coursename,"aggregate",profname,res);
}
@@ -271,12 +269,7 @@ function openDialog(dep,cls,sem,professor,res){
console.log(res);
var title = null
if(profname == "" && typeof res != 'undefined'){
// for(var i = 0; i<5;i++){
// $("#profdropdown-menu").append('<li class = "active menu-item"><a href = "#" class = "menu-item-link">'+res.values[i][1]+'</a></li>');
// }
// $("#profdropdown").css("visibility","visible");
title = res.values[0][1];
}
var modal = document.getElementById('myModal');
var span = document.getElementsByClassName("close")[0];
@@ -294,94 +287,90 @@ function openDialog(dep,cls,sem,professor,res){
color = "#F44336";
}
$("#title").append("<span style='color:"+color+";font-size:medium;'>"+" #"+uniquenum+"</>");
var name;
if(profname == ""){
name = "Undecided Professor ";
if(typeof res == 'undefined'){
}
}
else{
name = profinit+". "+profname.substring(0,1)+profname.substring(1).toLowerCase();
}
$("#profname").text("with "+ name);
//console.log(coursename);
span.onclick = function() {
$("#myModal").fadeOut(200);
$("#snackbar").attr("class","");
}
chart = Highcharts.chart('chart', {
chart: {
type: 'column',
backgroundColor: ' #fefefe',
spacingLeft: 10
},
title: {
text: null
},
subtitle: {
text: title
},
legend: {
enabled: false
},
xAxis: {
title: {
text: 'Grades'
span.onclick = function() {
$("#myModal").fadeOut(200);
$("#snackbar").attr("class","");
}
chart = Highcharts.chart('chart', {
chart: {
type: 'column',
backgroundColor: ' #fefefe',
spacingLeft: 10
},
categories: [
'A',
'A-',
'B+',
'B',
'B-',
'C+',
'C',
'C-',
'D+',
'D',
'D-',
'F'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Students'
}
},
credits: {
enabled: false
},
lang: {
noData: "The professor hasn't taught this class :("
},
tooltip: {
headerFormat: '<span style="font-size:small; font-weight:bold">{point.key}</span><table>',
pointFormat: '<td style="color:{black};padding:0;font-size:small; font-weight:bold;"><b>{point.y:.0f} Students</b></td>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
bar: {
pointPadding: 0.2,
borderWidth: 0
text: null
},
series: {
animation: {
duration: 700
subtitle: {
text: title
},
legend: {
enabled: false
},
xAxis: {
title: {
text: 'Grades'
},
categories: [
'A',
'A-',
'B+',
'B',
'B-',
'C+',
'C',
'C-',
'D+',
'D',
'D-',
'F'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Students'
}
}
},
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'}]
},
credits: {
enabled: false
},
lang: {
noData: "The professor hasn't taught this class :("
},
tooltip: {
headerFormat: '<span style="font-size:small; font-weight:bold">{point.key}</span><table>',
pointFormat: '<td style="color:{black};padding:0;font-size:small; font-weight:bold;"><b>{point.y:.0f} Students</b></td>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
bar: {
pointPadding: 0.2,
borderWidth: 0
},
series: {
animation: {
duration: 700
}
}
},
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
if(data.length == 0){
chart.renderer.text('Could not find distribution for this Instructor teaching this Course', 100, 120)
@@ -398,13 +387,13 @@ chart = Highcharts.chart('chart', {
}
}); // When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
$("#myModal").fadeOut(fadetime);
$("#snackbar").attr("class","");
window.onclick = function(event) {
if (event.target == modal) {
$("#myModal").fadeOut(fadetime);
$("#snackbar").attr("class","");
}
}
}
}
}
function prettifyTitle(){

BIN
grades.db

Binary file not shown.

View File

@@ -4,7 +4,7 @@
"name": "UT Course Extension",
"version": "0.1.0",
"description": "Chrome Extension to show more information on the UT Course catalog",
"permissions": [
"permissions": [ "tabs",
"declarativeContent",
"storage",
"*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*",

View File

@@ -8,7 +8,7 @@
<div class="card" id="header">
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button>
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px">Schedule</button>
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px">UT Planner</button>
<button id="open" class="matbut" style="font-size:medium;background:#FFC107;margin: 10px;">Options</button>
</div>
</div>

View File

@@ -67,9 +67,6 @@ function updateConflicts(){
}
$(document).ready(function() {
$("#clear").click(function(){
clear();
});
$("#courseList li").click(function(){
//GACKY FIX
$(this).find("#listMoreInfo").click(function(){
@@ -87,6 +84,11 @@ $(document).ready(function() {
});
}
updateConflicts();
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++){
chrome.tabs.sendMessage(tabs[i].id, {command: "update"});
}
});
});
});
if($(this).find("#moreInfo").is(":hidden")){
@@ -97,6 +99,15 @@ $(document).ready(function() {
$(this).find("#moreInfo").fadeOut(200);
}
});
$("#clear").click(function(){
clear();
});
$("#schedule").click(function(){
chrome.tabs.create({ 'url': 'https://utexas.collegescheduler.com/entry'});
});
$("#open").click(function(){
chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id });
});
});
function makeLine(index){
@@ -133,6 +144,11 @@ function makeLine(index){
function clear(){
chrome.storage.sync.set({savedCourses: []});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++){
chrome.tabs.sendMessage(tabs[i].id, {command: "update"});
}
});
console.log("cleared");
$("#courseList").fadeOut(300,function(){
$("#empty").fadeIn(200);

View File

@@ -158,10 +158,9 @@
#snackbar {
visibility: hidden;
min-width: 250px;
margin-left: -125px;
margin-left: -200px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
@@ -195,57 +194,4 @@
@keyframes fadeout {
from {bottom: 30px; opacity: 1;}
to {bottom: 0; opacity: 0;}
}
.dropdown-menu {
padding: 0;
margin: 0;
width: 130px;
display: inline-table;
border: solid 1px #CCCCCC;
max-height: 50px;
position: absolute;
font-size: x-small;
z-index: 100;
overflow: auto;
border-bottom-style: none;
background-color: #fefefe;;
}
.dropdown-menu .menu-item {
display: none;
}
.dropdown-menu .menu-item-link {
display: table-cell;
border-bottom: solid 1px #CCCCCC;
text-decoration: none;
color: rgba(89,87,87,0.9);
height: 30px;
padding: 5px;
vertical-align: middle;
cursor: pointer;
}
.dropdown-menu:hover .menu-item {
border-bottom-style: solid;
}
.dropdown-menu .menu-item-link:hover {
background-color: #DDDDDD;
}
.dropdown-menu:hover .menu-item {
display: table-row;
}
.dropdown-menu .menu-item.active {
display: table-header-group;
}
.dropdown-menu .menu-item.active .menu-item-link:after {
width: 0;
height: 0;
content: "";
position: absolute;
top: 12px;
right: 8px;
border-top: 4px solid rgba(0, 0, 0, 1);
border-left: 4px solid transparent;
border-right: 4px solid transparent;
}

31
todo
View File

@@ -1,29 +1,12 @@
TODO as of 7/10/18:
- undefined prof, show all possible profs from past? (DIFFERENT IF NO PROF)
- Online classes/no location
- save image of modal?
- no place
- Degree plan?
- default message save courses
- eureka integration
- underline Courses maybe? click to go to using the planner link thing
- schedule generator
- show schedule conflicts on the course page, and on the registration courselist
- highlight in red on save course screen
- sync saved
- "more at a glance" info on course list screen
- use maps for schedule conflict
- refresh the page get description
- update page with schedule conflict information
CLEAN UP:
Everything lmao
KNOWN BUGS:
- FIX POP UP CARD NOT FILLING FULL LENGTH
- FIX toast bug
- FIX save course when no times blank
- FIX Open popup flickering
- FIX DIST ICON NOT SCALING IN TD PROBLEM
IN-PROGRESS:
@@ -47,6 +30,20 @@ FIXED/DONE as of 7/10/18:
- Saving courses
- waitlist/closed/open colors
- popup.html
- no place
- Schedule Conflicts
- Online classes/no location
- default message save courses
- when almost everything is blank: M 379H as example
- added/removing/action toasts
- sync saved
- undefined prof, show all possible profs from past? (DIFFERENT IF NO PROF)
- refresh the page get description
- "more at a glance" info on course list screen
- show schedule conflicts on the course page, and on the registration courselist
- FIX POP UP CARD NOT FILLING FULL LENGTH
- FIX toast bug
- FIX save course when no times blank
- FIX Open popup flickering
chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id });