This commit is contained in:
Sriram Hariharan
2018-08-11 16:32:26 -05:00
parent 76446c1f0f
commit 1beb77187f
7 changed files with 654 additions and 547 deletions

View File

@@ -1,4 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<link rel='stylesheet' href='css/fullcalendar.css' /> <link rel='stylesheet' href='css/fullcalendar.css' />
<link rel='stylesheet' href='css/_materialFullCalendar.css' /> <link rel='stylesheet' href='css/_materialFullCalendar.css' />
@@ -8,7 +9,7 @@
</head> </head>
<body> <body>
<div id='calendar'></div> <div id='calendar' style="height:50%; width: 60%"></div>
</body> </body>
<script src='js/calendar.js'></script> <script src='js/calendar.js'></script>

View File

@@ -36,62 +36,85 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
}); });
*/ */
/* Remove that awful yellow color and border from today in Schedule */ /* Remove that awful yellow color and border from today in Schedule */
.fc-state-highlight { .fc-state-highlight {
opacity: 0; opacity: 0;
border: none; border: none;
} }
/* Styling for each event from Schedule */ /* Styling for each event from Schedule */
.fc-time-grid-event.fc-v-event.fc-event {
.fc-time-grid-event.fc-v-event.fc-event {
border-radius: 4px; border-radius: 4px;
border: none; border: none;
padding: 5px; padding: 5px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3);
transition: 0.3s;
opacity: 1; opacity: 1;
} }
/* Bolds the name of the event and inherits the font size */ .fc-time-grid-event.fc-v-event.fc-event:hover {
.fc-event { box-shadow: 0 8px 12px 0 rgba(0, 0, 0, 0.3);
font-size: inherit !important; }
/* Bolds the name of the event and inherits the font size */
.fc-event {
font-size: small !important;
font-weight: bold !important; font-weight: bold !important;
} }
/* Remove the header border from Schedule */ /* Remove the header border from Schedule */
.fc td, .fc th {
border-style: none !important; .fc td,
.fc th {
border-style: ridge !important;
border-width: 1px !important; border-width: 1px !important;
padding: 0 !important; padding: 2px !important;
vertical-align: top !important; vertical-align: top !important;
} }
/* Inherits background for each event from Schedule. */ .fc-widget-header {
.fc-event .fc-bg { background-color: #cc5500;
color: white;
}
/* Inherits background for each event from Schedule. */
.fc-event .fc-bg {
z-index: 1 !important; z-index: 1 !important;
background: inherit !important; background: inherit !important;
opacity: 0.25 !important; opacity: 0.25 !important;
} }
/* Normal font weight for the time in each event */ /* Normal font weight for the time in each event */
.fc-time-grid-event .fc-time {
.fc-time-grid-event .fc-time {
font-weight: normal !important; font-weight: normal !important;
} }
/* Apply same opacity to all day events */ /* Apply same opacity to all day events */
.fc-ltr .fc-h-event.fc-not-end, .fc-rtl .fc-h-event.fc-not-start {
.fc-ltr .fc-h-event.fc-not-end,
.fc-rtl .fc-h-event.fc-not-start {
opacity: 0.65 !important; opacity: 0.65 !important;
margin-left: 12px !important; margin-left: 12px !important;
padding: 5px !important; padding: 5px !important;
} }
/* Apply same opacity to all day events */ /* Apply same opacity to all day events */
.fc-day-grid-event.fc-h-event.fc-event.fc-not-start.fc-end {
.fc-day-grid-event.fc-h-event.fc-event.fc-not-start.fc-end {
opacity: 0.65 !important; opacity: 0.65 !important;
margin-left: 12px !important; margin-left: 12px !important;
padding: 5px !important; padding: 5px !important;
} }
/* Material design button */ /* Material design button */
.fc-button {
.fc-button {
display: inline-block; display: inline-block;
position: relative; position: relative;
cursor: pointer; cursor: pointer;
@@ -127,22 +150,25 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
overflow: hidden; overflow: hidden;
-webkit-transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); -webkit-transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
} }
.fc-button:hover { .fc-button:hover {
background-color: rgba(158, 158, 158, 0.2); background-color: rgba(158, 158, 158, 0.2);
} }
.fc-button:focus, .fc-button:hover { .fc-button:focus,
.fc-button:hover {
text-decoration: none; text-decoration: none;
} }
/* The active button box is ugly so the active button will have the same appearance of the hover */ /* The active button box is ugly so the active button will have the same appearance of the hover */
.fc-state-active {
.fc-state-active {
background-color: rgba(158, 158, 158, 0.2); background-color: rgba(158, 158, 158, 0.2);
} }
/* Not raised button */ /* Not raised button */
.fc-state-default {
.fc-state-default {
box-shadow: None; box-shadow: None;
} }

View File

