removed cs favoritism 🤪
This commit is contained in:
603
js/popup.js
603
js/popup.js
@@ -7,417 +7,416 @@ getDepartments();
|
|||||||
var can_remove = true;
|
var can_remove = true;
|
||||||
|
|
||||||
function setCourseList() {
|
function setCourseList() {
|
||||||
$("#courseList").empty()
|
$("#courseList").empty();
|
||||||
chrome.storage.sync.get('savedCourses', function (data) {
|
chrome.storage.sync.get("savedCourses", function (data) {
|
||||||
updateConflicts();
|
updateConflicts();
|
||||||
courses = data.savedCourses
|
courses = data.savedCourses;
|
||||||
handleEmpty();
|
handleEmpty();
|
||||||
let num_hours = 0;
|
let num_hours = 0;
|
||||||
// build and append the course list element
|
// build and append the course list element
|
||||||
for (var i = 0; i < courses.length; i++) {
|
for (var i = 0; i < courses.length; i++) {
|
||||||
let {
|
let { coursename, unique, profname, status, datetimearr } = courses[i];
|
||||||
coursename,
|
profname = capitalizeString(profname);
|
||||||
unique,
|
let line = buildTimeLines(datetimearr);
|
||||||
profname,
|
let list_tile_color = getStatusColor(status);
|
||||||
status,
|
let list_sub_color = getStatusColor(status, true);
|
||||||
datetimearr
|
let { department, number } = seperateCourseNameParts(coursename);
|
||||||
} = courses[i];
|
num_hours += parseInt(number.substring(0, 1));
|
||||||
profname = capitalizeString(profname);
|
|
||||||
let line = buildTimeLines(datetimearr);
|
|
||||||
let list_tile_color = getStatusColor(status)
|
|
||||||
let list_sub_color = getStatusColor(status, true);
|
|
||||||
let {
|
|
||||||
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);
|
let list_html = Template.Popup.list_item(i, list_tile_color, unique, department, number, profname, list_sub_color, line);
|
||||||
$("#courseList").append(list_html);
|
$("#courseList").append(list_html);
|
||||||
}
|
}
|
||||||
$("#meta-metric").text(num_hours);
|
$("#meta-metric").text(num_hours);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert from the dtarr and maek the time lines*/
|
/* convert from the dtarr and maek the time lines*/
|
||||||
function buildTimeLines(datetimearr) {
|
function buildTimeLines(datetimearr) {
|
||||||
let lines = convertDateTimeArrToLine(datetimearr);
|
let lines = convertDateTimeArrToLine(datetimearr);
|
||||||
let output = "";
|
let output = "";
|
||||||
if (lines.length == 0) {
|
if (lines.length == 0) {
|
||||||
output = "<span style='font-size:medium;'>This class has no meeting times.</span>"
|
output = "<span style='font-size:medium;'>This class has no meeting times.</span>";
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
let line = lines[i];
|
let line = lines[i];
|
||||||
output += Template.Popup.line(line)
|
output += Template.Popup.line(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the conflict messages */
|
/* Update the conflict messages */
|
||||||
function updateConflicts() {
|
function updateConflicts() {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage(
|
||||||
command: "checkConflicts"
|
{
|
||||||
}, function (response) {
|
command: "checkConflicts",
|
||||||
if (response.isConflict) {
|
},
|
||||||
var between = response.between;
|
function (response) {
|
||||||
let conflict_message = "";
|
if (response.isConflict) {
|
||||||
for (var i = 0; i < between.length; i++) {
|
var between = response.between;
|
||||||
let courseA = between[i][0];
|
let conflict_message = "";
|
||||||
let courseB = between[i][1];
|
for (var i = 0; i < between.length; i++) {
|
||||||
conflict_message += `CONFLICT: ${formatShortenedCourseName(courseA)} and ${formatShortenedCourseName(courseB)}`;
|
let courseA = between[i][0];
|
||||||
if (i != between.length - 1)
|
let courseB = between[i][1];
|
||||||
conflict_message += "<br>";
|
conflict_message += `CONFLICT: ${formatShortenedCourseName(courseA)} and ${formatShortenedCourseName(courseB)}`;
|
||||||
}
|
if (i != between.length - 1) conflict_message += "<br>";
|
||||||
$(Template.Popup.conflict_message(conflict_message)).prependTo("#courseList").hide().fadeIn(200);
|
}
|
||||||
}
|
$(Template.Popup.conflict_message(conflict_message)).prependTo("#courseList").hide().fadeIn(200);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prettify the name for the conflict messages*/
|
/* prettify the name for the conflict messages*/
|
||||||
function formatShortenedCourseName(course) {
|
function formatShortenedCourseName(course) {
|
||||||
let {
|
let { number, department } = seperateCourseNameParts(course.coursename);
|
||||||
number,
|
return `${department} ${number} (${course.unique})`;
|
||||||
department
|
|
||||||
} = seperateCourseNameParts(course.coursename)
|
|
||||||
return `${department} ${number} (${course.unique})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).click(function (event) {
|
$(document).click(function (event) {
|
||||||
$target = $(event.target);
|
$target = $(event.target);
|
||||||
|
|
||||||
// If we're not clicking on search button or search popup, and popup is visible, hide it
|
// If we're not clicking on search button or search popup, and popup is visible, hide it
|
||||||
if (!$target.closest('#search').length && !$target.closest('#search-popup').length && $('#search-popup').is(":visible")) {
|
if (!$target.closest("#search").length && !$target.closest("#search-popup").length && $("#search-popup").is(":visible")) {
|
||||||
hideSearchPopup();
|
hideSearchPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not clicking on import/export button or imp/exp popup, and popup is visible, hide it
|
// If we're not clicking on import/export button or imp/exp popup, and popup is visible, hide it
|
||||||
if (!$target.closest('#impexp').length && !$target.closest('#import-export-popup').length && $('#import-export-popup').is(":visible")) {
|
if (!$target.closest("#impexp").length && !$target.closest("#import-export-popup").length && $("#import-export-popup").is(":visible")) {
|
||||||
hideImportExportPopup();
|
hideImportExportPopup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#clear").click(function () {
|
$("#clear").click(function () {
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
savedCourses: []
|
savedCourses: [],
|
||||||
});
|
});
|
||||||
$("#courseList").empty();
|
$("#courseList").empty();
|
||||||
updateAllTabsCourseList();
|
updateAllTabsCourseList();
|
||||||
showEmpty();
|
showEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#RIS").click(function () {
|
$("#RIS").click(function () {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
'url': 'https://utdirect.utexas.edu/registrar/ris.WBX'
|
url: "https://utdirect.utexas.edu/registrar/ris.WBX",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#calendar").click(function () {
|
$("#calendar").click(function () {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
'url': "calendar.html"
|
url: "calendar.html",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("#impexp").click(function () {
|
$("#impexp").click(function () {
|
||||||
if ($("#impexp>i").text() == 'close') {
|
if ($("#impexp>i").text() == "close") {
|
||||||
hideImportExportPopup();
|
hideImportExportPopup();
|
||||||
} else {
|
} else {
|
||||||
if ($("#search>i").text() == 'close') {
|
if ($("#search>i").text() == "close") {
|
||||||
hideSearchPopup();
|
hideSearchPopup();
|
||||||
}
|
}
|
||||||
showImportExportPopup();
|
showImportExportPopup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#search").click(function () {
|
$("#search").click(function () {
|
||||||
if ($("#search>i").text() == 'close') {
|
if ($("#search>i").text() == "close") {
|
||||||
hideSearchPopup();
|
hideSearchPopup();
|
||||||
} else {
|
} else {
|
||||||
if ($("#impexp>i").text() == 'close') {
|
if ($("#impexp>i").text() == "close") {
|
||||||
hideImportExportPopup();
|
hideImportExportPopup();
|
||||||
}
|
}
|
||||||
showSearchPopup();
|
showSearchPopup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#import-class').click(function () {
|
$("#import-class").click(function () {
|
||||||
$("#import_input").click();
|
$("#import_input").click();
|
||||||
console.log('back to improting');
|
console.log("back to improting");
|
||||||
});
|
});
|
||||||
|
|
||||||
function isImportedValid(imported_courses) {
|
function isImportedValid(imported_courses) {
|
||||||
return imported_courses && imported_courses.length && (imported_courses.length == 0 || validateCourses(imported_courses))
|
return imported_courses && imported_courses.length && (imported_courses.length == 0 || validateCourses(imported_courses));
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#import_input").change(function (e) {
|
$("#import_input").change(function (e) {
|
||||||
console.log('hello');
|
console.log("hello");
|
||||||
var files = e.target.files;
|
var files = e.target.files;
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function () {
|
reader.onload = function () {
|
||||||
try {
|
try {
|
||||||
var imported_courses = JSON.parse(this.result);
|
var imported_courses = JSON.parse(this.result);
|
||||||
if (isImportedValid(imported_courses)) {
|
if (isImportedValid(imported_courses)) {
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
savedCourses: imported_courses
|
savedCourses: imported_courses,
|
||||||
});
|
});
|
||||||
updateAllTabsCourseList();
|
updateAllTabsCourseList();
|
||||||
setCourseList();
|
setCourseList();
|
||||||
hideImportExportPopup();
|
hideImportExportPopup();
|
||||||
$("#import_input").val('');
|
$("#import_input").val("");
|
||||||
} else {
|
} else {
|
||||||
Alert('There was an error.');
|
Alert("There was an error.");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
reader.readAsText(files[0]);
|
reader.readAsText(files[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function exportCourses(url) {
|
function exportCourses(url) {
|
||||||
var exportlink = document.createElement('a');
|
var exportlink = document.createElement("a");
|
||||||
exportlink.setAttribute('href', url);
|
exportlink.setAttribute("href", url);
|
||||||
exportlink.setAttribute('download', 'my_courses.json');
|
exportlink.setAttribute("download", "my_courses.json");
|
||||||
exportlink.click();
|
exportlink.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBlob(export_courses) {
|
function createBlob(export_courses) {
|
||||||
return new Blob([JSON.stringify(export_courses, null, 4)], {
|
return new Blob([JSON.stringify(export_courses, null, 4)], {
|
||||||
type: "octet/stream"
|
type: "octet/stream",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#export-class').click(function () {
|
$("#export-class").click(function () {
|
||||||
chrome.storage.sync.get('savedCourses', function (data) {
|
chrome.storage.sync.get("savedCourses", function (data) {
|
||||||
let export_courses = data.savedCourses;
|
let export_courses = data.savedCourses;
|
||||||
if (export_courses.length > 0) {
|
if (export_courses.length > 0) {
|
||||||
let url = window.URL.createObjectURL(createBlob(export_courses));
|
let url = window.URL.createObjectURL(createBlob(export_courses));
|
||||||
exportCourses(url);
|
exportCourses(url);
|
||||||
} else {
|
} else {
|
||||||
alert('No Saved Courses to Export.');
|
alert("No Saved Courses to Export.");
|
||||||
}
|
}
|
||||||
hideImportExportPopup();
|
hideImportExportPopup();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function openSearch(semester, department, level, courseCode) {
|
function openSearch(semester, department, level, courseCode) {
|
||||||
var link = "";
|
var link = "";
|
||||||
if (courseCode) {
|
if (courseCode) {
|
||||||
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester}/results/?search_type_main=COURSE&fos_cn=${department}&course_number=${courseCode}`
|
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester}/results/?search_type_main=COURSE&fos_cn=${department}&course_number=${courseCode}`;
|
||||||
} else {
|
} else {
|
||||||
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester}/results/?fos_fl=${department}&level=${level}&search_type_main=FIELD`;
|
link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${semester}/results/?fos_fl=${department}&level=${level}&search_type_main=FIELD`;
|
||||||
}
|
}
|
||||||
chrome.tabs.create({ url: link });
|
chrome.tabs.create({ url: link });
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#search-class").click(() => {
|
$("#search-class").click(() => {
|
||||||
let semester = $("#semesters").find(":selected").val();
|
let semester = $("#semesters").find(":selected").val();
|
||||||
let department = $("#department").find(":selected").val();
|
let department = $("#department").find(":selected").val();
|
||||||
let level = $("#level").find(":selected").val();
|
let level = $("#level").find(":selected").val();
|
||||||
let courseCode = $("#courseCode").val();
|
let courseCode = $("#courseCode").val();
|
||||||
openSearch(semester, department, level, courseCode);
|
openSearch(semester, department, level, courseCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#options_button").click(function () {
|
$("#options_button").click(function () {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
'url': "options.html"
|
url: "options.html",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#courseList").on('mouseover', '.copy_button', function () {
|
$("#courseList")
|
||||||
$(this).addClass('shadow');
|
.on("mouseover", ".copy_button", function () {
|
||||||
}).on('mouseleave', '.copy_button', function () {
|
$(this).addClass("shadow");
|
||||||
$(this).removeClass('shadow');
|
})
|
||||||
});
|
.on("mouseleave", ".copy_button", function () {
|
||||||
|
$(this).removeClass("shadow");
|
||||||
|
});
|
||||||
|
|
||||||
$("#courseList").on('click', '.copy_button', function (e) {
|
$("#courseList").on("click", ".copy_button", function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
copyButtonAnimation($(this));
|
copyButtonAnimation($(this));
|
||||||
let unique = $(this).val();
|
let unique = $(this).val();
|
||||||
copyUnique(unique);
|
copyUnique(unique);
|
||||||
});
|
});
|
||||||
|
|
||||||
function copyUnique(unique) {
|
function copyUnique(unique) {
|
||||||
var temp = $("<input>");
|
var temp = $("<input>");
|
||||||
$("body").append(temp);
|
$("body").append(temp);
|
||||||
temp.val(unique).select();
|
temp.val(unique).select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
temp.remove();
|
temp.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#courseList").on('click', 'li', function () {
|
$("#courseList").on("click", "li", function () {
|
||||||
let clicked_item = $(this).closest('li');
|
let clicked_item = $(this).closest("li");
|
||||||
let curr_course = courses[$(clicked_item).attr("id")];
|
let curr_course = courses[$(clicked_item).attr("id")];
|
||||||
handleMoreInfo(clicked_item, curr_course);
|
handleMoreInfo(clicked_item, curr_course);
|
||||||
handleRegister(clicked_item, curr_course)
|
handleRegister(clicked_item, curr_course);
|
||||||
handleRemove(clicked_item, curr_course)
|
handleRemove(clicked_item, curr_course);
|
||||||
toggleTimeDropdown(clicked_item);
|
toggleTimeDropdown(clicked_item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function handleRegister(clicked_item, curr_course) {
|
function handleRegister(clicked_item, curr_course) {
|
||||||
let {
|
let { status, registerlink } = curr_course;
|
||||||
status,
|
let register_button = $(clicked_item).find("#register");
|
||||||
registerlink
|
let can_not_register = canNotRegister(status, registerlink);
|
||||||
} = curr_course;
|
let register_text = can_not_register ? "Can't Register" : status.includes("waitlisted") ? "Join Waitlist" : "Register";
|
||||||
let register_button = $(clicked_item).find("#register");
|
let register_color = can_not_register ? Colors.closed : status.includes("waitlisted") ? Colors.waitlisted : Colors.open;
|
||||||
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) {
|
if (!status) {
|
||||||
register_text = "No Status";
|
register_text = "No Status";
|
||||||
register_color = Colors.no_status;
|
register_color = Colors.no_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(register_button).text(register_text).css('background-color', register_color);
|
$(register_button).text(register_text).css("background-color", register_color);
|
||||||
|
|
||||||
if (!can_not_register) {
|
if (!can_not_register) {
|
||||||
$(register_button).click(function () {
|
$(register_button).click(function () {
|
||||||
setCurrentTabUrl(registerlink);
|
setCurrentTabUrl(registerlink);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRemove(clicked_item, curr_course) {
|
function handleRemove(clicked_item, curr_course) {
|
||||||
let list = $(clicked_item).closest("ul");
|
let list = $(clicked_item).closest("ul");
|
||||||
$(clicked_item).find("#listRemove").click(function () {
|
$(clicked_item)
|
||||||
if (can_remove) {
|
.find("#listRemove")
|
||||||
can_remove = false;
|
.click(function () {
|
||||||
$(list).find("#conflict").fadeOut(300, function () {
|
if (can_remove) {
|
||||||
$(clicked_item).remove();
|
can_remove = false;
|
||||||
});
|
$(list)
|
||||||
subtractHours(curr_course);
|
.find("#conflict")
|
||||||
chrome.runtime.sendMessage({
|
.fadeOut(300, function () {
|
||||||
command: "courseStorage",
|
$(clicked_item).remove();
|
||||||
course: curr_course,
|
});
|
||||||
action: "remove"
|
subtractHours(curr_course);
|
||||||
}, () => {
|
chrome.runtime.sendMessage(
|
||||||
$(clicked_item).fadeOut(200);
|
{
|
||||||
if ($(list).children(':visible').length === 1)
|
command: "courseStorage",
|
||||||
showEmpty();
|
course: curr_course,
|
||||||
can_remove = true;
|
action: "remove",
|
||||||
updateConflicts();
|
},
|
||||||
updateAllTabsCourseList();
|
() => {
|
||||||
});
|
$(clicked_item).fadeOut(200);
|
||||||
}
|
if ($(list).children(":visible").length === 1) showEmpty();
|
||||||
});
|
can_remove = true;
|
||||||
|
updateConflicts();
|
||||||
|
updateAllTabsCourseList();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function subtractHours(curr_course) {
|
function subtractHours(curr_course) {
|
||||||
let curr_total_hours = parseInt($("#meta-metric").text());
|
let curr_total_hours = parseInt($("#meta-metric").text());
|
||||||
let curr_course_number = seperateCourseNameParts(curr_course.coursename).number;
|
let curr_course_number = seperateCourseNameParts(curr_course.coursename).number;
|
||||||
let curr_individual_hours = parseInt(curr_course_number.substring(0, 1));
|
let curr_individual_hours = parseInt(curr_course_number.substring(0, 1));
|
||||||
$("#meta-metric").text(curr_total_hours - curr_individual_hours);
|
$("#meta-metric").text(curr_total_hours - curr_individual_hours);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMoreInfo(clicked_item, curr_course) {
|
function handleMoreInfo(clicked_item, curr_course) {
|
||||||
$(clicked_item).find("#listMoreInfo").click(function () {
|
$(clicked_item)
|
||||||
openMoreInfoWithOpenModal(curr_course.link);
|
.find("#listMoreInfo")
|
||||||
});
|
.click(function () {
|
||||||
|
openMoreInfoWithOpenModal(curr_course.link);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEmpty() {
|
function handleEmpty() {
|
||||||
if (courses.length != 0) {
|
if (courses.length != 0) {
|
||||||
$("#empty").hide();
|
$("#empty").hide();
|
||||||
$("#courseList").show();
|
$("#courseList").show();
|
||||||
} else {
|
} else {
|
||||||
showEmpty();
|
showEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyButtonAnimation(copy_button) {
|
function copyButtonAnimation(copy_button) {
|
||||||
$(copy_button).find('i').text('check');
|
$(copy_button).find("i").text("check");
|
||||||
$(copy_button).stop(true, false).removeAttr('style').removeClass('shadow', {
|
$(copy_button).stop(true, false).removeAttr("style").removeClass("shadow", {
|
||||||
duration: 200
|
duration: 200,
|
||||||
});
|
});
|
||||||
$(copy_button).find('i').delay(400).queue(function (n) {
|
$(copy_button)
|
||||||
$(this).text('content_copy');
|
.find("i")
|
||||||
$(this).parent().removeClass('shadow');
|
.delay(400)
|
||||||
if ($(this).parent().is(":hover")) {
|
.queue(function (n) {
|
||||||
$(this).parent().addClass('shadow');
|
$(this).text("content_copy");
|
||||||
}
|
$(this).parent().removeClass("shadow");
|
||||||
n();
|
if ($(this).parent().is(":hover")) {
|
||||||
})
|
$(this).parent().addClass("shadow");
|
||||||
|
}
|
||||||
|
n();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleTimeDropdown(clicked_item) {
|
function toggleTimeDropdown(clicked_item) {
|
||||||
let more_info_button = $(clicked_item).find('#moreInfo');
|
let more_info_button = $(clicked_item).find("#moreInfo");
|
||||||
let arrow = $(clicked_item).find("#arrow");
|
let arrow = $(clicked_item).find("#arrow");
|
||||||
if ($(more_info_button).is(":hidden")) {
|
if ($(more_info_button).is(":hidden")) {
|
||||||
$(more_info_button).fadeIn(200);
|
$(more_info_button).fadeIn(200);
|
||||||
$(arrow).css('transform', 'rotate(90deg)');
|
$(arrow).css("transform", "rotate(90deg)");
|
||||||
} else {
|
} else {
|
||||||
$(more_info_button).fadeOut(200);
|
$(more_info_button).fadeOut(200);
|
||||||
$(arrow).css('transform', '');
|
$(arrow).css("transform", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEmpty() {
|
function showEmpty() {
|
||||||
$("#courseList").hide();
|
$("#courseList").hide();
|
||||||
$("#empty").fadeIn(200);
|
$("#empty").fadeIn(200);
|
||||||
$("#main").html(Text.emptyText());
|
$("#main").html(Text.emptyText());
|
||||||
$("#meta-metric").text('0');
|
$("#meta-metric").text("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideSearchPopup() {
|
function hideSearchPopup() {
|
||||||
$("#search>i").text('search');
|
$("#search>i").text("search");
|
||||||
$("#semcon").hide();
|
$("#semcon").hide();
|
||||||
$("#depcon").hide();
|
$("#depcon").hide();
|
||||||
$("#semesters").hide();
|
$("#semesters").hide();
|
||||||
$("#levcon").hide();
|
$("#levcon").hide();
|
||||||
$("#search-popup").addClass('hide');
|
$("#search-popup").addClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSearchPopup() {
|
function showSearchPopup() {
|
||||||
$("#search>i").text('close');
|
$("#search>i").text("close");
|
||||||
$("#class_id_input").show();
|
$("#class_id_input").show();
|
||||||
$("#semesters").show();
|
$("#semesters").show();
|
||||||
$("#semcon").show();
|
$("#semcon").show();
|
||||||
$("#depcon").show();
|
$("#depcon").show();
|
||||||
$("#levcon").show();
|
$("#levcon").show();
|
||||||
$("#search-popup").removeClass('hide');
|
$("#search-popup").removeClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideImportExportPopup() {
|
function hideImportExportPopup() {
|
||||||
$("#import-export-popup").addClass('hide');
|
$("#import-export-popup").addClass("hide");
|
||||||
$("#impexp>i").text('import_export');
|
$("#impexp>i").text("import_export");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showImportExportPopup() {
|
function showImportExportPopup() {
|
||||||
$("#impexp>i").text('close');
|
$("#impexp>i").text("close");
|
||||||
$("#import-export-popup").removeClass('hide');
|
$("#import-export-popup").removeClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSemesters() {
|
function getSemesters() {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage(
|
||||||
command: "currentSemesters"
|
{
|
||||||
}, function (response) {
|
command: "currentSemesters",
|
||||||
let { semesters } = response;
|
},
|
||||||
let semester_names = Object.keys(semesters);
|
function (response) {
|
||||||
for (let i = 0; i < semester_names.length; i++) {
|
let { semesters } = response;
|
||||||
let name = semester_names[i];
|
let semester_names = Object.keys(semesters);
|
||||||
$("#semesters").append(`<option value='${semesters[name]}'>${name}</option>`);
|
for (let i = 0; i < semester_names.length; i++) {
|
||||||
}
|
let name = semester_names[i];
|
||||||
});
|
$("#semesters").append(`<option value='${semesters[name]}'>${name}</option>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDepartments() {
|
function getDepartments() {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage(
|
||||||
command: "currentDepartments"
|
{
|
||||||
}, function (response) {
|
command: "currentDepartments",
|
||||||
let { departments } = response;
|
},
|
||||||
console.log(departments);
|
function (response) {
|
||||||
for (let i = 0; i < departments.length; i++) {
|
let { departments } = response;
|
||||||
let abv = departments[i];
|
console.log(departments);
|
||||||
$("#department").append(`<option value='${abv}'>${abv}</option>`);
|
for (let i = 0; i < departments.length; i++) {
|
||||||
}
|
let abv = departments[i];
|
||||||
$("#department").val('C S');
|
$("#department").append(`<option value='${abv}'>${abv}</option>`);
|
||||||
});
|
}
|
||||||
|
// $("#department").val('C S');
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user