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

@@ -30,14 +30,33 @@ $(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="20" height="20" src='+chrome.extension.getURL('disticon.png')+' /></td>');
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this)}, function(response) {
$(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');
$(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(){
console.log("hello");
var row = $(this).closest('tr');
getCourseInfo(row);
getDistribution();
@@ -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');
$(this).css('font-weight','normal');
});
} else {
}
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 = "";
@@ -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];
@@ -421,7 +449,6 @@ chrome.runtime.sendMessage({
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){
@@ -476,23 +503,3 @@ xhr.onload = function() {
};
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