@@ -1,28 +1,31 @@
.card { .card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s; transition: 0.3s;
margin:5px; margin: 5px;
} }
.card:hover { .card:hover {
box-shadow: 0 8px 12px 0 rgba(0,0,0,0.2); box-shadow: 0 8px 12px 0 rgba(0, 0, 0, 0.2);
} }
.container { .container {
padding: 2px 16px; padding: 2px 16px;
} }
h2 {
padding: 10px 0px 0 10px;
}
li {
width: 350px;
} h2 {
body{ padding: 10px 0px 0 10px;
min-width: 500px; }
li {
width: 350px;
}
body {
min-width: 370px;
min-height: 400px; min-height: 400px;
} }
.matbut {
.matbut {
border: none; border: none;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
@@ -32,67 +35,69 @@
border-radius: 10px; border-radius: 10px;
font-size: medium; font-size: medium;
font-style: bold; font-style: bold;
box-shadow: 2px 2px 4px rgba(0, 0, 0, .4); box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
background: #FF9800; background: #ff9800;
}
.matbut{
position: relative;
overflow: hidden;
}
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 80%;
} }
.matbut:after { .matbut {
content: ''; position: relative;
position: absolute; overflow: hidden;
top: 50%; }
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, .5);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
.card:after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, .5);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
@keyframes ripple { .truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 80%;
}
.matbut:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, 0.5);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
.card:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, 0.5);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
@keyframes ripple {
0% { 0% {
transform: scale(0, 0); transform: scale(0, 0);
opacity: 1; opacity: 1;
} }
20% { 20% {
transform: scale(25, 25); transform: scale(25, 25);
opacity: 1; opacity: 1;
} }
100% { 100% {
opacity: 0; opacity: 0;
transform: scale(40, 40); transform: scale(40, 40);
} }
} }
.matbut:focus:not(:active)::after { .matbut:focus:not(:active)::after {
animation: ripple 1s ease-out; animation: ripple 1s ease-out;
} }
.card:focus:not(:active)::after {
.card:focus:not(:active)::after {
animation: ripple 1s ease-out; animation: ripple 1s ease-out;
} }

View File

@@ -1,191 +1,214 @@
.modal { .modal {
display: none; display: none;
position: fixed; position: fixed;
z-index: 1; z-index: 1;
padding-top: 100px; padding-top: 100px;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgb(0,0,0); background-color: rgb(0, 0, 0);
background-color: rgba(0,0,0,0.4); background-color: rgba(0, 0, 0, 0.4);
} }
.modal-content { .modal-content {
background-color: #fefefe; background-color: #fefefe;
margin: auto; margin: auto;
max-height: 85%; max-height: 85%;
overflow-y: auto; overflow-y: auto;
padding: 20px; padding: 20px;
border: 1px solid #888; border: 1px solid #888;
width: 50%; width: 50%;
} }
/* The Close Button */ /* The Close Button */
.close { .close {
color: #aaaaaa; color: #aaaaaa;
float: right; float: right;
padding: 5px; padding: 5px;
font-size: 28px; font-size: 28px;
font-weight: bold; font-weight: bold;
} }
.title { .title {
font-size: x-large; font-size: x-large;
font-weight: bold ; font-weight: bold;
padding-top: 5px; padding-top: 5px;
padding-left: 5px; padding-left: 5px;
margin:5px 0px 5px 0px; margin: 5px 0px 5px 0px;
} }
.description { .description {
padding: 5px; padding: 5px;
font-size: 15px; font-size: 15px;
font-weight: normal; font-weight: normal;
} }
.profname { .profname {
margin-left: 5px; margin-left: 5px;
padding-bottom: 5px; padding-bottom: 5px;
font-size: medium; font-size: medium;
margin-top: 10px; margin-top: 10px;
} }
.dateTimePlace { .dateTimePlace {
margin-left: 5px; margin-left: 5px;
font-size: smaller; font-size: smaller;
font-weight: bold; font-weight: bold;
} }
#chart { #chart {
min-width: auto; min-width: auto;
max-width: 800px; max-width: 800px;
height: 250px; height: 250px;
margin: 0 auto margin: 0 auto;
z-index:1; z-index: 1;
} }
.card { .card {
transition: 0.3s; transition: 0.3s;
margin-bottom: 10px; margin-bottom: 10px;
box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
0 2px 10px 0 rgba(0, 0, 0, 0.12);
} }
.card:hover { .card:hover {
box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19) box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2),
0 4px 20px 0 rgba(0, 0, 0, 0.19);
} }
.cardcontainer { .cardcontainer {
padding: 2px 16px; padding: 2px 16px;
transition:width 300ms ease-in-out, height 300ms ease-in-out; transition: width 300ms ease-in-out, height 300ms ease-in-out;
} }
.description { .description {
padding: 10px; padding: 10px;
} }
.close:hover, .close:hover,
.close:focus { .close:focus {
color: #000; color: #000;
text-decoration: none; text-decoration: none;
cursor: pointer; cursor: pointer;
} }
.topbuttons .matbut { .topbuttons .matbut {
display:inline-block; display: inline-block;
} }
.matbut { .matbut {
border: none; border: none;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
color: white; color: white;
margin: 10px 10px 10px 0px; margin: 10px 10px 10px 0px;
padding: 10px 10px; padding: 10px 10px;
border-radius: 10px; border-radius: 10px;
font-size: medium; font-size: medium;
font-style: bold; font-style: bold;
box-shadow: 2px 2px 4px rgba(0, 0, 0, .4); box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
background: #FF9800; background: #ff9800;
} }
.matbut{ .matbut {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.matbut:after { .matbut:after {
content: ''; content: "";
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
width: 5px; width: 5px;
height: 5px; height: 5px;
background: rgba(255, 255, 255, .5); background: rgba(255, 255, 255, 0.5);
opacity: 0; opacity: 0;
border-radius: 100%; border-radius: 100%;
transform: scale(1, 1) translate(-50%); transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%; transform-origin: 50% 50%;
} }
@keyframes ripple { @keyframes ripple {
0% { 0% {
transform: scale(0, 0); transform: scale(0, 0);
opacity: 1; opacity: 1;
} }
20% { 20% {
transform: scale(25, 25); transform: scale(25, 25);
opacity: 1; opacity: 1;
} }
100% { 100% {
opacity: 0; opacity: 0;
transform: scale(40, 40); transform: scale(40, 40);
} }
} }
.matbut:focus:not(:active)::after { .matbut:focus:not(:active)::after {
animation: ripple 1s ease-out; animation: ripple 1s ease-out;
} }
#snackbar { #snackbar {
visibility: hidden; visibility: hidden;
min-width: 250px; min-width: 250px;
margin-left: -200px; margin-left: -200px;
background-color: #333; background-color: #333;
color: #fff; color: #fff;
border-radius: 2px; border-radius: 2px;
padding: 16px; padding: 16px;
position: fixed; position: fixed;
z-index: 1; z-index: 1;
left: 50%; left: 50%;
bottom: 30px; bottom: 30px;
} }
#snackbar.show { #snackbar.show {
visibility: visible; visibility: visible;
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
animation: fadein 0.5s, fadeout 0.5s 2.5s; animation: fadein 0.5s, fadeout 0.5s 2.5s;
} }
@-webkit-keyframes fadein { @-webkit-keyframes fadein {
from {bottom: 0; opacity: 0;} from {
to {bottom: 30px; opacity: 1;} bottom: 0;
opacity: 0;
}
to {
bottom: 30px;
opacity: 1;
}
} }
@keyframes fadein { @keyframes fadein {
from {bottom: 0; opacity: 0;} from {
to {bottom: 30px; opacity: 1;} bottom: 0;
opacity: 0;
}
to {
bottom: 30px;
opacity: 1;
}
} }
@-webkit-keyframes fadeout { @-webkit-keyframes fadeout {
from {bottom: 30px; opacity: 1;} from {
to {bottom: 0; opacity: 0;} bottom: 30px;
opacity: 1;
}
to {
bottom: 0;
opacity: 0;
}
} }
@keyframes fadeout { @keyframes fadeout {
from {bottom: 30px; opacity: 1;} from {
to {bottom: 0; opacity: 0;} bottom: 30px;
} opacity: 1;
}
to {
bottom: 0;
opacity: 0;
}
}

