highling conflicts on the UT course list screen
This commit is contained in:
@@ -7,6 +7,9 @@ chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
||||
remove(request,sender,response);
|
||||
}
|
||||
}
|
||||
else if(request.command == "isSingleConflict"){
|
||||
isSingleConflict(request.dtarr,response);
|
||||
}
|
||||
else if(request.command == "checkConflicts"){
|
||||
checkConflicts(response);
|
||||
}
|
||||
@@ -40,7 +43,7 @@ function checkConflicts(sendResponse) {
|
||||
var courses = data.savedCourses;
|
||||
for(var i = 0; i<courses.length;i++){
|
||||
for(var j=i+1; j<courses.length; j++){
|
||||
if(isConflict(courses[i],courses[j])){
|
||||
if(isConflict(courses[i].datetimearr,courses[j].datetimearr)){
|
||||
console.log("conflict");
|
||||
conflicts.push([courses[i],courses[j]]);
|
||||
}
|
||||
@@ -55,10 +58,20 @@ function checkConflicts(sendResponse) {
|
||||
});
|
||||
}
|
||||
|
||||
function isSingleConflict(currdatearr, sendResponse){
|
||||
chrome.storage.sync.get('savedCourses', function(data) {
|
||||
var courses = data.savedCourses;
|
||||
for(var i = 0; i<courses.length;i++){
|
||||
if(isConflict(currdatearr,courses[i].datetimearr)){
|
||||
sendResponse({isConflict:true});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sendResponse({isConflict:false});
|
||||
});
|
||||
}
|
||||
|
||||
function isConflict(courseA, courseB){
|
||||
var adtarr = courseA.datetimearr;
|
||||
var bdtarr = courseB.datetimearr;
|
||||
function isConflict(adtarr, bdtarr){
|
||||
for(var i = 0; i<adtarr.length;i++){
|
||||
var currday = adtarr[i][0];
|
||||
var currtimes = adtarr[i][1];
|
||||
|
||||
105
content.js
105
content.js
@@ -22,7 +22,7 @@ $(document).ready( function() {
|
||||
loadDataBase();
|
||||
//make heading and modal
|
||||
$("table thead th:last-child").after('<th scope=col>Plus</th>');
|
||||
var modhtml = '<div class=modal id=myModal><div class=modal-content><span class=close>×</span><div class=card><div class=cardcontainer><h2 class=title>Computer Fluency (C S 302)</h2><h2 class=profname>with Bruce Porter</h2><div class=topbuttons><button class=matbut id="rateMyProf" style="background: #4CAF50;"> RMP </button><button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button><button class=matbut id="Syllabi"> Past Syllabi </button><button class=matbut id="saveCourse" style="background: #F44336;"> Save Course +</button></div></div></div><div class=card><div class=cardcontainer style=""><ul class=description style="list-style-type:disc"></ul></div></div><div class=card><div class=cardcontainer><div id=chart></div></div></div></div>'
|
||||
var modhtml = '<div class=modal id=myModal><div class=modal-content><span class=close>×</span><div class=card><div class=cardcontainer><h2 class=title>Computer Fluency (C S 302)</h2><h2 class=profname>with Bruce Porter</h2><div class=topbuttons><button class=matbut id="rateMyProf" style="background: #4CAF50;"> RMP </button><button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button><button class=matbut id="Syllabi"> Past Syllabi </button><button class=matbut id="saveCourse" style="background: #F44336;"> Save Course +</button></div></div></div><div class=card><div class=cardcontainer style=""><ul class=description style="list-style-type:disc"></ul></div></div><div class=card ><div id="chartcontainer" class=cardcontainer><div id="profdropdown" style="position:relative; display:flex;visibility:hidden;flex-flow:row-reverse;height:30px;"><ul style="z-index:1000; margin:5px; position:absolute;" class = "dropdown-menu"></ul></div><div id=chart></div></div></div></div>'
|
||||
$("#container").prepend(modhtml);
|
||||
$("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>");
|
||||
$('table').find('tr').each(function(){
|
||||
@@ -30,15 +30,25 @@ $(document).ready( function() {
|
||||
//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" style="vertical-align: bottom; display:block;" width="25" height="25" src='+chrome.extension.getURL('disticon.png')+' /></td>');
|
||||
// chrome.runtime.sendMessage({command: "alreadyContains",unique: $(this).find('td[data-th="Unique"]').text()}, function(response) {
|
||||
// if(response.alreadyContains){
|
||||
// //DO SOMETHING IF ALREADY CONTAINS
|
||||
// $(thisForm).find('td').each(function(){
|
||||
// // $(this).css('font-weight','bold');
|
||||
// $(this).css('color','#4CAF50');
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, 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','bold');
|
||||
});
|
||||
}
|
||||
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');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,6 +65,7 @@ $(document).ready( function() {
|
||||
$("#snackbar").text(response.done);
|
||||
$("#snackbar").attr("class","show");
|
||||
setTimeout(function(){$("#snackbar").attr("class","");}, 3000);
|
||||
update();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,6 +92,59 @@ $(document).ready( function() {
|
||||
});
|
||||
});
|
||||
|
||||
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;
|
||||
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, 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','bold');
|
||||
});
|
||||
} 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');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
var time = $(row).find('td[data-th="Hour"]>span:eq('+i+')').text();
|
||||
var place = $(row).find('td[data-th="Room"]>span:eq('+i+')').text();
|
||||
console.log("DateLength: " +date.length);
|
||||
for(var j = 0; j<date.length;j++){
|
||||
var letter = date.charAt(j);
|
||||
var day = "";
|
||||
if(letter == "T" && j <date.length-1 && date.charAt(j+1) == "H"){
|
||||
dtarr.push(["TH", convertTime(time),place]);
|
||||
}
|
||||
else {
|
||||
if(letter != "H"){
|
||||
dtarr.push([letter, convertTime(time),place]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(dtarr);
|
||||
return dtarr;
|
||||
}
|
||||
|
||||
function Course(coursename, unique, profname,datetimearr, status, link){
|
||||
this.coursename = coursename;
|
||||
this.unique = unique;
|
||||
@@ -170,7 +234,10 @@ function makeLine(date, time, place){
|
||||
output+=arr[0];
|
||||
}
|
||||
var building = place.substring(0,place.search(/\d/)-1);
|
||||
return output + " at "+time.replace(/\./g,'').replace(/\-/g,' to ')+" in "+"<a style='font-size:medium' target='_blank' href='"+"https://maps.utexas.edu/buildings/UTM/"+building+"''>"+place.substring(0,place.search(/\d/)-1)+"</>";
|
||||
if(building == ""){
|
||||
building = "Undecided Location";
|
||||
}
|
||||
return output + " at "+time.replace(/\./g,'').replace(/\-/g,' to ')+" in "+"<a style='font-size:medium' target='_blank' href='"+"https://maps.utexas.edu/buildings/UTM/"+building+"''>"+building+"</>";
|
||||
}
|
||||
|
||||
function convertTime(time){
|
||||
@@ -185,6 +252,7 @@ function getDistribution(){
|
||||
query += " where dept like '%"+department+"%'";
|
||||
query += " and prof like '%"+profname+"%'";
|
||||
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);
|
||||
@@ -210,6 +278,16 @@ function openDialog(dep,cls,sem,professor,res){
|
||||
else{
|
||||
data = res.values[0];
|
||||
}
|
||||
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];
|
||||
modal.style.display = "block";
|
||||
@@ -247,13 +325,14 @@ span.onclick = function() {
|
||||
chart = Highcharts.chart('chart', {
|
||||
chart: {
|
||||
type: 'column',
|
||||
backgroundColor: ' #fefefe',
|
||||
spacingLeft: 10
|
||||
},
|
||||
title: {
|
||||
text: null
|
||||
},
|
||||
subtitle: {
|
||||
text: null
|
||||
text: title
|
||||
},
|
||||
legend: {
|
||||
enabled: false
|
||||
@@ -390,6 +469,8 @@ chrome.runtime.sendMessage({
|
||||
else{
|
||||
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?&s_in_action_sw=S&s_in_search_type_sw=N&s_in_search_name="+profname.substring(0,1)+profname.substring(1).toLowerCase()+"%2C%20"+first.substring(0,1)+first.substring(1).toLowerCase();
|
||||
}
|
||||
} else {
|
||||
description = "Please Refresh the Page"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
8
popup.js
8
popup.js
@@ -6,14 +6,14 @@ chrome.storage.sync.get('savedCourses', function(data) {
|
||||
var between = response.between;
|
||||
var text = "";
|
||||
for(var i = 0; i<between.length;i++){
|
||||
text+="Conflict between: "+ getSimpleName(between[i][0].coursename,between[i][0].unique) + " and "+getSimpleName(between[i][1].coursename,between[i][1].unique);
|
||||
text+="CONFLICT: "+ getSimpleName(between[i][0].coursename,between[i][0].unique) + " and "+getSimpleName(between[i][1].coursename,between[i][1].unique);
|
||||
isConflicted.push(between[i][0].unique);
|
||||
isConflicted.push(between[i][1].unique);
|
||||
if(i != between.length-1){
|
||||
text+= "<br>";
|
||||
}
|
||||
}
|
||||
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px;'>"+text+"</>");
|
||||
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px 5px 5px 10px'>"+text+"</>");
|
||||
}
|
||||
});
|
||||
courses = data.savedCourses;
|
||||
@@ -82,7 +82,9 @@ $(document).ready(function() {
|
||||
console.log($(thisForm).closest("ul").children(":visible").length);
|
||||
$(thisForm).closest("ul").find("> p").remove();
|
||||
if($(thisForm).closest("ul").children(':visible').length===1){
|
||||
$("#empty").fadeIn(200);
|
||||
$("#courseList").fadeOut(300,function(){
|
||||
$("#empty").fadeIn(200);
|
||||
});
|
||||
}
|
||||
updateConflicts();
|
||||
});
|
||||
|
||||
54
styles.css
54
styles.css
@@ -65,6 +65,7 @@
|
||||
max-width: 800px;
|
||||
height: 250px;
|
||||
margin: 0 auto
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
.card {
|
||||
@@ -194,4 +195,57 @@
|
||||
@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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user