hour metric on popup, cleaning up utplanner/removing adding from it (because of status)
This commit is contained in:
@@ -70,7 +70,7 @@ class Template {
|
||||
<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>
|
||||
<button class=matbut id="saveCourse" value="add" style="background: #F44336;opacity:.4;"> Unable to Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,7 @@ $("#calendar").after(Template.Calendar.modal());
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
// Iterate through each saved course and add to 'event'
|
||||
saved_courses = data.savedCourses;
|
||||
console.log(saved_courses);
|
||||
let event_source = buildEventSource(saved_courses);
|
||||
|
||||
$("#calendar").fullCalendar({
|
||||
|
||||
@@ -14,10 +14,14 @@ class Colors {
|
||||
static open = "#4CAF50";
|
||||
static waitlisted = "#FF9800";
|
||||
static closed = "#FF5722";
|
||||
static no_status = "#607D8B";
|
||||
|
||||
|
||||
static open_light = "#C8E6C9";
|
||||
static waitlisted_light = "#FFE0B2";
|
||||
static closed_light = "#FFCCBC";
|
||||
static no_status_light = "#CFD8DC";
|
||||
|
||||
|
||||
static highlight_conflict = "#F44336";
|
||||
static highlight_default = "#333333";
|
||||
|
||||
@@ -337,11 +337,11 @@ function openDialog(course_info, res) {
|
||||
command: "alreadyContains",
|
||||
unique: course_info["unique"]
|
||||
}, function (response) {
|
||||
if (response.alreadyContains) {
|
||||
$("#saveCourse").text("Remove Course -");
|
||||
} else {
|
||||
$("#saveCourse").text("Add Course +");
|
||||
}
|
||||
|
||||
let button_text = response.alreadyContains ? "Remove Course -" : "Add Course +";
|
||||
let button_val = response.alreadyContains ? "remove" : "add";
|
||||
$("#saveCourse").text(button_text);
|
||||
$("#saveCourse").val(button_val);
|
||||
});
|
||||
buildSemestersDropdown(course_info, res)
|
||||
var data = []
|
||||
|
||||
31
js/popup.js
31
js/popup.js
@@ -11,6 +11,7 @@ function setCourseList() {
|
||||
updateConflicts();
|
||||
courses = data.savedCourses
|
||||
handleEmpty();
|
||||
let num_hours = 0;
|
||||
// build and append the course list element
|
||||
for (var i = 0; i < courses.length; i++) {
|
||||
let {
|
||||
@@ -28,10 +29,12 @@ function setCourseList() {
|
||||
department,
|
||||
number
|
||||
} = seperateCourseNameParts(coursename)
|
||||
num_hours += parseInt(number.substring(0,1));
|
||||
|
||||
let list_html = Template.Popup.list_item(i, list_tile_color, unique, department, number, profname, list_sub_color, line);
|
||||
$("#courseList").append(list_html);
|
||||
}
|
||||
$("#meta-metric").text(num_hours);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,6 +142,7 @@ $("#search").click(function () {
|
||||
|
||||
$('#import-class').click(function () {
|
||||
$("#import_input").click();
|
||||
console.log('back to improting');
|
||||
});
|
||||
|
||||
function isImportedValid(imported_courses) {
|
||||
@@ -146,6 +150,7 @@ function isImportedValid(imported_courses) {
|
||||
}
|
||||
|
||||
$("#import_input").change(function (e) {
|
||||
console.log('hello');
|
||||
var files = e.target.files;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function () {
|
||||
@@ -158,6 +163,7 @@ $("#import_input").change(function (e) {
|
||||
updateAllTabsCourseList();
|
||||
setCourseList();
|
||||
hideImportExportPopup();
|
||||
$("#import_input").val('');
|
||||
} else {
|
||||
Alert('There was an error.');
|
||||
}
|
||||
@@ -219,13 +225,6 @@ $("#options_button").click(function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$("#courseList").on('mouseover', '.copybut', function () {
|
||||
$(this).addClass('shadow');
|
||||
}).on('mouseleave', '.copybut', function () {
|
||||
@@ -264,11 +263,16 @@ function handleRegister(clicked_item, curr_course) {
|
||||
} = curr_course;
|
||||
let register_button = $(clicked_item).find("#register");
|
||||
let can_not_register = canNotRegister(status, registerlink);
|
||||
|
||||
let register_text = can_not_register ? "Can't Register" :
|
||||
status.includes("waitlisted") ? "Join Waitlist" : "Register";
|
||||
let register_color = can_not_register ? Colors.closed :
|
||||
status.includes("waitlisted") ? Colors.waitlisted : Colors.open;
|
||||
|
||||
if(!status){
|
||||
register_text = "No Status";
|
||||
register_color = Colors.no_status;
|
||||
}
|
||||
|
||||
$(register_button).text(register_text).css('background-color', register_color);
|
||||
|
||||
if (!can_not_register) {
|
||||
@@ -286,6 +290,7 @@ function handleRemove(clicked_item, curr_course) {
|
||||
$(list).find("#conflict").fadeOut(300, function () {
|
||||
$(clicked_item).remove();
|
||||
});
|
||||
subtractHours(curr_course);
|
||||
chrome.runtime.sendMessage({
|
||||
command: "courseStorage",
|
||||
course: curr_course,
|
||||
@@ -302,6 +307,15 @@ function handleRemove(clicked_item, curr_course) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function subtractHours(curr_course){
|
||||
let curr_total_hours = parseInt($("#meta-metric").text());
|
||||
let curr_course_number = seperateCourseNameParts(curr_course.coursename).number;
|
||||
let curr_individual_hours = parseInt(curr_course_number.substring(0,1));
|
||||
$("#meta-metric").text(curr_total_hours-curr_individual_hours);
|
||||
|
||||
}
|
||||
|
||||
function handleMoreInfo(clicked_item, curr_course) {
|
||||
$(clicked_item).find("#listMoreInfo").click(function () {
|
||||
window.open(curr_course.link);
|
||||
@@ -348,6 +362,7 @@ function showEmpty() {
|
||||
$("#courseList").hide();
|
||||
$("#empty").fadeIn(200);
|
||||
$("#main").html(Text.emptyText());
|
||||
$("#meta-metric").text('0');
|
||||
}
|
||||
|
||||
function hideSearchPopup() {
|
||||
|
||||
@@ -14,6 +14,8 @@ function getStatusColor(status, sub = false) {
|
||||
color = sub ? Colors.waitlisted_light : Colors.waitlisted;
|
||||
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||
color = sub ? Colors.closed_light : Colors.closed;
|
||||
} else {
|
||||
color = sub ? Colors.no_status_light : Colors.no_status;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -9,15 +9,12 @@ chrome.runtime.sendMessage({
|
||||
semester_code = response.semesters[key];
|
||||
});
|
||||
|
||||
|
||||
if ($('html').hasClass('gr__utexas_collegescheduler_com')) {
|
||||
$.initialize("table.section-detail-grid", function () {
|
||||
$(this).find('thead>tr').append('<th> Plus</th')
|
||||
$(this).find('tbody>tr').each(function () {
|
||||
$(this).append(Template.Main.extension_button());
|
||||
})
|
||||
});
|
||||
}
|
||||
$.initialize("table.section-detail-grid", function () {
|
||||
$(this).find('thead>tr').append('<th> Plus</th')
|
||||
$(this).find('tbody>tr').each(function () {
|
||||
$(this).append(Template.Main.extension_button());
|
||||
})
|
||||
});
|
||||
|
||||
$("body").prepend(Template.UTPlanner.modal());
|
||||
$("body").on('click', '#distButton', function () {
|
||||
@@ -101,13 +98,6 @@ $("#moreInfo").click(function () {
|
||||
}, Timing.button_delay);
|
||||
});
|
||||
|
||||
$("#myModal").on('click', '#saveCourse', function () {
|
||||
setTimeout(function () {
|
||||
saveCourse();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
function toggleChartLoading(loading) {
|
||||
if (loading) {
|
||||
@@ -229,47 +219,6 @@ function standardizeName(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();
|
||||
|
||||
Reference in New Issue
Block a user