Added github contributors to options page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
class Template{}
|
||||
class Template {}
|
||||
|
||||
Template.Main = class {
|
||||
static modal() {
|
||||
@@ -37,12 +37,12 @@ Template.Main = class {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
static extension_button() {
|
||||
return `<td data-th="Plus"><input type="image" class="distButton" id="distButton" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`
|
||||
return `<td data-th="Plus"><input type="image" class="distButton" id="distButton" width="20" height="20" src='${chrome.extension.getURL("images/disticon.png")}'/></td>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Template.Catalog = class {
|
||||
static loading() {
|
||||
return `<div style="text-align:center">
|
||||
@@ -52,11 +52,11 @@ Template.Catalog = class {
|
||||
<h1 id="retrylabel"style="color: #F44336;display:none;">Failed to Load Courses</h1>
|
||||
<br>
|
||||
<button class=material-button id="retry" style="background: #F44336;display:none;">Retry</button>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Template.UTPlanner = class {
|
||||
static modal(){
|
||||
static modal() {
|
||||
return `<div class=modal id=myModal>
|
||||
<div class=modal-content>
|
||||
<span class=close>×</span>
|
||||
@@ -83,25 +83,19 @@ Template.UTPlanner = class {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Template.Calendar = class {
|
||||
static line(line) {
|
||||
let {
|
||||
days,
|
||||
start_time,
|
||||
end_time,
|
||||
location_link,
|
||||
location_full
|
||||
} = line;
|
||||
let { days, start_time, end_time, location_link, location_full } = line;
|
||||
return `<p class='time' style='font-size:large;'>
|
||||
<span style='display:inline-block;'>${days}:</span>
|
||||
<span style='margin-left:10px;display:inline-block;text-align:center;'>${start_time} to ${end_time}</span>
|
||||
<span style='float:right;display:inline-block;text-align:right;width: 25%;'>
|
||||
<a target='_blank' style='color:#3c87a3;text-decoration:none;'href='${location_link}'>${location_full}</a>
|
||||
</span>
|
||||
</p>`
|
||||
</p>`;
|
||||
}
|
||||
static modal() {
|
||||
return `<div id="myModal" class="modal">
|
||||
@@ -121,9 +115,9 @@ Template.Calendar = class {
|
||||
<button id="remove" class="matbut" style="font-size:medium;margin:10px;background: #FF0000;">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Template.Popup = class {
|
||||
static list_item(i, list_tile_color, unique, department, number, profname, list_sub_color, line) {
|
||||
return `<li id='${i}' class='course_list_item'>
|
||||
@@ -150,26 +144,20 @@ Template.Popup = class {
|
||||
}
|
||||
|
||||
static conflict_message(conflict_message) {
|
||||
return `<p id='conflict' class='conflict_message'>${conflict_message}</>`
|
||||
return `<p id='conflict' class='conflict_message'>${conflict_message}</>`;
|
||||
}
|
||||
|
||||
static line(line) {
|
||||
let {
|
||||
days,
|
||||
start_time,
|
||||
end_time,
|
||||
location_link,
|
||||
location_full
|
||||
} = line;
|
||||
let { days, start_time, end_time, location_link, location_full } = line;
|
||||
|
||||
return `<span class='time_line_days'>${days}:</span>
|
||||
<span class='time_line_hours'>${start_time} to ${end_time}</span>
|
||||
<span class='time_line_location'>
|
||||
<a target='_blank' class= 'time_line_location_link' href='${location_link}'>${location_full}</a>
|
||||
</span>
|
||||
<br>`
|
||||
<br>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
Template.Import = class {
|
||||
static import_button() {
|
||||
return `<button class='material-button' id='import' style='margin:15px 0px;'>${Text.button_text_default}</button><br>`;
|
||||
@@ -179,16 +167,15 @@ Template.Import = class {
|
||||
return `<button class='material-button' id='import_waitlist' style='margin:0px'>${Text.waitlist_button_text_default}</button><br>`;
|
||||
}
|
||||
|
||||
static store_waitlist_message(){
|
||||
return `<h1 id="nextlabel"style="color: #FF9800;display:none;"></h1>`
|
||||
static store_waitlist_message() {
|
||||
return `<h1 id="nextlabel"style="color: #FF9800;display:none;"></h1>`;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Template.Options = class {
|
||||
static options_row(key, enabled){
|
||||
let button_text = enabled ? "Turn Off" : "Turn On";
|
||||
let button_color = enabled ? Colors.closed : Colors.open;
|
||||
static options_row(key, enabled) {
|
||||
let button_text = enabled ? "Turn Off" : "Turn On";
|
||||
let button_color = enabled ? Colors.closed : Colors.open;
|
||||
let label_text = capitalizeString(key.replace(/([A-Z]+)*([A-Z][a-z])/g, "$1 $2"));
|
||||
return `<h2 style="padding: 5px 16px 5px 16px; font-weight: normal;display: inline-block;text-align:left;">
|
||||
${label_text}
|
||||
@@ -196,7 +183,14 @@ Template.Options = class {
|
||||
<button id="${key}" value=${enabled} class="material-button" style="display:inline-block;font-size:medium; float:right; background:${button_color}">
|
||||
${button_text}
|
||||
</button>
|
||||
<br>`
|
||||
|
||||
<br>`;
|
||||
}
|
||||
}
|
||||
|
||||
static contributor_card(username, name, image_url, profile_url) {
|
||||
return `<div class='card contributor-card' id="${username}" data-url="${profile_url}">
|
||||
<img class='contributor-image' src="${image_url}"></img>
|
||||
${name ? `<p class='contributor-name'>${name}</p>` : ""}
|
||||
<p class='contributor-username'>${username}</p>
|
||||
</div>`;
|
||||
}
|
||||
};
|
||||
|
||||
248
js/background.js
248
js/background.js
@@ -4,10 +4,10 @@ var departments = [];
|
||||
var should_open = false;
|
||||
|
||||
const default_options = {
|
||||
"loadAll": true,
|
||||
"courseConflictHighlight": true,
|
||||
"storeWaitlist": true,
|
||||
}
|
||||
loadAll: true,
|
||||
courseConflictHighlight: true,
|
||||
storeWaitlist: true,
|
||||
};
|
||||
|
||||
onStartup();
|
||||
|
||||
@@ -44,18 +44,18 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
||||
executeQuery(request.query, response);
|
||||
break;
|
||||
case "currentSemesters":
|
||||
response({ semesters: current_semesters});
|
||||
response({ semesters: current_semesters });
|
||||
getCurrentSemesters();
|
||||
break;
|
||||
case "currentDepartments":
|
||||
response({departments: departments});
|
||||
response({ departments: departments });
|
||||
break;
|
||||
case "setOpen":
|
||||
should_open = true;
|
||||
chrome.tabs.create({ url: request.url});
|
||||
chrome.tabs.create({ url: request.url });
|
||||
break;
|
||||
case "shouldOpen":
|
||||
response({open : should_open});
|
||||
response({ open: should_open });
|
||||
should_open = false;
|
||||
break;
|
||||
case "getOptionsValue":
|
||||
@@ -72,7 +72,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
||||
xhr.onload = () => {
|
||||
console.log(xhr.responseUrl);
|
||||
response(xhr.responseText);
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => response(xhr.statusText);
|
||||
if (method == "POST") {
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
@@ -87,13 +87,16 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
||||
chrome.runtime.onInstalled.addListener(function (details) {
|
||||
if (details.reason == "install") {
|
||||
setDefaultOptions();
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
if (!data.savedCourses) {
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: new Array()
|
||||
}, function () {
|
||||
console.log('initial course list');
|
||||
});
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
savedCourses: new Array(),
|
||||
},
|
||||
function () {
|
||||
console.log("initial course list");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (details.reason == "update") {
|
||||
@@ -102,163 +105,169 @@ chrome.runtime.onInstalled.addListener(function (details) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
chrome.storage.onChanged.addListener(function (changes) {
|
||||
for (key in changes) {
|
||||
console.log(changes);
|
||||
if (key === 'savedCourses') {
|
||||
if (key === "savedCourses") {
|
||||
updateBadge(false, changes.savedCourses.newValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function onStartup(){
|
||||
function onStartup() {
|
||||
updateBadge(true);
|
||||
loadDataBase()
|
||||
loadDataBase();
|
||||
getCurrentSemesters();
|
||||
getCurrentDepartments();
|
||||
}
|
||||
|
||||
function getOptionsValue(key, sendResponse){
|
||||
chrome.storage.sync.get('options', function (data) {
|
||||
function getOptionsValue(key, sendResponse) {
|
||||
chrome.storage.sync.get("options", function (data) {
|
||||
if (!data.options) {
|
||||
setDefaultOptions();
|
||||
} else {
|
||||
sendResponse({
|
||||
'value': data.options[key]
|
||||
value: data.options[key],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setOptionsValue(key, value, sendResponse){
|
||||
chrome.storage.sync.get('options', function (data) {
|
||||
function setOptionsValue(key, value, sendResponse) {
|
||||
chrome.storage.sync.get("options", function (data) {
|
||||
let new_options = data.options;
|
||||
if (!data.options) {
|
||||
setDefaultOptions();
|
||||
new_options = default_options;
|
||||
}
|
||||
new_options[key] = value;
|
||||
chrome.storage.sync.set({
|
||||
options: new_options
|
||||
}, function () {
|
||||
console.log(key);
|
||||
console.log(new_options);
|
||||
sendResponse({
|
||||
'value': new_options[key]
|
||||
});
|
||||
});
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
options: new_options,
|
||||
},
|
||||
function () {
|
||||
console.log(key);
|
||||
console.log(new_options);
|
||||
sendResponse({
|
||||
value: new_options[key],
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function setDefaultOptions(){
|
||||
chrome.storage.sync.get('options', function (data) {
|
||||
function setDefaultOptions() {
|
||||
chrome.storage.sync.get("options", function (data) {
|
||||
if (!data.options) {
|
||||
chrome.storage.sync.set({
|
||||
options: default_options
|
||||
}, function () {
|
||||
console.log('default options:');
|
||||
console.log(default_options);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCurrentSemesters(){
|
||||
$.get('https://registrar.utexas.edu/schedules', function (response) {
|
||||
if (response) {
|
||||
htmlToNode(response).find('.callout2>ul>li>a').each(function (i) {
|
||||
if (i < Popup.num_semesters) {
|
||||
let sem_name = $(this).text().trim();
|
||||
if (sem_name != "Course Schedule Archive") {
|
||||
// $("#semesters").append(`<option>${sem_name}</option>`);
|
||||
current_semesters[sem_name] = "code";
|
||||
$.get($(this).attr('href'), function (response) {
|
||||
if (response) {
|
||||
let response_node = htmlToNode(response);
|
||||
let name = response_node.find(".page-title").text().substring(17).trim();
|
||||
response_node.find('.gobutton>a').each(function () {
|
||||
let link = $(this).attr('href');
|
||||
var sem_num = link.substring(link.lastIndexOf('/') + 1).trim();
|
||||
if(current_semesters[name] != sem_num){
|
||||
current_semesters[name] = sem_num;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
options: default_options,
|
||||
},
|
||||
function () {
|
||||
console.log("default options:");
|
||||
console.log(default_options);
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getCurrentDepartments(){
|
||||
$.get('https://catalog.utexas.edu/undergraduate/appendix-b/', function(response){
|
||||
if(response){;
|
||||
departments = [];
|
||||
htmlToNode(response).find('.column1').each(function(i){
|
||||
if(i > 1){
|
||||
let abv = $(this).text();
|
||||
departments.push(abv);
|
||||
function getCurrentSemesters() {
|
||||
$.get("https://registrar.utexas.edu/schedules", function (response) {
|
||||
if (response) {
|
||||
htmlToNode(response)
|
||||
.find(".callout2>ul>li>a")
|
||||
.each(function (i) {
|
||||
if (i < Popup.num_semesters) {
|
||||
let sem_name = $(this).text().trim();
|
||||
if (sem_name != "Course Schedule Archive") {
|
||||
// $("#semesters").append(`<option>${sem_name}</option>`);
|
||||
current_semesters[sem_name] = "code";
|
||||
$.get($(this).attr("href"), function (response) {
|
||||
if (response) {
|
||||
let response_node = htmlToNode(response);
|
||||
let name = response_node.find(".page-title").text().substring(17).trim();
|
||||
response_node.find(".gobutton>a").each(function () {
|
||||
let link = $(this).attr("href");
|
||||
var sem_num = link.substring(link.lastIndexOf("/") + 1).trim();
|
||||
if (current_semesters[name] != sem_num) {
|
||||
current_semesters[name] = sem_num;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getCurrentDepartments() {
|
||||
$.get("https://catalog.utexas.edu/undergraduate/appendix-b/", function (response) {
|
||||
if (response) {
|
||||
departments = [];
|
||||
htmlToNode(response)
|
||||
.find(".column1")
|
||||
.each(function (i) {
|
||||
if (i > 1) {
|
||||
let abv = $(this).text();
|
||||
departments.push(abv);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateBadge(first, new_changes) {
|
||||
if (new_changes) {
|
||||
updateBadgeText(first, new_changes);
|
||||
} else {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
let courses = data.savedCourses;
|
||||
updateBadgeText(first, courses);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateBadgeText(first, courses) {
|
||||
let badge_text = courses.length > 0 ? `${courses.length}` : "";
|
||||
let flash_time = !first ? 200 : 0;
|
||||
chrome.browserAction.setBadgeText({
|
||||
text: badge_text
|
||||
text: badge_text,
|
||||
});
|
||||
if (!first) {
|
||||
chrome.browserAction.setBadgeBackgroundColor({
|
||||
color: Colors.badge_flash
|
||||
color: Colors.badge_flash,
|
||||
});
|
||||
}
|
||||
setTimeout(function () {
|
||||
chrome.browserAction.setBadgeBackgroundColor({
|
||||
color: Colors.badge_default
|
||||
color: Colors.badge_default,
|
||||
});
|
||||
}, flash_time);
|
||||
}
|
||||
|
||||
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
|
||||
function checkConflicts(sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var conflicts = [];
|
||||
var courses = data.savedCourses;
|
||||
for (let i = 0; i < courses.length; i++) {
|
||||
for (let j = i + 1; j < courses.length; j++) {
|
||||
let course_a = courses[i];
|
||||
let course_b = courses[j];
|
||||
if (isConflict(course_a.datetimearr, course_b.datetimearr))
|
||||
conflicts.push([course_a, course_b]);
|
||||
if (isConflict(course_a.datetimearr, course_b.datetimearr)) conflicts.push([course_a, course_b]);
|
||||
}
|
||||
}
|
||||
if (conflicts.length == 0) {
|
||||
sendResponse({
|
||||
isConflict: false
|
||||
isConflict: false,
|
||||
});
|
||||
} else {
|
||||
sendResponse({
|
||||
isConflict: true,
|
||||
between: conflicts
|
||||
between: conflicts,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -266,7 +275,7 @@ function checkConflicts(sendResponse) {
|
||||
|
||||
/* Find if the course at unique and with currdatearr is contained in the saved courses and if it conflicts with any other courses*/
|
||||
function isSingleConflict(currdatearr, unique, sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var courses = data.savedCourses;
|
||||
var conflict_list = [];
|
||||
var conflict = false;
|
||||
@@ -284,14 +293,11 @@ function isSingleConflict(currdatearr, unique, sendResponse) {
|
||||
sendResponse({
|
||||
isConflict: conflict,
|
||||
alreadyContains: contains,
|
||||
conflictList: conflict_list
|
||||
conflictList: conflict_list,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Check if conflict between two date-time-arrs*/
|
||||
function isConflict(adtarr, bdtarr) {
|
||||
for (var i = 0; i < adtarr.length; i++) {
|
||||
@@ -312,25 +318,25 @@ function isConflict(adtarr, bdtarr) {
|
||||
|
||||
/* Add the requested course to the storage*/
|
||||
function add(request, sender, sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var courses = data.savedCourses;
|
||||
if (!contains(courses, request.course.unique)) {
|
||||
courses.push(request.course)
|
||||
courses.push(request.course);
|
||||
console.log(courses);
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: courses
|
||||
savedCourses: courses,
|
||||
});
|
||||
}
|
||||
sendResponse({
|
||||
done: "Added: (" + request.course.unique + ") " + request.course.coursename,
|
||||
label: "Remove Course -",
|
||||
value: "remove"
|
||||
value: "remove",
|
||||
});
|
||||
});
|
||||
}
|
||||
/* Find and Remove the requested course from the storage*/
|
||||
function remove(request, sender, sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var courses = data.savedCourses;
|
||||
console.log(courses);
|
||||
var index = 0;
|
||||
@@ -339,22 +345,22 @@ function remove(request, sender, sendResponse) {
|
||||
}
|
||||
courses.splice(index, 1);
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: courses
|
||||
savedCourses: courses,
|
||||
});
|
||||
sendResponse({
|
||||
done: "Removed: (" + request.course.unique + ") " + request.course.coursename,
|
||||
label: "Add Course +",
|
||||
value: "add"
|
||||
value: "add",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* Find if the unique is already contained within the storage*/
|
||||
function alreadyContains(unique, sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var courses = data.savedCourses;
|
||||
sendResponse({
|
||||
alreadyContains: contains(courses, unique)
|
||||
alreadyContains: contains(courses, unique),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -371,14 +377,14 @@ function contains(courses, unique) {
|
||||
}
|
||||
|
||||
function isSameCourse(course, unique) {
|
||||
return course.unique == unique
|
||||
return course.unique == unique;
|
||||
}
|
||||
|
||||
function updateTabs() {
|
||||
chrome.tabs.query({}, function (tabs) {
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
chrome.tabs.sendMessage(tabs[i].id, {
|
||||
command: "updateCourseList"
|
||||
command: "updateCourseList",
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -388,9 +394,8 @@ const UPDATE_INTERVAL = 1000 * 60 * 16;
|
||||
setInterval(updateStatus, UPDATE_INTERVAL);
|
||||
// updateStatus();
|
||||
|
||||
|
||||
function updateStatus(sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
var courses = data.savedCourses;
|
||||
var no_change = true;
|
||||
for (let i = 0; i < courses.length; i++) {
|
||||
@@ -403,37 +408,34 @@ function updateStatus(sendResponse) {
|
||||
success: function (result) {
|
||||
if (result) {
|
||||
console.log(result);
|
||||
var object = $('<div/>').html(result).contents();
|
||||
var object = $("<div/>").html(result).contents();
|
||||
let new_status = object.find('[data-th="Status"]').text();
|
||||
let register_link = object.find('td[data-th="Add"] a');
|
||||
if (register_link)
|
||||
register_link = register_link.attr('href');
|
||||
var haschanged = (new_status == old_status && register_link == old_link);
|
||||
if (!haschanged)
|
||||
console.log(c.unique + ' updated from ' + old_status + " to " + new_status + " and " + old_link + " to " + register_link);
|
||||
if (register_link) register_link = register_link.attr("href");
|
||||
var haschanged = new_status == old_status && register_link == old_link;
|
||||
if (!haschanged) console.log(c.unique + " updated from " + old_status + " to " + new_status + " and " + old_link + " to " + register_link);
|
||||
no_change &= haschanged;
|
||||
c.registerlink = register_link;
|
||||
c.status = new_status;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('Not logged into UT Coursebook. Could not update class statuses.');
|
||||
console.log("Not logged into UT Coursebook. Could not update class statuses.");
|
||||
}
|
||||
}
|
||||
if (!no_change) {
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: courses
|
||||
savedCourses: courses,
|
||||
});
|
||||
console.log('updated status');
|
||||
console.log("updated status");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function executeQuery(query, sendResponse) {
|
||||
console.log(grades)
|
||||
console.log(grades);
|
||||
var res = grades.exec(query)[0];
|
||||
sendResponse({
|
||||
data: res,
|
||||
@@ -443,7 +445,7 @@ function executeQuery(query, sendResponse) {
|
||||
/* Load the database*/
|
||||
function loadDataBase() {
|
||||
sql = window.SQL;
|
||||
loadBinaryFile('grades.db', function (data) {
|
||||
loadBinaryFile("grades.db", function (data) {
|
||||
var sqldb = new SQL.Database(data);
|
||||
grades = sqldb;
|
||||
});
|
||||
@@ -460,4 +462,4 @@ function loadBinaryFile(path, success) {
|
||||
success(arr.join(""));
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
}
|
||||
|
||||
80
js/config.js
80
js/config.js
@@ -1,27 +1,36 @@
|
||||
class Timing{}
|
||||
class Timing {}
|
||||
Timing.fade_time = 100;
|
||||
Timing.calendar_fade_time = 100;
|
||||
Timing.button_delay = 75;
|
||||
|
||||
|
||||
class Colors{}
|
||||
Colors.material_colors = ['#4CAF50', '#CDDC39',
|
||||
'#FFC107', '#2196F3', '#F57C00', '#9C27B0', '#FF5722', '#673AB7',
|
||||
'#FF5252', '#E91E63', '#009688', '#00BCD4',
|
||||
'#4E342E', '#424242', '#9E9E9E'
|
||||
class Colors {}
|
||||
Colors.material_colors = [
|
||||
"#4CAF50",
|
||||
"#CDDC39",
|
||||
"#FFC107",
|
||||
"#2196F3",
|
||||
"#F57C00",
|
||||
"#9C27B0",
|
||||
"#FF5722",
|
||||
"#673AB7",
|
||||
"#FF5252",
|
||||
"#E91E63",
|
||||
"#009688",
|
||||
"#00BCD4",
|
||||
"#4E342E",
|
||||
"#424242",
|
||||
"#9E9E9E",
|
||||
];
|
||||
Colors.open = "#4CAF50";
|
||||
Colors.waitlisted = "#FF9800";
|
||||
Colors.closed = "#FF5722";
|
||||
Colors.no_status = "#607D8B";
|
||||
|
||||
|
||||
Colors.open_light = "#C8E6C9";
|
||||
Colors.waitlisted_light = "#FFE0B2";
|
||||
Colors.closed_light = "#FFCCBC";
|
||||
Colors.no_status_light = "#CFD8DC";
|
||||
|
||||
|
||||
Colors.highlight_conflict = "#F44336";
|
||||
Colors.highlight_default = "#333333";
|
||||
Colors.highlight_saved = "#4CAF50";
|
||||
@@ -29,31 +38,50 @@ Colors.highlight_saved = "#4CAF50";
|
||||
Colors.badge_flash = "#FF5722";
|
||||
Colors.badge_default = "#bf5700";
|
||||
|
||||
|
||||
class Export{}
|
||||
class Export {}
|
||||
Export.png_options = {
|
||||
foreignObjectRendering: true,
|
||||
logging: true,
|
||||
removeContainer: true,
|
||||
async: true,
|
||||
}
|
||||
foreignObjectRendering: true,
|
||||
logging: true,
|
||||
removeContainer: true,
|
||||
async: true,
|
||||
};
|
||||
|
||||
class Popup {}
|
||||
Popup.num_semesters = 2;
|
||||
|
||||
class Text{}
|
||||
Text.emptyText = function(){
|
||||
let arr = ["Doesn't Look Like Anything To Me.", "You Can't Fail Classes You're Not In.", "Pro-Tip: Don't Take O-Chem.",
|
||||
"No Work Happens On PCL 5th Floor.", "Sophomore But Freshman By Credit.", "Pain is temporary, GPA is forever.",
|
||||
"You've Yee'd Your Last Haw.", "lol everything is already waitlisted.", "At Least You're Not At A&M.",
|
||||
`It's ${moment().format("h:mm")} and OU Still Sucks.`, 'TeXAs iS BaCK GuYZ', "'Academically Challenged'",
|
||||
'Does McCombs teach Parseltongue?', 'Lets make Daddy Fenves proud.', 'Feel bad if you say Wampus.', 'No Cruce Enfrente Del Bus.',
|
||||
'Midterm 1 has been Unmuted', 'Omae Wa Mou Shindeiru...', 'Bevo Bucks are the new Bitcoin', 'Subway Robber > Machete Guy'
|
||||
]
|
||||
class Text {}
|
||||
Text.emptyText = function () {
|
||||
let arr = [
|
||||
"Doesn't Look Like Anything To Me.",
|
||||
"You Can't Fail Classes You're Not In.",
|
||||
"Pro-Tip: Don't Take O-Chem.",
|
||||
"Jendy's Fofofo™",
|
||||
"Fine Dining at Jester City Limits",
|
||||
"Rec Sports is full and it's only 2pm.",
|
||||
"Hope Domino is doing well rn 🥺",
|
||||
"The year is 2055 and Welch still isn't finished.",
|
||||
"Wear a Mask.",
|
||||
"Motivation dropping faster than ur GPA",
|
||||
"No Work Happens On PCL 5th Floor.",
|
||||
"Sophomore But Freshman By Credit.",
|
||||
"Pain is temporary, GPA is forever.",
|
||||
"You've Yee'd Your Last Haw.",
|
||||
"lol everything is already waitlisted.",
|
||||
"At Least You're Not At A&M.",
|
||||
`It's ${moment().format("h:mm")} and OU Still Sucks.`,
|
||||
"TeXAs iS BaCK GuYZ",
|
||||
"'Academically Challenged'",
|
||||
"Does McCombs teach Parseltongue?",
|
||||
"Feel bad if you say Wampus.",
|
||||
"No Cruce Enfrente Del Bus.",
|
||||
"Midterm 1 has been Unmuted",
|
||||
"Omae Wa Mou Shindeiru...",
|
||||
"Bevo Bucks are the new Bitcoin",
|
||||
];
|
||||
let index = Math.floor(Math.random() * arr.length);
|
||||
|
||||
return arr[index];
|
||||
}
|
||||
};
|
||||
Text.button_text_default = "<span style='font-size:small'>Import to </span><b>UT Reg +<b>";
|
||||
Text.waitlist_button_text_default = "<span style='font-size:small'>Import Waitlists to </span><b>UT Reg +<b>";
|
||||
Text.button_success = "Courses Saved!";
|
||||
|
||||
@@ -1,37 +1,55 @@
|
||||
var manifestData = chrome.runtime.getManifest();
|
||||
$("#version").text(manifestData.version);
|
||||
|
||||
chrome.storage.sync.get('options', function(data){
|
||||
if(data.options){
|
||||
console.log(data.options);
|
||||
Object.keys(data.options).forEach(key => {
|
||||
let enabled = data.options[key];
|
||||
$('#options_container').append(Template.Options.options_row(key, enabled));
|
||||
});
|
||||
}
|
||||
chrome.storage.sync.get("options", function (data) {
|
||||
if (data.options) {
|
||||
console.log(data.options);
|
||||
Object.keys(data.options).forEach(key => {
|
||||
let enabled = data.options[key];
|
||||
$("#options_container").append(Template.Options.options_row(key, enabled));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("body").on("click","button",function(){
|
||||
let key = $(this).attr('id');
|
||||
let old_status = $(this).val() === 'true';
|
||||
let new_status = !old_status;
|
||||
chrome.runtime.sendMessage({
|
||||
command: "setOptionsValue",
|
||||
key: key,
|
||||
value: new_status
|
||||
}, function (response) {
|
||||
console.log(response.value);
|
||||
toggle(key, response.value)
|
||||
updateAllTabsCourseList();
|
||||
});
|
||||
$("body").on("click", "button", function () {
|
||||
let key = $(this).attr("id");
|
||||
let old_status = $(this).val() === "true";
|
||||
let new_status = !old_status;
|
||||
chrome.runtime.sendMessage(
|
||||
{
|
||||
command: "setOptionsValue",
|
||||
key: key,
|
||||
value: new_status,
|
||||
},
|
||||
function (response) {
|
||||
console.log(response.value);
|
||||
toggle(key, response.value);
|
||||
updateAllTabsCourseList();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$.get("https://api.github.com/repos/sghsri/UT-Registration-Plus/stats/contributors", data => {
|
||||
data = data.sort((a, b) => b.total - a.total);
|
||||
console.log("data", data);
|
||||
for (var contributorData of data) {
|
||||
$.get(`https://api.github.com/users/${contributorData.author.login}`, userData => {
|
||||
let fullData = { ...contributorData, ...userData };
|
||||
let { login, avatar_url, html_url, name } = fullData;
|
||||
$("#contributor-list").append(Template.Options.contributor_card(login, name, avatar_url, html_url));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("body").on("click", ".contributor-card", function () {
|
||||
console.log("hello world");
|
||||
window.open($(this).data("url"), "_blank");
|
||||
});
|
||||
|
||||
function toggle(key, value) {
|
||||
let button_text = value ? "Turn Off": "Turn On";
|
||||
let button_color = value ? Colors.closed : Colors.open ;
|
||||
$(`#${key}`).text(button_text);
|
||||
$(`#${key}`).css("background", button_color);
|
||||
$(`#${key}`).val(value);
|
||||
let button_text = value ? "Turn Off" : "Turn On";
|
||||
let button_color = value ? Colors.closed : Colors.open;
|
||||
$(`#${key}`).text(button_text);
|
||||
$(`#${key}`).css("background", button_color);
|
||||
$(`#${key}`).val(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user