options and more
This commit is contained in:
@@ -37,6 +37,9 @@ chrome.runtime.onInstalled.addListener(function() {
|
|||||||
chrome.storage.sync.set({savedCourses: arr}, function() {
|
chrome.storage.sync.set({savedCourses: arr}, function() {
|
||||||
console.log('initial course list');
|
console.log('initial course list');
|
||||||
});
|
});
|
||||||
|
chrome.storage.sync.set({courseConflictHighlight: true}, function() {
|
||||||
|
console.log('initial highlighting: true');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
|
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
|
||||||
@@ -119,7 +122,6 @@ function remove(request, sender, sendResponse) {
|
|||||||
var courses = data.savedCourses;
|
var courses = data.savedCourses;
|
||||||
console.log(courses);
|
console.log(courses);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
console.log(courses.length);
|
|
||||||
while(index<courses.length && courses[index].unique != request.course.unique){
|
while(index<courses.length && courses[index].unique != request.course.unique){
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,35 +29,12 @@ $(document).ready( function() {
|
|||||||
//go through all the rows in the list
|
//go through all the rows in the list
|
||||||
$('table').find('tr').each(function(){
|
$('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"
|
//if a course row, then add the extension button
|
||||||
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('images/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>');
|
||||||
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
|
||||||
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this),unique:uniquenum}, function(response) {
|
|
||||||
if(response.isConflict){
|
|
||||||
$(thisForm).find('td').each(function(){
|
|
||||||
$(this).css('color','#F44336');
|
|
||||||
$(this).css('text-decoration','line-through');
|
|
||||||
$(this).css('font-weight','normal');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(thisForm).find('td').each(function(){
|
|
||||||
$(this).css('color','black');
|
|
||||||
$(this).css('text-decoration','none');
|
|
||||||
$(this).css('font-weight','normal');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(response.alreadyContains){
|
|
||||||
$(thisForm).find('td').each(function(){
|
|
||||||
$(this).css('color','#4CAF50');
|
|
||||||
$(this).css('text-decoration','none');
|
|
||||||
$(this).css('font-weight','bold');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//update the conflicts
|
||||||
|
update();
|
||||||
/*Handle the button clicks*/
|
/*Handle the button clicks*/
|
||||||
$(".distButton").click(function(){
|
$(".distButton").click(function(){
|
||||||
var row = $(this).closest('tr');
|
var row = $(this).closest('tr');
|
||||||
@@ -101,7 +78,7 @@ $(document).ready( function() {
|
|||||||
/*Listen for update mssage coming from popup*/
|
/*Listen for update mssage coming from popup*/
|
||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
function(request, sender, sendResponse) {
|
function(request, sender, sendResponse) {
|
||||||
if (request.command == "update"){
|
if (request.command == "updateCourseList"){
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -109,12 +86,14 @@ $(document).ready( function() {
|
|||||||
|
|
||||||
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
||||||
function update(){
|
function update(){
|
||||||
|
chrome.storage.sync.get('courseConflictHighlight', function(data) {
|
||||||
|
console.log(data.courseConflictHighlight);
|
||||||
$('table').find('tr').each(function(){
|
$('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){
|
||||||
var thisForm = this;
|
var thisForm = this;
|
||||||
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
var uniquenum = $(this).find('td[data-th="Unique"]').text();
|
||||||
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this),unique:uniquenum}, function(response) {
|
chrome.runtime.sendMessage({command: "isSingleConflict",dtarr: getDtarr(this),unique:uniquenum}, function(response) {
|
||||||
if(response.isConflict){
|
if(response.isConflict && data.courseConflictHighlight){
|
||||||
$(thisForm).find('td').each(function(){
|
$(thisForm).find('td').each(function(){
|
||||||
$(this).css('color','#F44336');
|
$(this).css('color','#F44336');
|
||||||
$(this).css('text-decoration','line-through');
|
$(this).css('text-decoration','line-through');
|
||||||
@@ -138,6 +117,7 @@ function update(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For a row, get the date-time-array for checking conflicts*/
|
/* For a row, get the date-time-array for checking conflicts*/
|
||||||
@@ -204,7 +184,7 @@ function getCourseInfo(row){
|
|||||||
/*Handle if on the individual course page*/
|
/*Handle if on the individual course page*/
|
||||||
if(typeof coursename == 'undefined'){
|
if(typeof coursename == 'undefined'){
|
||||||
coursename = $("#details h2").text();
|
coursename = $("#details h2").text();
|
||||||
profinit = profinit.substring(0,1);
|
profinit = $("table").find("td[data-th='Instructor']").text().split(", ")[1].substring(0,1);
|
||||||
profurl = document.URL;
|
profurl = document.URL;
|
||||||
}
|
}
|
||||||
getDescription();
|
getDescription();
|
||||||
@@ -291,17 +271,12 @@ function openDialog(dep,cls,sem,professor,res){
|
|||||||
});
|
});
|
||||||
//set if no grade distribution
|
//set if no grade distribution
|
||||||
var data;
|
var data;
|
||||||
if(typeof res == 'undefined'){
|
if(typeof res == 'undefined' || profname == ""){
|
||||||
data = [];
|
data = [];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
data = res.values[0];
|
data = res.values[0];
|
||||||
}
|
}
|
||||||
//if undefined professor, then pick the distribution for the prof with the largest number of overall student entries
|
|
||||||
var title = null
|
|
||||||
if(profname == "" && typeof res != 'undefined'){
|
|
||||||
title = res.values[0][1];
|
|
||||||
}
|
|
||||||
var modal = document.getElementById('myModal');
|
var modal = document.getElementById('myModal');
|
||||||
var span = document.getElementsByClassName("close")[0];
|
var span = document.getElementsByClassName("close")[0];
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
@@ -319,12 +294,15 @@ function openDialog(dep,cls,sem,professor,res){
|
|||||||
}
|
}
|
||||||
$("#title").append("<span style='color:"+color+";font-size:medium;'>"+" #"+uniquenum+"</>");
|
$("#title").append("<span style='color:"+color+";font-size:medium;'>"+" #"+uniquenum+"</>");
|
||||||
|
|
||||||
|
if(typeof profinit != "undefined" && profinit.length > 1){
|
||||||
|
profinit = profinit.substring(0,1);
|
||||||
|
}
|
||||||
var name;
|
var name;
|
||||||
if(profname == ""){
|
if(profname == ""){
|
||||||
name = "Undecided Professor ";
|
name = "Undecided Professor ";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
name = profinit+". "+profname.substring(0,1)+profname.substring(1).toLowerCase();
|
name = prettifyName();
|
||||||
}
|
}
|
||||||
$("#profname").text("with "+ name);
|
$("#profname").text("with "+ name);
|
||||||
//close button
|
//close button
|
||||||
@@ -343,7 +321,7 @@ function openDialog(dep,cls,sem,professor,res){
|
|||||||
text: null
|
text: null
|
||||||
},
|
},
|
||||||
subtitle: {
|
subtitle: {
|
||||||
text: title
|
text: null
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
enabled: false
|
enabled: false
|
||||||
@@ -405,7 +383,7 @@ function openDialog(dep,cls,sem,professor,res){
|
|||||||
}, function(chart) { // on complete
|
}, function(chart) { // on complete
|
||||||
if(data.length == 0){
|
if(data.length == 0){
|
||||||
//if no data, then show the message and hide the series
|
//if no data, then show the message and hide the series
|
||||||
chart.renderer.text('Could not find distribution for this Instructor teaching this Course', 100, 120)
|
chart.renderer.text('Could not find distribution for this Instructor teaching this Course.', 100, 120)
|
||||||
.css({
|
.css({
|
||||||
fontSize: '20px',
|
fontSize: '20px',
|
||||||
align:'center',
|
align:'center',
|
||||||
@@ -435,6 +413,12 @@ function prettifyTitle(){
|
|||||||
});
|
});
|
||||||
return output + " ("+department+" "+course_nbr+")";
|
return output + " ("+department+" "+course_nbr+")";
|
||||||
}
|
}
|
||||||
|
/* Format the Professor Name */
|
||||||
|
function prettifyName() {
|
||||||
|
return profinit + ". "+profname.replace(/\w\S*/g, function(txt){
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*Get the course description from the profurl and highlight the important elements, as well as set the eCIS, and rmp links.*/
|
/*Get the course description from the profurl and highlight the important elements, as well as set the eCIS, and rmp links.*/
|
||||||
function getDescription(){
|
function getDescription(){
|
||||||
|
|||||||
30
js/options.js
Normal file
30
js/options.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
chrome.storage.sync.get('courseConflictHighlight', function(data) {
|
||||||
|
if(data.courseConflictHighlight){
|
||||||
|
$("#toggleConflictHighlighting").text("Turn Off");
|
||||||
|
$("#toggleConflictHighlighting").css("background","#F44336");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#toggleConflictHighlighting").text("Turn On");
|
||||||
|
$("#toggleConflictHighlighting").css("background","#4CAF50");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#toggleConflictHighlighting").click(function(){
|
||||||
|
var action = $("#toggleConflictHighlighting").text();
|
||||||
|
if(action == "Turn Off"){
|
||||||
|
chrome.storage.sync.set({courseConflictHighlight: false}, function() {
|
||||||
|
$("#toggleConflictHighlighting").text("Turn On");
|
||||||
|
$("#toggleConflictHighlighting").css("background","#4CAF50");
|
||||||
|
});
|
||||||
|
} else{
|
||||||
|
chrome.storage.sync.set({courseConflictHighlight: true}, function() {
|
||||||
|
$("#toggleConflictHighlighting").text("Turn Off");
|
||||||
|
$("#toggleConflictHighlighting").css("background","#F44336");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
chrome.tabs.query({}, function(tabs) {
|
||||||
|
for(var i = 0; i<tabs.length; i++){
|
||||||
|
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
16
js/popup.js
16
js/popup.js
@@ -78,8 +78,8 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
|
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
|
||||||
$(this).find("#listRemove").click(function(){
|
$(this).find("#listRemove").click(function(){
|
||||||
$(thisForm).closest("ul").find("> p").remove();
|
|
||||||
var thisForm = this;
|
var thisForm = this;
|
||||||
|
$(thisForm).closest("ul").find("> p").remove();
|
||||||
chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) {
|
chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) {
|
||||||
$(thisForm).closest("li").fadeOut(200);
|
$(thisForm).closest("li").fadeOut(200);
|
||||||
if($(thisForm).closest("ul").children(':visible').length===1){
|
if($(thisForm).closest("ul").children(':visible').length===1){
|
||||||
@@ -88,8 +88,10 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateConflicts();
|
updateConflicts();
|
||||||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
chrome.tabs.query({}, function(tabs) {
|
||||||
chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
|
for(var i = 0; i<tabs.length; i++){
|
||||||
|
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -108,7 +110,7 @@ $(document).ready(function() {
|
|||||||
chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'});
|
chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'});
|
||||||
});
|
});
|
||||||
$("#open").click(function(){
|
$("#open").click(function(){
|
||||||
chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id });
|
chrome.tabs.create({ 'url': "options.html"});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,8 +144,10 @@ function makeLine(index){
|
|||||||
/*Clear the list and the storage of courses*/
|
/*Clear the list and the storage of courses*/
|
||||||
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({}, function(tabs) {
|
||||||
chrome.tabs.sendMessage(tabs[0].id, {command: "update"});
|
for(var i = 0; i<tabs.length; i++){
|
||||||
|
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
console.log("cleared");
|
console.log("cleared");
|
||||||
$("#courseList").fadeOut(300,function(){
|
$("#courseList").fadeOut(300,function(){
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
"name": "UT Registration Plus",
|
"name": "UT Registration Plus",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
|
"options_page": "options.html",
|
||||||
"description": "Improves the course registration process at the University of Texas at Austin!",
|
"description": "Improves the course registration process at the University of Texas at Austin!",
|
||||||
"permissions": [ "tabs",
|
"permissions": [ "tabs",
|
||||||
"declarativeContent",
|
"declarativeContent",
|
||||||
|
|||||||
15
options.html
Normal file
15
options.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card" style="width: 20%; margin-left:auto;margin-right: auto; height:auto;"id="header">
|
||||||
|
<h2 style="padding:16px 16px 0px 16px;font-size: 20px"> <u>Options</u> </h2>
|
||||||
|
<h2 style="padding: 5px 16px 16px 16px; font-weight: normal;display: inline-block;">Conflict Highlighting</h2>
|
||||||
|
<button id="toggleConflictHighlighting" class="matbut" style="margin: 5px 16px 16px 16px;font-size:medium; display:inline-block;float:right;background:#F44336;">Turn Off</button>
|
||||||
|
<script src="js/jquery-3.3.1.min.js"></script>
|
||||||
|
<script src="js/options.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user