utplanner adding semi working, buttons working
This commit is contained in:
@@ -89,6 +89,7 @@
|
|||||||
.dateTimePlace {
|
.dateTimePlace {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Template {
|
|||||||
<button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button>
|
<button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button>
|
||||||
<button class=matbut id="textbook" style="background: #FFC107;"> Textbook </button>
|
<button class=matbut id="textbook" style="background: #FFC107;"> Textbook </button>
|
||||||
<button class=matbut id="Syllabi"> Past Syllabi </button>
|
<button class=matbut id="Syllabi"> Past Syllabi </button>
|
||||||
<button class=matbut id="saveCourse" style="background: #F44336;"> Save Course +</button>
|
<button class=matbut id="saveCourse" value="add" style="background: #F44336;"> Save Course +</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -57,6 +57,39 @@ class Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static UTPlanner = class UTPlanner{
|
||||||
|
static modal(){
|
||||||
|
return `<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" style="margin-bottom:0px;">with Bruce Porter</h2>
|
||||||
|
<div id="topbuttons" class=topbuttons>
|
||||||
|
<button class=matbut id="moreInfo" style="background: #2196F3;"> More Info </button>
|
||||||
|
<button class=matbut id="textbook" style="background: #FFC107;"> Textbook </button>
|
||||||
|
<button class=matbut id="Syllabi"> Past Syllabi </button>
|
||||||
|
<button class=matbut id="saveCourse" value="add" style="background: #F44336;"> Save Course +</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=card style='text-align:center'>
|
||||||
|
<select id="semesters" style='text-align-last:center;color:#666666;fill:#666666;'>
|
||||||
|
</select>
|
||||||
|
<div class="chartloader">
|
||||||
|
<div class="loader" id='chartload'></div>
|
||||||
|
</div>
|
||||||
|
<div id="chartcontainer" class=cardcontainer>
|
||||||
|
<div id=chart></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Calendar = class Calendar {
|
static Calendar = class Calendar {
|
||||||
static line(line) {
|
static line(line) {
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
var grades;
|
var grades;
|
||||||
var current_semesters = {};
|
var current_semesters = {};
|
||||||
|
|
||||||
updateBadge(true);
|
onStartup();
|
||||||
loadDataBase()
|
|
||||||
getCurrentSemesters();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Handle messages and their commands from content and popup scripts*/
|
/* Handle messages and their commands from content and popup scripts*/
|
||||||
chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
||||||
@@ -40,6 +36,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
|||||||
executeQuery(request.query, response);
|
executeQuery(request.query, response);
|
||||||
case "currentSemesters":
|
case "currentSemesters":
|
||||||
response({ semesters: current_semesters});
|
response({ semesters: current_semesters});
|
||||||
|
getCurrentSemesters();
|
||||||
default:
|
default:
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
const method = request.method ? request.method.toUpperCase() : "GET";
|
const method = request.method ? request.method.toUpperCase() : "GET";
|
||||||
@@ -106,13 +103,10 @@ chrome.storage.onChanged.addListener(function (changes) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function onStartup(){
|
||||||
function executeQuery(query, sendResponse) {
|
updateBadge(true);
|
||||||
console.log(grades)
|
loadDataBase()
|
||||||
var res = grades.exec(query)[0];
|
getCurrentSemesters();
|
||||||
sendResponse({
|
|
||||||
data: res,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -259,7 +253,8 @@ function add(request, sender, sendResponse) {
|
|||||||
}
|
}
|
||||||
sendResponse({
|
sendResponse({
|
||||||
done: "Added: (" + request.course.unique + ") " + request.course.coursename,
|
done: "Added: (" + request.course.unique + ") " + request.course.coursename,
|
||||||
label: "Remove Course -"
|
label: "Remove Course -",
|
||||||
|
value: "remove"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -278,7 +273,8 @@ function remove(request, sender, sendResponse) {
|
|||||||
});
|
});
|
||||||
sendResponse({
|
sendResponse({
|
||||||
done: "Removed: (" + request.course.unique + ") " + request.course.coursename,
|
done: "Removed: (" + request.course.unique + ") " + request.course.coursename,
|
||||||
label: "Add Course +"
|
label: "Add Course +",
|
||||||
|
value: "add"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -365,6 +361,15 @@ function updateStatus(sendResponse) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function executeQuery(query, sendResponse) {
|
||||||
|
console.log(grades)
|
||||||
|
var res = grades.exec(query)[0];
|
||||||
|
sendResponse({
|
||||||
|
data: res,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* Load the database*/
|
/* Load the database*/
|
||||||
function loadDataBase() {
|
function loadDataBase() {
|
||||||
sql = window.SQL;
|
sql = window.SQL;
|
||||||
@@ -385,4 +390,5 @@ function loadBinaryFile(path, success) {
|
|||||||
success(arr.join(""));
|
success(arr.join(""));
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -168,9 +168,10 @@ function saveCourse() {
|
|||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "courseStorage",
|
command: "courseStorage",
|
||||||
course: c,
|
course: c,
|
||||||
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
|
action: $("#saveCourse").val()
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
$("#saveCourse").text(response.label);
|
$("#saveCourse").text(response.label);
|
||||||
|
$("#saveCourse").val(response.value);
|
||||||
$("#snackbar").text(response.done);
|
$("#snackbar").text(response.done);
|
||||||
toggleSnackbar();
|
toggleSnackbar();
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
@@ -320,12 +321,17 @@ function buildSemestersDropdown(course_data, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Open the modal and show all the data*/
|
function displayBasicCourseInfo(course_info){
|
||||||
function openDialog(course_info, res) {
|
|
||||||
$("#title").text(buildTitle(course_info))
|
$("#title").text(buildTitle(course_info))
|
||||||
$("#topbuttons").before(buildTimeTitle(course_info));
|
$("#topbuttons").before(buildTimeTitle(course_info));
|
||||||
$("#profname").text(buildProfTitle(course_info));
|
$("#profname").text(buildProfTitle(course_info));
|
||||||
$("#myModal").fadeIn(Timing.fade_time);
|
$("#myModal").fadeIn(Timing.fade_time);
|
||||||
|
console.log(course_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Open the modal and show all the data*/
|
||||||
|
function openDialog(course_info, res) {
|
||||||
|
displayBasicCourseInfo(course_info);
|
||||||
//initial text on the "save course button"
|
//initial text on the "save course button"
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: "alreadyContains",
|
command: "alreadyContains",
|
||||||
@@ -345,6 +351,9 @@ function openDialog(course_info, res) {
|
|||||||
setChart(data);
|
setChart(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setChart(data) {
|
function setChart(data) {
|
||||||
// set up the chart
|
// set up the chart
|
||||||
toggleChartLoading(false);
|
toggleChartLoading(false);
|
||||||
@@ -497,16 +506,6 @@ $("#retry").click(function () {
|
|||||||
loadNextPages();
|
loadNextPages();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*Listen for update mssage coming from popup*/
|
|
||||||
chrome.runtime.onMessage.addListener(
|
|
||||||
function (request, sender, sendResponse) {
|
|
||||||
if (request.command == "updateCourseList") {
|
|
||||||
updateListConflictHighlighting(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
function toggleLoadingPage(loading) {
|
function toggleLoadingPage(loading) {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
done_loading = false;
|
done_loading = false;
|
||||||
@@ -546,15 +545,6 @@ function toggleSnackbar() {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).keydown(function (e) {
|
|
||||||
/*Close Modal when hit escape*/
|
|
||||||
if (e.keyCode == 27) {
|
|
||||||
close();
|
|
||||||
} else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
|
|
||||||
saveCourse();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function allowClosing() {
|
function allowClosing() {
|
||||||
$('.close').click(function () {
|
$('.close').click(function () {
|
||||||
@@ -570,4 +560,24 @@ function allowClosing() {
|
|||||||
function close() {
|
function close() {
|
||||||
$("#myModal").fadeOut(Timing.fade_time);
|
$("#myModal").fadeOut(Timing.fade_time);
|
||||||
$("#snackbar").attr("class", "");
|
$("#snackbar").attr("class", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$(document).keydown(function (e) {
|
||||||
|
/*Close Modal when hit escape*/
|
||||||
|
if (e.keyCode == 27) {
|
||||||
|
close();
|
||||||
|
} else if (e.keyCode == 13 && $('#myModal').is(':visible')) {
|
||||||
|
saveCourse();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*Listen for update mssage coming from popup or calendar or other course catalog pages*/
|
||||||
|
chrome.runtime.onMessage.addListener(
|
||||||
|
function (request, sender, sendResponse) {
|
||||||
|
if (request.command == "updateCourseList") {
|
||||||
|
updateListConflictHighlighting(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ function getStatusColor(status, sub = false) {
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function buildQuery(course_data, sem) {
|
function buildQuery(course_data, sem) {
|
||||||
let query = !sem ? "select * from agg" : "select * from grades";
|
let query = !sem ? "select * from agg" : "select * from grades";
|
||||||
query += " where dept like '%" + course_data["department"] + "%'";
|
query += " where dept like '%" + course_data["department"] + "%'";
|
||||||
@@ -54,15 +52,16 @@ function capitalizeString(string) {
|
|||||||
return output.trim();
|
return output.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
function seperateDays(date) {
|
function seperateDays(date, simple=false) {
|
||||||
let arr = [];
|
let arr = [];
|
||||||
for (var i = 0; i < date.length; i++) {
|
for (var i = 0; i < date.length; i++) {
|
||||||
let letter = date.charAt(i);
|
let letter = date.charAt(i);
|
||||||
|
let seperated_letter = letter;
|
||||||
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(simple ? "TH" : days.get("TH"));
|
||||||
} else {
|
} else {
|
||||||
if (letter != "H") {
|
if (letter != "H") {
|
||||||
arr.push(days.get(letter));
|
arr.push(simple ? letter : days.get(letter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
123
js/utplanner.js
123
js/utplanner.js
@@ -1,3 +1,15 @@
|
|||||||
|
let semester_code = "";
|
||||||
|
curr_course = {}
|
||||||
|
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "currentSemesters"
|
||||||
|
}, function(response){
|
||||||
|
let semester_text = $('.row:contains(Semester)').find('span').text();
|
||||||
|
let key = semester_text.split(' ').reverse().join(' ');
|
||||||
|
semester_code = response.semesters[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if ($('html').hasClass('gr__utexas_collegescheduler_com')) {
|
if ($('html').hasClass('gr__utexas_collegescheduler_com')) {
|
||||||
$.initialize("table.section-detail-grid", function () {
|
$.initialize("table.section-detail-grid", function () {
|
||||||
$(this).find('thead>tr').append('<th> Plus</th')
|
$(this).find('thead>tr').append('<th> Plus</th')
|
||||||
@@ -6,15 +18,11 @@ if ($('html').hasClass('gr__utexas_collegescheduler_com')) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
curr_course = {}
|
|
||||||
$("body").prepend(Template.Main.modal());
|
|
||||||
|
|
||||||
|
$("body").prepend(Template.UTPlanner.modal());
|
||||||
$("body").on('click', '#distButton', function () {
|
$("body").on('click', '#distButton', function () {
|
||||||
var row = $(this).closest('tr');
|
var row = $(this).closest('tr');
|
||||||
console.log(row.text())
|
$('.modal-content').stop().animate({ scrollTop: 0 }, 500);
|
||||||
$('.modal-content').stop().animate({
|
|
||||||
scrollTop: 0
|
|
||||||
}, 500);
|
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
getCourseInfo(row)
|
getCourseInfo(row)
|
||||||
});
|
});
|
||||||
@@ -37,9 +45,10 @@ function getCourseInfo(row) {
|
|||||||
"prof_name": profname,
|
"prof_name": profname,
|
||||||
"initial": profinit,
|
"initial": profinit,
|
||||||
"notes": notes,
|
"notes": notes,
|
||||||
|
"individual": `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester_code}/${uniquenum}/`,
|
||||||
"times": times,
|
"times": times,
|
||||||
}
|
}
|
||||||
curr_course = course_data;
|
curr_course = buildCourseLinks(course_data);
|
||||||
getDistribution(course_data);
|
getDistribution(course_data);
|
||||||
var modal = document.getElementById('myModal');
|
var modal = document.getElementById('myModal');
|
||||||
window.onclick = function (event) {
|
window.onclick = function (event) {
|
||||||
@@ -49,6 +58,22 @@ function getCourseInfo(row) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildCourseLinks(course_info) {
|
||||||
|
console.log(semester_code);
|
||||||
|
let {
|
||||||
|
department,
|
||||||
|
number,
|
||||||
|
unique,
|
||||||
|
prof_name
|
||||||
|
} = course_info
|
||||||
|
links = {
|
||||||
|
"textbook": `https://www.universitycoop.com/adoption-search-results?sn=${semester_code}__${department}__${number}__${unique}`,
|
||||||
|
"syllabi": `https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=${department}&course_number=${number}&course_title=&unique=&instructor_first=&instructor_last=${prof_name}&course_type=In+Residence&search=Search`,
|
||||||
|
}
|
||||||
|
course_info["links"] = links;
|
||||||
|
return course_info;
|
||||||
|
}
|
||||||
|
|
||||||
function badData(course_data, res) {
|
function badData(course_data, res) {
|
||||||
return typeof res == 'undefined' || course_data["prof_name"] == "Staff";
|
return typeof res == 'undefined' || course_data["prof_name"] == "Staff";
|
||||||
}
|
}
|
||||||
@@ -59,6 +84,30 @@ $("#semesters").on('change', function () {
|
|||||||
getDistribution(curr_course, sem);
|
getDistribution(curr_course, sem);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#Syllabi").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["syllabi"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
$("#textbook").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["links"]["textbook"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#moreInfo").click(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
window.open(curr_course["individual"]);
|
||||||
|
}, Timing.button_delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#myModal").on('click', '#saveCourse', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
saveCourse();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function toggleChartLoading(loading) {
|
function toggleChartLoading(loading) {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -72,6 +121,7 @@ function toggleChartLoading(loading) {
|
|||||||
|
|
||||||
|
|
||||||
function openDialog(course_data, res) {
|
function openDialog(course_data, res) {
|
||||||
|
console.log(course_data);
|
||||||
$("#title").text(buildTitle(course_data))
|
$("#title").text(buildTitle(course_data))
|
||||||
$("#topbuttons").before(buildTimeTitle(course_data["times"]));
|
$("#topbuttons").before(buildTimeTitle(course_data["times"]));
|
||||||
$("#profname").text(buildProfTitle(course_data));
|
$("#profname").text(buildProfTitle(course_data));
|
||||||
@@ -81,6 +131,7 @@ function openDialog(course_data, res) {
|
|||||||
if (!badData(course_data, res))
|
if (!badData(course_data, res))
|
||||||
data = res.values[0];
|
data = res.values[0];
|
||||||
setChart(data);
|
setChart(data);
|
||||||
|
allowClosing();
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildProfTitle(course_data) {
|
function buildProfTitle(course_data) {
|
||||||
@@ -173,6 +224,64 @@ function setChart(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function standardizeName(department, number, name){
|
||||||
|
return `${department} ${number} ${name}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveCourse() {
|
||||||
|
let {
|
||||||
|
department, name, number, prof_name, times, unique, individual
|
||||||
|
} = curr_course;
|
||||||
|
let dtarr = makeDateTimeArray(times);
|
||||||
|
let full_name = standardizeName(department, number, name);
|
||||||
|
var c = new Course(full_name, unique, prof_name, dtarr, "open", individual, "");
|
||||||
|
console.log(c);
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "courseStorage",
|
||||||
|
course: c,
|
||||||
|
action: $("#saveCourse").val()
|
||||||
|
}, function (response) {
|
||||||
|
$("#saveCourse").text(response.label);
|
||||||
|
$("#saveCourse").val(response.value);
|
||||||
|
$("#snackbar").text(response.done);
|
||||||
|
toggleSnackbar();
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function makeDateTimeArray(times){
|
||||||
|
let dtarr = [];
|
||||||
|
times.forEach(function(session){
|
||||||
|
date = session.substring(0, session.indexOf(' ')).toUpperCase();
|
||||||
|
time = session.substring(session.indexOf(' ') + 1, session.lastIndexOf('-')).trim().split(' - ');
|
||||||
|
place = session.substring(session.lastIndexOf('-') + 1).trim();
|
||||||
|
timearr = [];
|
||||||
|
time.forEach(function(ind_time){
|
||||||
|
timearr.push(moment(ind_time, ["h:mma"]).format("h:mm A"))
|
||||||
|
})
|
||||||
|
seperateDays(date, true).forEach(function(ind_day){
|
||||||
|
dtarr.push([ind_day, timearr, place]);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return dtarr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function allowClosing() {
|
||||||
|
$('.close').click(function () {
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
$('#myModal').click(function (event) {
|
||||||
|
if (event.target.id == 'myModal') {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
$("#myModal").fadeOut(Timing.fade_time);
|
$("#myModal").fadeOut(Timing.fade_time);
|
||||||
|
$("#snackbar").attr("class", "");
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user