reorganization

This commit is contained in:
Sriram Hariharan
2018-07-16 17:28:01 -05:00
parent 5f13c60923
commit add9171851
14 changed files with 727 additions and 718 deletions

BIN
grades.db

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -8,7 +8,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, response) {
}
}
else if(request.command == "isSingleConflict"){
isSingleConflict(request.dtarr,response);
isSingleConflict(request.dtarr,request.unique,response);
}
else if(request.command == "checkConflicts"){
checkConflicts(response);
@@ -58,16 +58,25 @@ function checkConflicts(sendResponse) {
});
}
function isSingleConflict(currdatearr, sendResponse){
function isSingleConflict(currdatearr, unique, sendResponse){
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
var conflict = false;
for(var i = 0; i<courses.length;i++){
if(isConflict(currdatearr,courses[i].datetimearr)){
sendResponse({isConflict:true});
return false;
conflict = true;
break;
}
}
sendResponse({isConflict:false});
var contains = false;
var i = 0;
while(i < courses.length && !contains){
if(courses[i].unique == unique){
contains = true;
}
i++;
}
sendResponse({isConflict:conflict,alreadyContains:contains});
});
}

View File

@@ -14,8 +14,8 @@ var description;
var status;
const days = new Map([["M" ,"Monday"],
["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"],
["F", "Friday"]]);
["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"],
["F", "Friday"]]);
const fadetime = 150;
const butdelay = 100;
@@ -27,25 +27,43 @@ $(document).ready( function() {
$("#container").prepend(modhtml);
$("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>");
$('table').find('tr').each(function(){
if(!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0){
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="20" height="20" src='+chrome.extension.getURL('disticon.png')+' /></td>');
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, function(response) {
if(response.isConflict){
$(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('images/disticon.png')+' /></td>');
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');
});
$(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');
});
}
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');
});
}
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');
});
}
});
}
});
$(".distButton").click(function(){
console.log("hello");
var row = $(this).closest('tr');
getCourseInfo(row);
getDistribution();
@@ -64,7 +82,7 @@ $(document).ready( function() {
$("#Syllabi").click(function(){
setTimeout(function(){
window.open('https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department='+department+'&course_number='+course_nbr+'&course_title=&unique=&instructor_first=&instructor_last='+profname+'&course_type=In+Residence&search=Search');
window.open('https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department='+department+'&course_number='+course_nbr+'&course_title=&unique=&instructor_first=&instructor_last='+profname+'&course_type=In+Residence&search=Search');
}, butdelay);
});
$("#rateMyProf").click(function(){
@@ -78,10 +96,10 @@ $(document).ready( function() {
}, butdelay);
});
$(document).keydown(function(e) {
if (e.keyCode == 27) {
$("#myModal").fadeOut(fadetime);
}
$("#snackbar").attr("class","");
if (e.keyCode == 27) {
$("#myModal").fadeOut(fadetime);
}
$("#snackbar").attr("class","");
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
@@ -96,22 +114,35 @@ function update(){
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) {
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');
});
} else {
$(this).css('font-weight','normal');
});
}
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');
});
}
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');
});
}
});
}
});
}
@@ -123,7 +154,6 @@ function getDtarr(row){
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 = "";
@@ -157,8 +187,8 @@ function getCourseInfo(row){
}
if($(this).is(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();
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];
profinit = $(this).find('td[data-th="Instructor"]').text().split(', ')[1];
if(profname.indexOf(" ") == 0){
@@ -172,10 +202,10 @@ function getCourseInfo(row){
var place = $(this).find('td[data-th="Room"]>span:eq('+i+')').text();
$("#topbuttons").before('<h2 class="dateTimePlace">'+makeLine(date,time,place)+'</th>');
// makeLine(date,time,place);
}
return false;
}
});
return false;
}
});
if(typeof coursename == 'undefined'){
coursename = $("#details h2").text();
profinit = profinit.substring(0,1);
@@ -251,7 +281,6 @@ function getDistribution(){
function openDialog(dep,cls,sem,professor,res){
$("#myModal").fadeIn(fadetime);
chrome.runtime.sendMessage({command: "alreadyContains",unique: uniquenum}, function(response) {
console.log("Already Contains: "+response.alreadyContains);
if(response.alreadyContains){
$("#saveCourse").text("Remove Course -");
}
@@ -266,7 +295,6 @@ function openDialog(dep,cls,sem,professor,res){
else{
data = res.values[0];
}
console.log(res);
var title = null
if(profname == "" && typeof res != 'undefined'){
title = res.values[0][1];
@@ -406,25 +434,24 @@ function prettifyTitle(){
}
function getDescription(){
chrome.runtime.sendMessage({
method: "GET",
action: "xhttp",
url: profurl,
data: ""
}, function(response) {
if(response){
var output="";
var object = $('<div/>').html(response).contents();
object.find('#details > p').each(function(){
var sentence = $(this).text();
if(sentence.indexOf("Prerequisite") == 0){
sentence = "<li style='font-weight: bold; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
else if(sentence.indexOf("May be") >=0 ){
console.log(sentence.indexOf("May be"));
sentence = "<li style='font-style: italic; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
else if(sentence.indexOf("Restricted to") == 0){
chrome.runtime.sendMessage({
method: "GET",
action: "xhttp",
url: profurl,
data: ""
}, function(response) {
if(response){
var output="";
var object = $('<div/>').html(response).contents();
object.find('#details > p').each(function(){
var sentence = $(this).text();
if(sentence.indexOf("Prerequisite") == 0){
sentence = "<li style='font-weight: bold; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
else if(sentence.indexOf("May be") >=0 ){
sentence = "<li style='font-style: italic; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
else if(sentence.indexOf("Restricted to") == 0){
//console.log(sentence);
sentence = "<li style='color:red; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
@@ -434,65 +461,45 @@ chrome.runtime.sendMessage({
output+=sentence;
});
description = output;
$("#description").animate({'opacity': 0}, 200, function(){
$(this).html(description).animate({'opacity': 1}, 200);
});
var first = object.find('td[data-th="Instructor"]').text();
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2));
first = first.substring(2);
rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query="+first+" "+profname+";&facetSearch=true";
if(profname == ""){
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept="+department+"&s_in_search_course_num="+course_nbr;
description = output;
$("#description").animate({'opacity': 0}, 200, function(){
$(this).html(description).animate({'opacity': 1}, 200);
});
var first = object.find('td[data-th="Instructor"]').text();
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2));
first = first.substring(2);
rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query="+first+" "+profname+";&facetSearch=true";
if(profname == ""){
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept="+department+"&s_in_search_course_num="+course_nbr;
}
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"
}
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"
}
});
});
}
function loadDataBase(){
sql = window.SQL;
loadBinaryFile('grades.db', function(data){
var sqldb = new SQL.Database(data);
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]);
});
});
}
function loadBinaryFile(path,success) {
var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL(path), true);
xhr.responseType = "arraybuffer";
xhr.onload = function() {
var data = new Uint8Array(xhr.response);
var arr = new Array();
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
success(arr.join(""));
var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL(path), true);
xhr.responseType = "arraybuffer";
xhr.onload = function() {
var data = new Uint8Array(xhr.response);
var arr = new Array();
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
success(arr.join(""));
};
xhr.send();
};
xhr.send();
};
// function getProfessorLink(profname) {
// var name = profname.split(',');
// var lastname = profname[0];
// var firstinit = profname[1].substring(1);
// console.log(lastname + " "+firstinit);
// return new Promise((resolve, reject) => {
// chrome.runtime.sendMessage({
// method: "POST",
// url: "http://www.ratemyprofessors.com/search.jsp",
// data: "queryBy=teacherName&schoolName=university+of+texas+at+austin&query="+profname+"&facetSearch=true"
// }, function(response) {
// if (response) {
// console.log(response);
// }
// });
// });
// }

View File

View File

@@ -85,9 +85,7 @@ $(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"});
}
chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
});
});
});
@@ -145,9 +143,7 @@ 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"});
}
chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
});
console.log("cleared");
$("#courseList").fadeOut(300,function(){

View File

@@ -8,18 +8,17 @@
"declarativeContent",
"storage",
"*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*",
"*://*.ratemyprofessors.com/*",
"*://*.catalog.utexas.edu/ribbit/"
],
"content_scripts": [{
"css": ["styles.css"],
"js": ["moment.min.js","sql-memory-growth.js","highcharts.js","jquery-3.3.1.min.js","content.js"],
"css": ["css/styles.css"],
"js": ["js/moment.min.js","js/sql-memory-growth.js","js/highcharts.js","js/jquery-3.3.1.min.js","js/content.js"],
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
}],
"web_accessible_resources": [
"grades.db","disticon.png"],
"grades.db","images/disticon.png"],
"background": {
"scripts": ["background.js"],
"scripts": ["js/background.js"],
"persistent": true
},
"browser_action": {

View File

@@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="popup.css">
<link rel="stylesheet" href="css/popup.css">
</head>
<body>
<div class="card" id="header">
@@ -15,8 +15,8 @@
<ul id= "courseList" style="list-style-type: none;padding: 5px;"></ul>
<h2 id="empty" style="font-weight: normal;font-size: large;margin: 60px 30px 40px 30px ;">Doesn't Look Like Anything To Me.<br>
<span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span><h2>
<script src="jquery-3.3.1.min.js"></script>
<script src="moment.min.js"></script>
<script src="popup.js"></script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/popup.js"></script>
</body>
</html>

6
todo
View File

@@ -1,8 +1,7 @@
TODO as of 7/10/18:
- eureka integration
- use maps for schedule conflict
- update page with schedule conflict information
- descriiption when not loading properly, whne need to refresh page
CLEAN UP:
Everything lmao
@@ -45,5 +44,4 @@ FIXED/DONE as of 7/10/18:
- FIX toast bug
- FIX save course when no times blank
- FIX Open popup flickering
chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id });
- update page with schedule conflict information