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"){ else if(request.command == "isSingleConflict"){
isSingleConflict(request.dtarr,response); isSingleConflict(request.dtarr,request.unique,response);
} }
else if(request.command == "checkConflicts"){ else if(request.command == "checkConflicts"){
checkConflicts(response); 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) { chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses; var courses = data.savedCourses;
var conflict = false;
for(var i = 0; i<courses.length;i++){ for(var i = 0; i<courses.length;i++){
if(isConflict(currdatearr,courses[i].datetimearr)){ if(isConflict(currdatearr,courses[i].datetimearr)){
sendResponse({isConflict:true}); conflict = true;
return false; 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; var status;
const days = new Map([["M" ,"Monday"], const days = new Map([["M" ,"Monday"],
["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"], ["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"],
["F", "Friday"]]); ["F", "Friday"]]);
const fadetime = 150; const fadetime = 150;
const butdelay = 100; const butdelay = 100;
@@ -30,14 +30,33 @@ $(document).ready( 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" //if a course row, then add the extension button and do something if that course has been "saved"
var thisForm = this; 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>'); $(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>');
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, function(response) { 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){ if(response.isConflict){
//DO SOMETHING IF ALREADY CONTAINS //DO SOMETHING IF ALREADY CONTAINS
$(thisForm).find('td').each(function(){ $(thisForm).find('td').each(function(){
// $(this).css('font-weight','bold'); // $(this).css('font-weight','bold');
$(this).css('color','#F44336'); $(this).css('color','#F44336');
$(this).css('text-decoration','line-through'); $(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');
}); });
} }
}); });
@@ -45,7 +64,6 @@ $(document).ready( function() {
}); });
$(".distButton").click(function(){ $(".distButton").click(function(){
console.log("hello");
var row = $(this).closest('tr'); var row = $(this).closest('tr');
getCourseInfo(row); getCourseInfo(row);
getDistribution(); getDistribution();
@@ -96,22 +114,35 @@ function update(){
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" //if a course row, then add the extension button and do something if that course has been "saved"
var thisForm = this; 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){ if(response.isConflict){
//DO SOMETHING IF ALREADY CONTAINS //DO SOMETHING IF ALREADY CONTAINS
$(thisForm).find('td').each(function(){ $(thisForm).find('td').each(function(){
// $(this).css('font-weight','bold'); // $(this).css('font-weight','bold');
$(this).css('color','#F44336'); $(this).css('color','#F44336');
$(this).css('text-decoration','line-through'); $(this).css('text-decoration','line-through');
$(this).css('font-weight','normal');
}); });
} else { }
else {
$(thisForm).find('td').each(function(){ $(thisForm).find('td').each(function(){
// $(this).css('font-weight','bold'); // $(this).css('font-weight','bold');
$(this).css('color','black'); $(this).css('color','black');
$(this).css('text-decoration','none'); $(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 date = $(row).find('td[data-th="Days"]>span:eq('+i+')').text();
var time = $(row).find('td[data-th="Hour"]>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(); 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++){ for(var j = 0; j<date.length;j++){
var letter = date.charAt(j); var letter = date.charAt(j);
var day = ""; var day = "";
@@ -175,7 +205,7 @@ function getCourseInfo(row){
} }
return false; return false;
} }
}); });
if(typeof coursename == 'undefined'){ if(typeof coursename == 'undefined'){
coursename = $("#details h2").text(); coursename = $("#details h2").text();
profinit = profinit.substring(0,1); profinit = profinit.substring(0,1);
@@ -251,7 +281,6 @@ function getDistribution(){
function openDialog(dep,cls,sem,professor,res){ function openDialog(dep,cls,sem,professor,res){
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(fadetime);
chrome.runtime.sendMessage({command: "alreadyContains",unique: uniquenum}, function(response) { chrome.runtime.sendMessage({command: "alreadyContains",unique: uniquenum}, function(response) {
console.log("Already Contains: "+response.alreadyContains);
if(response.alreadyContains){ if(response.alreadyContains){
$("#saveCourse").text("Remove Course -"); $("#saveCourse").text("Remove Course -");
} }
@@ -266,7 +295,6 @@ function openDialog(dep,cls,sem,professor,res){
else{ else{
data = res.values[0]; data = res.values[0];
} }
console.log(res);
var title = null var title = null
if(profname == "" && typeof res != 'undefined'){ if(profname == "" && typeof res != 'undefined'){
title = res.values[0][1]; title = res.values[0][1];
@@ -406,12 +434,12 @@ function prettifyTitle(){
} }
function getDescription(){ function getDescription(){
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
method: "GET", method: "GET",
action: "xhttp", action: "xhttp",
url: profurl, url: profurl,
data: "" data: ""
}, function(response) { }, function(response) {
if(response){ if(response){
var output=""; var output="";
var object = $('<div/>').html(response).contents(); var object = $('<div/>').html(response).contents();
@@ -421,7 +449,6 @@ chrome.runtime.sendMessage({
sentence = "<li style='font-weight: bold; padding: 0px 5px 5px 5px;'>"+sentence+"</li>"; sentence = "<li style='font-weight: bold; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
} }
else if(sentence.indexOf("May be") >=0 ){ 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>"; sentence = "<li style='font-style: italic; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
} }
else if(sentence.indexOf("Restricted to") == 0){ else if(sentence.indexOf("Restricted to") == 0){
@@ -451,48 +478,28 @@ chrome.runtime.sendMessage({
} else { } else {
description = "Please Refresh the Page" description = "Please Refresh the Page"
} }
}); });
} }
function loadDataBase(){ function loadDataBase(){
sql = window.SQL; sql = window.SQL;
loadBinaryFile('grades.db', function(data){ loadBinaryFile('grades.db', function(data){
var sqldb = new SQL.Database(data); var sqldb = new SQL.Database(data);
// Database is ready // Database is ready
grades = sqldb; grades = sqldb;
//console.log(grades.exec(query)[0]); //console.log(grades.exec(query)[0]);
}); });
} }
function loadBinaryFile(path,success) { function loadBinaryFile(path,success) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL(path), true); xhr.open("GET", chrome.extension.getURL(path), true);
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";
xhr.onload = function() { xhr.onload = function() {
var data = new Uint8Array(xhr.response); var data = new Uint8Array(xhr.response);
var arr = new Array(); var arr = new Array();
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
success(arr.join("")); 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(); updateConflicts();
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++){ chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
chrome.tabs.sendMessage(tabs[i].id, {command: "update"});
}
}); });
}); });
}); });
@@ -145,9 +143,7 @@ function makeLine(index){
function clear(){ function clear(){
chrome.storage.sync.set({savedCourses: []}); chrome.storage.sync.set({savedCourses: []});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++){ chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
chrome.tabs.sendMessage(tabs[i].id, {command: "update"});
}
}); });
console.log("cleared"); console.log("cleared");
$("#courseList").fadeOut(300,function(){ $("#courseList").fadeOut(300,function(){

View File

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

View File

@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="popup.css"> <link rel="stylesheet" href="css/popup.css">
</head> </head>
<body> <body>
<div class="card" id="header"> <div class="card" id="header">
@@ -15,8 +15,8 @@
<ul id= "courseList" style="list-style-type: none;padding: 5px;"></ul> <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> <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> <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="js/jquery-3.3.1.min.js"></script>
<script src="moment.min.js"></script> <script src="js/moment.min.js"></script>
<script src="popup.js"></script> <script src="js/popup.js"></script>
</body> </body>
</html> </html>

6
todo
View File

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