View File

@@ -1,102 +1,102 @@
$(function() { $(function () {
const materialColors = ['#4CAF50', '#CDDC39',
const materialColors = '#FFC107', '#2196F3', '#F57C00', '#9C27B0', '#FF5722', , '#673AB7',
['#FF1744', '#F50057', '#D500F9', '#651FFF', '#FF5252', '#E91E63', '#009688', '#00BCD4',
'#3D5AFE', '#2979FF', '#00B0FF', '#00E5FF', '#4E342E', '#424242', '#9E9E9E'
'#1DE9B6', '#00E676', '#76FF03', '#C6FF00', ];
'#FFEA00', '#FFC400', '#FF9100', 'FF3D00', const days = new Map([
'#4E342E', '#424242', '#37474F']; ["M", "Monday"],
["T", "Tuesday"],
["W", "Wednesday"],
["TH", "Thursday"],
["F", "Friday"]
]);
// Counter to iterate through material colors to avoid duplicates // Counter to iterate through material colors to avoid duplicates
var colorCounter = 0; var colorCounter = 0;
// Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR' // Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR'
var classSchedules = []; var classSchedules = [];
chrome.storage.sync.get('savedCourses', function (data) { chrome.storage.sync.get("savedCourses", function (data) {
var savedCourses = data.savedCourses; var savedCourses = data.savedCourses;
// Iterate through each saved course and add to 'event' // Iterate through each saved course and add to 'event'
for (let i = 0; i < savedCourses.length; i++) { for (let i = 0; i < savedCourses.length; i++) {
var classInfo = savedCourses[i]; // Store all info for a single class var classInfo = savedCourses[i];
var department = classInfo.coursename.substring(0, classInfo.coursename.search(/\d/) - 2);
var department = classInfo.coursename.substring(0,classInfo.coursename.search(/\d/)-2); var course_nbr = classInfo.coursename.substring(classInfo.coursename.search(/\d/), classInfo.coursename.indexOf(" ", classInfo.coursename.search(/\d/)));
var course_nbr = classInfo.coursename.substring(classInfo.coursename.search(/\d/),classInfo.coursename.indexOf(" ",classInfo.coursename.search(/\d/)));
var uncapProf = classInfo.profname; var uncapProf = classInfo.profname;
uncapProf = uncapProf.charAt(0) + uncapProf.substring(1).toLowerCase(); uncapProf = uncapProf.charAt(0) + uncapProf.substring(1).toLowerCase();
for (let j = 0; j < classInfo.datetimearr.length; j++) { for (let j = 0; j < classInfo.datetimearr.length; j++) {
let session = classInfo.datetimearr[j]; // One single session for a class let session = classInfo.datetimearr[j]; // One single session for a class
setEventForSection(session, colorCounter, department, course_nbr, uncapProf);
if (session[0] == 'M') {
classSchedules.push({
title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter],
allday: false
});
}
if (session[0] == 'T') {
classSchedules.push({
title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter],
allday: false
});
}
if (session[0] == 'W') {
classSchedules.push({
title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter],
allday: false
});
}
if (session[0] == 'TH') {
classSchedules.push({
title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter],
allday: false
});
}
if (session[0] == 'F') {
classSchedules.push({
title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter],
allday: false
});
}
colorCounter++;
} }
colorCounter++;
} }
$("#calendar").fullCalendar({
$('#calendar').fullCalendar({
editable: false, // Don't allow editing of events editable: false, // Don't allow editing of events
handleWindowResize: true, handleWindowResize: true,
weekends: false, // will hide Saturdays and Sundays weekends: false, // will hide Saturdays and Sundays
slotDuration: '00:15:00', // 15 minute intervals on vertical column slotDuration: "00:30:00", // 15 minute intervals on vertical column
slotEventOverlap: false, // No overlapping between events slotEventOverlap: false, // No overlapping between events
defaultView: 'agendaWeek', // Only show week view defaultView: "agendaWeek", // Only show week view
header: false, // Hide buttons/titles header: false, // Hide buttons/titles
minTime: '08:00:00', // Start time minTime: "08:00:00", // Start time
maxTime: '21:00:00', // End time maxTime: "21:00:00", // End time
columnHeaderFormat: 'ddd', // Only show day of the week names columnHeaderFormat: "ddd", // Only show day of the week names
displayEventTime: true, // Display event time displayEventTime: true, // Display event time
allDaySlot: false, allDaySlot: false,
events: classSchedules Duration: {
}) hours: 1
},
height: 'auto',
events: classSchedules,
slotLabelFormat: [
'h:mm A' // lower level of text
],
eventRender: function (event, element, view) {
$(element).css("padding", "5px");
$(element).css("margin-bottom", "5px");
},
eventClick: function (calEvent, jsEvent, view) {
console.log(calEvent);
// $(this).css('background-color', 'green');
alert('Event: ' + savedCourses[0].coursename);
// change the border color just for fun
}
});
}); });
function setEventForSection(session, colorCounter, department, course_nbr, uncapProf) {
var fullday = days.get(session[0]);
classSchedules.push({
title: `${department}-${course_nbr} with ${uncapProf}`,
start: moment().format("YYYY-MM-") +
moment()
.day(fullday)
._d.toString()
.split(" ")[2] +
"T" +
session[1][0] +
":00",
end: moment().format("YYYY-MM-") +
moment()
.day(fullday)
._d.toString()
.split(" ")[2] +
"T" +
session[1][1] +
":00",
color: materialColors[colorCounter],
allday: false
});
}
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.command == "updateCourseList") {
//update the calendar here
}
});
}); });

