settings option for loading
This commit is contained in:
@@ -9,8 +9,15 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id='calendar' style=" width: 75%; margin-left:auto; margin-right:auto;"></div>
|
<div style='display:flex'>
|
||||||
<button id="export" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Export Schedule</button>
|
<div id='calendar' style="flex-grow: 1"></div>
|
||||||
|
<div>
|
||||||
|
<button id="export" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;white-space: nowrap;text-align: center;">Export
|
||||||
|
Schedule</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/* 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) {
|
||||||
|
|
||||||
switch(request.command){
|
switch (request.command) {
|
||||||
case "courseStorage":
|
case "courseStorage":
|
||||||
if (request.action == "add") {
|
if (request.action == "add") {
|
||||||
add(request, sender, response);
|
add(request, sender, response);
|
||||||
}
|
}
|
||||||
if (request.action == "remove") {
|
if (request.action == "remove") {
|
||||||
remove(request, sender, response);
|
remove(request, sender, response);
|
||||||
@@ -43,9 +43,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
|||||||
/* Initially set the course data in storage */
|
/* Initially set the course data in storage */
|
||||||
chrome.runtime.onInstalled.addListener(function (details) {
|
chrome.runtime.onInstalled.addListener(function (details) {
|
||||||
if (details.reason == "install") {
|
if (details.reason == "install") {
|
||||||
chrome.storage.sync.get('savedCourses', function(data){
|
chrome.storage.sync.get('savedCourses', function (data) {
|
||||||
if(!data.savedCourses){
|
if (!data.savedCourses) {
|
||||||
console.log(data.savedCourses);
|
|
||||||
var arr = new Array();
|
var arr = new Array();
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
savedCourses: arr
|
savedCourses: arr
|
||||||
@@ -57,9 +56,14 @@ chrome.runtime.onInstalled.addListener(function (details) {
|
|||||||
}, function () {
|
}, function () {
|
||||||
console.log('initial highlighting: true');
|
console.log('initial highlighting: true');
|
||||||
});
|
});
|
||||||
|
chrome.storage.sync.set({
|
||||||
|
loadAll: true
|
||||||
|
}, function () {
|
||||||
|
console.log('initial loadAll: true');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(details.reason == "update"){
|
} else if (details.reason == "update") {
|
||||||
console.log("updated");
|
console.log("updated");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -221,7 +225,7 @@ function updateStatus() {
|
|||||||
dummy.innerHTML = result;
|
dummy.innerHTML = result;
|
||||||
let newstatus = dummy.querySelector('[data-th="Status"]').textContent;
|
let newstatus = dummy.querySelector('[data-th="Status"]').textContent;
|
||||||
let registerlink = dummy.querySelector('td[data-th="Add"] a');
|
let registerlink = dummy.querySelector('td[data-th="Add"] a');
|
||||||
if(registerlink){
|
if (registerlink) {
|
||||||
registerlink = registerlink.getAttribute('href');
|
registerlink = registerlink.getAttribute('href');
|
||||||
}
|
}
|
||||||
c.registerlink = registerlink;
|
c.registerlink = registerlink;
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const butdelay = 75;
|
|||||||
//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
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
loadNextPages($("html").html());
|
loadNextPages($("html").html());
|
||||||
$('[title*="next listing"]').remove();
|
|
||||||
loadDataBase();
|
loadDataBase();
|
||||||
//make heading and modal
|
//make heading and modal
|
||||||
if (!$("#kw_results_table").length) {
|
if (!$("#kw_results_table").length) {
|
||||||
@@ -139,37 +139,42 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function loadNextPages(inHTML) {
|
function loadNextPages(inHTML) {
|
||||||
var html = $('<div/>').html(inHTML).contents();
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
let next = html.find("#next_nav_link");
|
if (data.loadAll) {
|
||||||
if (next.length) {
|
$('[title*="next listing"]').remove();
|
||||||
let link = next.prop('href');
|
var html = $('<div/>').html(inHTML).contents();
|
||||||
console.log(link);
|
let next = html.find("#next_nav_link");
|
||||||
chrome.runtime.sendMessage({
|
if (next.length) {
|
||||||
method: "GET",
|
let link = next.prop('href');
|
||||||
action: "xhttp",
|
console.log(link);
|
||||||
url: link,
|
chrome.runtime.sendMessage({
|
||||||
data: ""
|
method: "GET",
|
||||||
}, function (response) {
|
action: "xhttp",
|
||||||
if (response) {
|
url: link,
|
||||||
var nextpage = $('<div/>').html(response).contents();
|
data: ""
|
||||||
var current = $('tbody');
|
}, function (response) {
|
||||||
nextpage.find('tbody>tr').each(function () {
|
if (response) {
|
||||||
if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
|
var nextpage = $('<div/>').html(response).contents();
|
||||||
$(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>`);
|
var current = $('tbody');
|
||||||
// if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
|
nextpage.find('tbody>tr').each(function () {
|
||||||
// $(this).find('td').each(function () {
|
if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
|
||||||
// $(this).css('background-color', '#E0E0E0');
|
$(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>`);
|
||||||
// });
|
// if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) {
|
||||||
// }
|
// $(this).find('td').each(function () {
|
||||||
|
// $(this).css('background-color', '#E0E0E0');
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
current.append($(this));
|
||||||
|
});
|
||||||
|
loadNextPages(response);
|
||||||
}
|
}
|
||||||
current.append($(this));
|
})
|
||||||
});
|
} else {
|
||||||
loadNextPages(response);
|
update();
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
} else {
|
});
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveCourse() {
|
function saveCourse() {
|
||||||
|
|||||||
@@ -1,38 +1,70 @@
|
|||||||
var manifestData = chrome.runtime.getManifest();
|
var manifestData = chrome.runtime.getManifest();
|
||||||
$("#version").text(manifestData.version);
|
$("#version").text(manifestData.version);
|
||||||
chrome.storage.sync.get('courseConflictHighlight', function(data) {
|
chrome.storage.sync.get('courseConflictHighlight', function (data) {
|
||||||
if(data.courseConflictHighlight){
|
if (data.courseConflictHighlight) {
|
||||||
off();
|
off('courseConflictHighlight');
|
||||||
|
} else {
|
||||||
|
on('courseConflictHighlight');
|
||||||
}
|
}
|
||||||
else {
|
});
|
||||||
on();
|
chrome.storage.sync.get('loadAll', function (data) {
|
||||||
|
if (data.loadAll) {
|
||||||
|
off('loadAll');
|
||||||
|
} else {
|
||||||
|
on('loadAll');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#toggleConflictHighlighting").click(function(){
|
$("#togglecourseConflictHighlight").click(function () {
|
||||||
var action = $("#toggleConflictHighlighting").text();
|
var action = $("#togglecourseConflictHighlight").text();
|
||||||
if(action == "Turn Off"){
|
if (action == "Turn Off") {
|
||||||
chrome.storage.sync.set({courseConflictHighlight: false}, function() {
|
chrome.storage.sync.set({
|
||||||
on();
|
courseConflictHighlight: false
|
||||||
|
}, function () {
|
||||||
|
on('courseConflictHighlight');
|
||||||
});
|
});
|
||||||
} else{
|
} else {
|
||||||
chrome.storage.sync.set({courseConflictHighlight: true}, function() {
|
chrome.storage.sync.set({
|
||||||
off();
|
courseConflictHighlight: true
|
||||||
|
}, function () {
|
||||||
|
off('courseConflictHighlight');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
chrome.tabs.query({}, function(tabs) {
|
chrome.tabs.query({}, function (tabs) {
|
||||||
for(var i = 0; i<tabs.length; i++){
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
chrome.tabs.sendMessage(tabs[i].id, {
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function on(){
|
$("#toggleloadAll").click(function () {
|
||||||
$("#toggleConflictHighlighting").text("Turn On");
|
var action = $("#toggleloadAll").text();
|
||||||
$("#toggleConflictHighlighting").css("background","#4CAF50");
|
if (action == "Turn Off") {
|
||||||
|
chrome.storage.sync.set({
|
||||||
|
loadAll: false
|
||||||
|
}, function () {
|
||||||
|
on('loadAll');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
chrome.storage.sync.set({
|
||||||
|
loadAll: true
|
||||||
|
}, function () {
|
||||||
|
off('loadAll');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function on(setting) {
|
||||||
|
$("#toggle" + setting).text("Turn On");
|
||||||
|
$("#toggle" + setting).css("background", "#4CAF50");
|
||||||
}
|
}
|
||||||
function off(){
|
|
||||||
$("#toggleConflictHighlighting").text("Turn Off");
|
function off(setting) {
|
||||||
$("#toggleConflictHighlighting").css("background","#F44336");
|
$("#toggle" + setting).text("Turn Off");
|
||||||
|
$("#toggle" + setting).css("background", "#F44336");
|
||||||
}
|
}
|
||||||
29
options.html
29
options.html
@@ -1,17 +1,30 @@
|
|||||||
<!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/styles.css">
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
|
||||||
<div class="card" style="width: 400px; margin-left:auto;margin-right: auto; height:auto;"id="header">
|
|
||||||
<h2 style="padding:16px 16px 0px 16px;font-size: 20px"> <u>Options</u> </h2>
|
|
||||||
<h2 style="padding: 5px 16px 16px 16px; font-weight: normal;display: inline-block;text-align:left;">Conflict Highlighting</h2>
|
|
||||||
<button id="toggleConflictHighlighting" class="matbut" style="margin-left: 20%;text-align:right;display:inline-block;font-size:medium;background:#F44336;">Turn Off</button>
|
|
||||||
|
|
||||||
<p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p>
|
<body>
|
||||||
<script src="js/jquery-3.3.1.min.js"></script>
|
<div class="card" style="width: 400px; margin-left:auto;margin-right: auto; height:auto;" id="header">
|
||||||
<script src="js/options.js"></script>
|
<h2 style="padding:16px 16px 0px 16px;font-size: 20px"> <u>Options</u> </h2>
|
||||||
|
<div>
|
||||||
|
<h2 style="padding: 5px 16px 5px 16px; font-weight: normal;display: inline-block;text-align:left;">Conflict
|
||||||
|
Highlighting</h2>
|
||||||
|
<button id="togglecourseConflictHighlight" class="matbut" style="float:right; display:inline-block;font-size:medium;background:#F44336;">Turn
|
||||||
|
Off</button>
|
||||||
|
<h2 style="padding: 5px 16px 16px 16px; font-weight: normal;display: inline-block;text-align:left;">All Courses
|
||||||
|
on First Page</h2>
|
||||||
|
<button id="toggleloadAll" class="matbut" style="float: right;display:inline-block;font-size:medium;background:#F44336;">Turn
|
||||||
|
Off</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p>
|
||||||
|
<script src="js/jquery-3.3.1.min.js"></script>
|
||||||
|
<script src="js/options.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user