View File

@@ -13,130 +13,142 @@ var chart;
var description; var description;
var status; var status;
const days = new Map([["M" ,"Monday"], const days = new Map([
["T", "Tuesday"], ["W", "Wednesday"],["TH" ,"Thursday"], ["M", "Monday"],
["F", "Friday"]]); ["T", "Tuesday"],
["W", "Wednesday"],
["TH", "Thursday"],
["F", "Friday"]
]);
const fadetime = 150; const fadetime = 150;
const butdelay = 100; const butdelay = 100;
//This extension may be super lit, but you know what's even more lit? //This extension may be super lit, but you know what's even more lit?
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann //Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
$(document).ready( function() { $(function () {
loadDataBase(); loadDataBase();
//make heading and modal //make heading and modal
$("table thead th:last-child").after('<th scope=col>Plus</th>'); $("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 id="title">Computer Fluency (C S 302)</h2><h2 class=profname id="profname">with Bruce Porter</h2><div id="topbuttons" 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 id="description" style="list-style-type:disc"></ul></div></div><div class=card ><div id="chartcontainer" class=cardcontainer><div id=chart></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 id="title">Computer Fluency (C S 302)</h2><h2 class=profname id="profname">with Bruce Porter</h2><div id="topbuttons" 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 id="description" style="list-style-type:disc"></ul></div></div><div class=card ><div id="chartcontainer" class=cardcontainer><div id=chart></div></div></div>';
$("#container").prepend(modhtml); $("#container").prepend(modhtml);
$("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>"); $("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>");
//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 //if a course row, then add the extension button
$(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>');
} }
}); });
//update the conflicts //update the conflicts
update(); 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');
getCourseInfo(row); getCourseInfo(row);
getDistribution(); getDistribution();
}); });
$("#saveCourse").click(function(){ $("#saveCourse").click(function () {
var c = new Course(coursename,uniquenum, profname, datetimearr, status, profurl); var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl);
chrome.runtime.sendMessage({command: "courseStorage",course: c, action:$("#saveCourse").text().substring(0,$("#saveCourse").text().indexOf(" ")).toLowerCase()}, function(response) { chrome.runtime.sendMessage({
command: "courseStorage",
course: c,
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
}, function (response) {
$("#saveCourse").text(response.label); $("#saveCourse").text(response.label);
$("#snackbar").text(response.done); $("#snackbar").text(response.done);
$("#snackbar").attr("class","show"); $("#snackbar").attr("class", "show");
setTimeout(function(){$("#snackbar").attr("class","");}, 3000); setTimeout(function () {
$("#snackbar").attr("class", "");
}, 3000);
setTimeout(update(), 1000); setTimeout(update(), 1000);
}); });
}); });
$("#Syllabi").click(function(){ $("#Syllabi").click(function () {
setTimeout(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); }, butdelay);
}); });
$("#rateMyProf").click(function(){ $("#rateMyProf").click(function () {
setTimeout(function(){ setTimeout(function () {
window.open(rmpLink); window.open(rmpLink);
}, butdelay); }, butdelay);
}); });
$("#eCIS").click(function(){ $("#eCIS").click(function () {
setTimeout(function(){ setTimeout(function () {
window.open(eCISLink); window.open(eCISLink);
}, butdelay); }, butdelay);
}); });
/*Close Modal when hit escape*/ /*Close Modal when hit escape*/
$(document).keydown(function(e) { $(document).keydown(function (e) {
if (e.keyCode == 27) { if (e.keyCode == 27) {
$("#myModal").fadeOut(fadetime); $("#myModal").fadeOut(fadetime);
} }
$("#snackbar").attr("class",""); $("#snackbar").attr("class", "");
}); });
/*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 == "updateCourseList"){ if (request.command == "updateCourseList") {
update(); update();
} }
}); });
}); });
/* 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) { chrome.storage.sync.get('courseConflictHighlight', function (data) {
$('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({
if(response.isConflict && data.courseConflictHighlight){ command: "isSingleConflict",
$(thisForm).find('td').each(function(){ dtarr: getDtarr(this),
$(this).css('color','#F44336'); unique: uniquenum
$(this).css('text-decoration','line-through'); }, function (response) {
$(this).css('font-weight','normal'); if (response.isConflict && data.courseConflictHighlight) {
}); $(thisForm).find('td').each(function () {
} $(this).css('color', '#F44336');
else { $(this).css('text-decoration', 'line-through');
$(thisForm).find('td').each(function(){ $(this).css('font-weight', 'normal');
$(this).css('color','black'); });
$(this).css('text-decoration','none'); } else {
$(this).css('font-weight','normal'); $(thisForm).find('td').each(function () {
}); $(this).css('color', 'black');
} $(this).css('text-decoration', 'none');
if(response.alreadyContains){ $(this).css('font-weight', 'normal');
$(thisForm).find('td').each(function(){ });
$(this).css('color','#4CAF50'); }
$(this).css('text-decoration','none'); if (response.alreadyContains) {
$(this).css('font-weight','bold'); $(thisForm).find('td').each(function () {
}); $(this).css('color', '#4CAF50');
} $(this).css('text-decoration', 'none');
}); $(this).css('font-weight', 'bold');
} });
}); }
});
}
});
}); });
} }
/* For a row, get the date-time-array for checking conflicts*/ /* For a row, get the date-time-array for checking conflicts*/
function getDtarr(row){ function getDtarr(row) {
var numlines = $(row).find('td[data-th="Days"]>span').length; var numlines = $(row).find('td[data-th="Days"]>span').length;
var dtarr = []; var dtarr = [];
for(var i=0; i<numlines;i++){ for (var i = 0; i < numlines; i++) {
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();
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 = "";
if(letter == "T" && j <date.length-1 && date.charAt(j+1) == "H"){ if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
dtarr.push(["TH", convertTime(time),place]); dtarr.push(["TH", convertTime(time), place]);
} } else {
else { if (letter != "H") {
if(letter != "H"){ dtarr.push([letter, convertTime(time), place]);
dtarr.push([letter, convertTime(time),place]);
} }
} }
} }
@@ -145,7 +157,7 @@ function getDtarr(row){
} }
/*Course object for passing to background*/ /*Course object for passing to background*/
function Course(coursename, unique, profname,datetimearr, status, link){ function Course(coursename, unique, profname, datetimearr, status, link) {
this.coursename = coursename; this.coursename = coursename;
this.unique = unique; this.unique = unique;
this.profname = profname; this.profname = profname;
@@ -155,126 +167,124 @@ function Course(coursename, unique, profname,datetimearr, status, link){
} }
/*For a row, get all the course information and add the date-time-lines*/ /*For a row, get all the course information and add the date-time-lines*/
function getCourseInfo(row){ function getCourseInfo(row) {
$(".dateTimePlace").remove(); $(".dateTimePlace").remove();
$('table').find('tr').each(function(){ $('table').find('tr').each(function () {
if($(this).find('td').hasClass("course_header")){ if ($(this).find('td').hasClass("course_header")) {
coursename = $(this).find('td').text() + ""; coursename = $(this).find('td').text() + "";
} }
if($(this).is(row)){ if ($(this).is(row)) {
profurl = $(this).find('td[data-th="Unique"] a').prop('href'); profurl = $(this).find('td[data-th="Unique"] a').prop('href');
uniquenum = $(this).find('td[data-th="Unique"]').text(); uniquenum = $(this).find('td[data-th="Unique"]').text();
status = $(this).find('td[data-th="Status"]').text(); status = $(this).find('td[data-th="Status"]').text();
profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0]; profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0];
profinit = $(this).find('td[data-th="Instructor"]').text().split(', ')[1]; profinit = $(this).find('td[data-th="Instructor"]').text().split(', ')[1];
if(profname.indexOf(" ") == 0){ if (profname.indexOf(" ") == 0) {
profname = profname.substring(1); profname = profname.substring(1);
} }
var numlines = $(this).find('td[data-th="Days"]>span').length; var numlines = $(this).find('td[data-th="Days"]>span').length;
datetimearr = []; datetimearr = [];
for(var i=0; i<numlines;i++){ for (var i = 0; i < numlines; i++) {
var date = $(this).find('td[data-th="Days"]>span:eq('+i+')').text(); var date = $(this).find('td[data-th="Days"]>span:eq(' + i + ')').text();
var time = $(this).find('td[data-th="Hour"]>span:eq('+i+')').text(); var time = $(this).find('td[data-th="Hour"]>span:eq(' + i + ')').text();
var place = $(this).find('td[data-th="Room"]>span:eq('+i+')').text(); var place = $(this).find('td[data-th="Room"]>span:eq(' + i + ')').text();
$("#topbuttons").before('<h2 class="dateTimePlace">'+makeLine(date,time,place)+'</th>'); $("#topbuttons").before('<h2 class="dateTimePlace">' + makeLine(date, time, place) + '</th>');
}
return false;
} }
return false; });
}
});
/*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 = $("table").find("td[data-th='Instructor']").text().split(", ")[1].substring(0,1); profinit = $("table").find("td[data-th='Instructor']").text().split(", ")[1].substring(0, 1);
profurl = document.URL; profurl = document.URL;
} }
getDescription(); getDescription();
department = coursename.substring(0,coursename.search(/\d/)-2); department = coursename.substring(0, coursename.search(/\d/) - 2);
course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/))); course_nbr = coursename.substring(coursename.search(/\d/), coursename.indexOf(" ", coursename.search(/\d/)));
} }
/* Make the day-time-arr and make the text for the date-time-line*/ /* Make the day-time-arr and make the text for the date-time-line*/
function makeLine(date, time, place){ function makeLine(date, time, place) {
var arr = []; var arr = [];
var output = ""; var output = "";
for(var i = 0; i<date.length;i++){ for (var i = 0; i < date.length; i++) {
var letter = date.charAt(i); var letter = date.charAt(i);
var day = ""; var day = "";
if(letter == "T" && i <date.length-1 && date.charAt(i+1) == "H"){ if (letter == "T" && i < date.length - 1 && date.charAt(i + 1) == "H") {
arr.push(days.get("TH")); arr.push(days.get("TH"));
datetimearr.push(["TH", convertTime(time),place]); datetimearr.push(["TH", convertTime(time), place]);
} } else {
else { if (letter != "H") {
if(letter != "H"){
arr.push(days.get(letter)); arr.push(days.get(letter));
datetimearr.push([letter, convertTime(time),place]); datetimearr.push([letter, convertTime(time), place]);
} }
} }
} }
if(arr.length > 2){ if (arr.length > 2) {
for(var i = 0; i<arr.length;i++){ for (var i = 0; i < arr.length; i++) {
if(i < arr.length-1){ if (i < arr.length - 1) {
output+=arr[i]+", " output += arr[i] + ", "
} }
if(i == arr.length-2){ if (i == arr.length - 2) {
output+= "and "; output += "and ";
} }
if(i == arr.length-1){ if (i == arr.length - 1) {
output+=arr[i]; output += arr[i];
} }
} }
} else if (arr.length == 2) {
output = arr[0] + " and " + arr[1];
} else {
output += arr[0];
} }
else if(arr.length == 2){ var building = place.substring(0, place.search(/\d/) - 1);
output = arr[0]+" and "+arr[1]; if (building == "") {
}
else{
output+=arr[0];
}
var building = place.substring(0,place.search(/\d/)-1);
if(building == ""){
building = "Undecided Location"; 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+"</>"; 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 + "</>";
} }
/*Convert time to 24hour format*/ /*Convert time to 24hour format*/
function convertTime(time){ function convertTime(time) {
var converted = time.replace(/\./g,'').split("-"); var converted = time.replace(/\./g, '').split("-");
for(var i = 0; i<2;i++){ for (var i = 0; i < 2; i++) {
converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm"); converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm");
} }
return converted; return converted;
} }
/*Query the grades database*/ /*Query the grades database*/
function getDistribution(){ function getDistribution() {
var query = "select * from agg"; var query = "select * from agg";
query += " where dept like '%"+department+"%'"; query += " where dept like '%" + department + "%'";
query += " and prof like '%"+profname.replace(/'/g, "")+"%'"; query += " and prof like '%" + profname.replace(/'/g, "") + "%'";
query += " and course_nbr like '%"+course_nbr+"%'"; query += " and course_nbr like '%" + course_nbr + "%'";
query += "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc"; query += "order by a1+a2+a3+b1+b2+b3+c1+c2+c3+d1+d2+d3+f desc";
var res = grades.exec(query)[0]; var res = grades.exec(query)[0];
var output = ""; var output = "";
openDialog(department,coursename,"aggregate",profname,res); openDialog(department, coursename, "aggregate", profname, res);
} }
/*Open the modal and show all the data*/ /*Open the modal and show all the data*/
function openDialog(dep,cls,sem,professor,res){ function openDialog(dep, cls, sem, professor, res) {
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(fadetime);
//initial text on the "save course button" //initial text on the "save course button"
chrome.runtime.sendMessage({command: "alreadyContains",unique: uniquenum}, function(response) { chrome.runtime.sendMessage({
if(response.alreadyContains){ command: "alreadyContains",
unique: uniquenum
}, function (response) {
if (response.alreadyContains) {
$("#saveCourse").text("Remove Course -"); $("#saveCourse").text("Remove Course -");
} } else {
else{
$("#saveCourse").text("Add Course +"); $("#saveCourse").text("Add Course +");
} }
}); });
//set if no grade distribution //set if no grade distribution
var data; var data;
if(typeof res == 'undefined' || profname == ""){ if (typeof res == 'undefined' || profname == "") {
data = []; data = [];
} } else {
else{
data = res.values[0]; data = res.values[0];
} }
var modal = document.getElementById('myModal'); var modal = document.getElementById('myModal');
@@ -283,32 +293,29 @@ function openDialog(dep,cls,sem,professor,res){
$("#title").text(prettifyTitle()); $("#title").text(prettifyTitle());
var color = "black"; var color = "black";
if(status.includes("open")){ if (status.includes("open")) {
color = "#4CAF50"; color = "#4CAF50";
} } else if (status.includes("waitlisted")) {
else if(status.includes("waitlisted")){
color = "#FF9800" color = "#FF9800"
} } else if (status.includes("closed") || status.includes("cancelled")) {
else if(status.includes("closed") || status.includes("cancelled")){
color = "#F44336"; color = "#F44336";
} }
$("#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){ if (typeof profinit != "undefined" && profinit.length > 1) {
profinit = profinit.substring(0,1); profinit = profinit.substring(0, 1);
} }
var name; var name;
if(profname == ""){ if (profname == "") {
name = "Undecided Professor "; name = "Undecided Professor ";
} } else {
else{
name = prettifyName(); name = prettifyName();
} }
$("#profname").text("with "+ name); $("#profname").text("with " + name);
//close button //close button
span.onclick = function() { span.onclick = function () {
$("#myModal").fadeOut(200); $("#myModal").fadeOut(200);
$("#snackbar").attr("class",""); $("#snackbar").attr("class", "");
} }
//set up the chart //set up the chart
chart = Highcharts.chart('chart', { chart = Highcharts.chart('chart', {
@@ -328,21 +335,21 @@ function openDialog(dep,cls,sem,professor,res){
}, },
xAxis: { xAxis: {
title: { title: {
text: 'Grades' text: 'Grades'
}, },
categories: [ categories: [
'A', 'A',
'A-', 'A-',
'B+', 'B+',
'B', 'B',
'B-', 'B-',
'C+', 'C+',
'C', 'C',
'C-', 'C-',
'D+', 'D+',
'D', 'D',
'D-', 'D-',
'F' 'F'
], ],
crosshair: true crosshair: true
}, },
@@ -378,94 +385,134 @@ function openDialog(dep,cls,sem,professor,res){
}, },
series: [{ series: [{
name: 'Grades', name: 'Grades',
data: [{y: data[6], color: '#4CAF50'}, {y: data[7], color: '#8BC34A'}, {y: data[8], color: '#CDDC39'}, {y: data[9], color: '#FFEB3B'}, {y: data[10], color: '#FFC107'}, {y: data[11], color: '#FFA000'}, {y: data[12], color: '#F57C00'}, {y: data[13], color: '#FF5722'}, {y: data[14], color: '#FF5252'}, {y: data[15], color: '#E64A19'}, {y: data[16], color: '#F44336'}, {y: data[17], color: '#D32F2F'}] data: [{
y: data[6],
color: '#4CAF50'
}, {
y: data[7],
color: '#8BC34A'
}, {
y: data[8],
color: '#CDDC39'
}, {
y: data[9],
color: '#FFEB3B'
}, {
y: data[10],
color: '#FFC107'
}, {
y: data[11],
color: '#FFA000'
}, {
y: data[12],
color: '#F57C00'
}, {
y: data[13],
color: '#FF5722'
}, {
y: data[14],
color: '#FF5252'
}, {
y: data[15],
color: '#E64A19'
}, {
y: data[16],
color: '#F44336'
}, {
y: data[17],
color: '#D32F2F'
}]
}] }]
}, 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',
width: '300px', width: '300px',
left:'160px' left: '160px'
}) })
.add(); .add();
$.each(chart.series, function(i, ser) { $.each(chart.series, function (i, ser) {
ser.hide(); ser.hide();
}); });
} }
}); // When clicks anywhere outside of the modal, close it }); // When clicks anywhere outside of the modal, close it
window.onclick = function(event) { window.onclick = function (event) {
if (event.target == modal) { if (event.target == modal) {
$("#myModal").fadeOut(fadetime); $("#myModal").fadeOut(fadetime);
$("#snackbar").attr("class",""); $("#snackbar").attr("class", "");
} }
} }
} }
/*Format the title*/ /*Format the title*/
function prettifyTitle(){ function prettifyTitle() {
val = department.length+course_nbr.length+3; val = department.length + course_nbr.length + 3;
output = coursename.substring(val).replace(/\b\w*/g, function(txt){ output = coursename.substring(val).replace(/\b\w*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}); });
return output + " ("+department+" "+course_nbr+")"; return output + " (" + department + " " + course_nbr + ")";
} }
/* Format the Professor Name */ /* Format the Professor Name */
function prettifyName() { function prettifyName() {
return profinit + ". "+profname.replace(/\w\S*/g, function(txt){ return profinit + ". " + profname.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); 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() {
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();
object.find('#details > p').each(function(){ object.find('#details > p').each(function () {
var sentence = $(this).text(); var sentence = $(this).text();
if(sentence.indexOf("Prerequisite") == 0){ if (sentence.indexOf("Prerequisite") == 0) {
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) {
sentence = "<li style='font-style: italic; padding: 0px 5px 5px 5px;'>" + sentence + "</li>";
} else if (sentence.indexOf("Restricted to") == 0) {
sentence = "<li style='color:red; padding: 0px 5px 5px 5px;'>" + sentence + "</li>";
} else {
sentence = "<li style='padding: 0px 5px 5px 5px;'>" + sentence + "</li>";
} }
else if(sentence.indexOf("May be") >=0 ){ output += sentence;
sentence = "<li style='font-style: italic; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
} });
else if(sentence.indexOf("Restricted to") == 0){
sentence = "<li style='color:red; padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
else{
sentence= "<li style='padding: 0px 5px 5px 5px;'>"+sentence+"</li>";
}
output+=sentence;
});
description = output; description = output;
$("#description").animate({'opacity': 0}, 200, function(){ $("#description").animate({
$(this).html(description).animate({'opacity': 1}, 200); 'opacity': 0
}, 200, function () {
$(this).html(description).animate({
'opacity': 1
}, 200);
}); });
var first = object.find('td[data-th="Instructor"]').text(); var first = object.find('td[data-th="Instructor"]').text();
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2)); first = first.substring(first.indexOf(", "), first.indexOf(" ", first.indexOf(", ") + 2));
first = first.substring(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"; rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query=" + first + " " + profname + ";&facetSearch=true";
if(profname == ""){ 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; 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 {
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();
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 { } else {
description = "<p style='color:red;font-style:bold'>You have been logged out. Please refresh the page and log back in using your UT EID and password.</p>" description = "<p style='color:red;font-style:bold'>You have been logged out. Please refresh the page and log back in using your UT EID and password.</p>"
$("#description").animate({'opacity': 0}, 200, function(){ $("#description").animate({
$(this).html(description).animate({'opacity': 1}, 200); 'opacity': 0
}, 200, function () {
$(this).html(description).animate({
'opacity': 1
}, 200);
}); });
rmpLink = "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255"; rmpLink = "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255";
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?"; eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?";
@@ -475,23 +522,23 @@ function getDescription(){
} }
/* Load the database*/ /* Load the database*/
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);
grades = sqldb; grades = sqldb;
}); });
} }
/* load the database from file */ /* load the database from file */
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();
}; };

View File

@@ -1,24 +1,29 @@
<!DOCTYPE html> <!DOCTYPE html>
<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="css/popup.css"> <link rel="stylesheet" href="css/popup.css">
</head> </head>
<body> <body>
<div class="card" id="header"> <div class="card" id="header">
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;"> <div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button> <button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button>
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px">Course List</button> <button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px;">Course List</button>
<button id="open" class="matbut" style="font-size:medium;background:#FFC107;margin: 10px;">Options</button> <button id="calendar" class="matbut" style="font-size:medium; background: #FF0000; margin:10px;">Schedule</button>
<button id="calendar" class="matbut" style="font-size:medium; background: #FF0000;margin: 10px;">Weekly Calendar</button>
</div> </div>
</div> </div>
<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> <span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span>
<h2> <h2>
<script src="js/jquery-3.3.1.min.js"></script> <script src="js/jquery-3.3.1.min.js"></script>
<script src="js/moment.min.js"></script> <script src="js/moment.min.js"></script>
<script src="js/popup.js"></script> <script src="js/popup.js"></script>
</body> </body>
</html>
</html>