removing from saved
This commit is contained in:
@@ -87,12 +87,13 @@ function add(request, sender, sendResponse) {
|
|||||||
function remove(request, sender, sendResponse) {
|
function remove(request, sender, sendResponse) {
|
||||||
chrome.storage.sync.get('savedCourses', function(data) {
|
chrome.storage.sync.get('savedCourses', function(data) {
|
||||||
var courses = data.savedCourses;
|
var courses = data.savedCourses;
|
||||||
|
console.log(courses);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
console.log(courses.length);
|
||||||
while(index<courses.length && courses[index].unique != request.course.unique){
|
while(index<courses.length && courses[index].unique != request.course.unique){
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
courses.splice(index,1);
|
courses.splice(index,1);
|
||||||
console.log(courses);
|
|
||||||
chrome.storage.sync.set({savedCourses: courses});
|
chrome.storage.sync.set({savedCourses: courses});
|
||||||
sendResponse({done:"Removed: ("+request.course.unique+") "+request.course.coursename,label:"Add Course +"});
|
sendResponse({done:"Removed: ("+request.course.unique+") "+request.course.coursename,label:"Add Course +"});
|
||||||
});
|
});
|
||||||
|
|||||||
16
content.js
16
content.js
@@ -28,13 +28,17 @@ $(document).ready( function() {
|
|||||||
$('table').find('tr').each(function(){
|
$('table').find('tr').each(function(){
|
||||||
if(!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0){
|
if(!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0){
|
||||||
//if a course row, then add the extension button and do something if that course has been "saved"
|
//if a course row, then add the extension button and do something if that course has been "saved"
|
||||||
|
var thisForm = this;
|
||||||
$(this).append('<td data-th="Plus"><input type="image" class="distButton" style="vertical-align: bottom; display:block;" width="25" height="25" src='+chrome.extension.getURL('disticon.png')+' /></td>');
|
$(this).append('<td data-th="Plus"><input type="image" class="distButton" style="vertical-align: bottom; display:block;" width="25" height="25" src='+chrome.extension.getURL('disticon.png')+' /></td>');
|
||||||
chrome.runtime.sendMessage({command: "alreadyContains",unique: $(this).find('td[data-th="Unique"]').text()}, function(response) {
|
// chrome.runtime.sendMessage({command: "alreadyContains",unique: $(this).find('td[data-th="Unique"]').text()}, function(response) {
|
||||||
if(response.alreadyContains){
|
// if(response.alreadyContains){
|
||||||
//DO SOMETHING IF ALREADY CONTAINS
|
// //DO SOMETHING IF ALREADY CONTAINS
|
||||||
console.log("ALREADY CONTAINS IN THIS ROW");
|
// $(thisForm).find('td').each(function(){
|
||||||
}
|
// // $(this).css('font-weight','bold');
|
||||||
});
|
// $(this).css('color','#4CAF50');
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,12 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.truncate {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.matbut:after {
|
.matbut:after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
10
popup.html
10
popup.html
@@ -6,15 +6,15 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="card" id="header">
|
<div class="card" id="header">
|
||||||
<h2 id='headertext'>Saved Courses</h2>
|
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
|
||||||
<div id="buttons" style="padding: 10px 0px 5px 10px;">
|
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button>
|
||||||
<button id="clear" class="matbut" style="background:#4CAF50">Clear</button>
|
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px">Schedule</button>
|
||||||
<button id="open" class="matbut" style="background:#FFC107">Options</button>
|
<button id="open" class="matbut" style="font-size:medium;background:#FFC107;margin: 10px;">Options</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul id= "courseList" style="list-style-type: none;padding: 5px;"></ul>
|
<ul id= "courseList" style="list-style-type: none;padding: 5px;"></ul>
|
||||||
<h2 id="empty" style="font-weight: normal;font-size: large;margin: 60px 30px 40px 30px ;">Doesn't Look Like Anything To Me.<br>
|
<h2 id="empty" style="font-weight: normal;font-size: large;margin: 60px 30px 40px 30px ;">Doesn't Look Like Anything To Me.<br>
|
||||||
<span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses)</span><h2>
|
<span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span><h2>
|
||||||
<script src="jquery-3.3.1.min.js"></script>
|
<script src="jquery-3.3.1.min.js"></script>
|
||||||
<script src="moment.min.js"></script>
|
<script src="moment.min.js"></script>
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
|
|||||||
50
popup.js
50
popup.js
@@ -36,7 +36,7 @@ chrome.storage.sync.get('savedCourses', function(data) {
|
|||||||
var department = courses[i].coursename.substring(0,courses[i].coursename.search(/\d/)-2);
|
var department = courses[i].coursename.substring(0,courses[i].coursename.search(/\d/)-2);
|
||||||
var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/),courses[i].coursename.indexOf(" ",courses[i].coursename.search(/\d/)));
|
var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/),courses[i].coursename.indexOf(" ",courses[i].coursename.search(/\d/)));
|
||||||
var profname = courses[i].profname.substring(0,1)+courses[i].profname.substring(1).toLowerCase();
|
var profname = courses[i].profname.substring(0,1)+courses[i].profname.substring(1).toLowerCase();
|
||||||
var listhtml = "<li id='"+i+"'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:"+color+"''><h4 style='color:white; margin:5px; font-size:large;'><b>"+department + " "+course_nbr+"<span style='font-size:medium'>"+" with </span><span style='font-size:medium'>"+profname+" ("+courses[i].unique+")"+"</span></b></h4></div></div><p style='display: none;font-weight:bold;padding:10px;font-size:small;background-color:#FFCDD2;'>"+makeLine(i)+"</p></li>";
|
var listhtml = "<li id='"+i+"'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:"+color+"''><h4 class='truncate' style='color:white;margin:5px; font-size:large;'><b>"+department + " "+course_nbr+"<span style='font-size:medium'>"+" with </span><span style='font-size:medium'>"+profname+" ("+courses[i].unique+")"+"</span></b></h4></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px;font-size:small;background-color:#FFCDD2;'>"+makeLine(i)+"</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>";
|
||||||
$("#courseList").append(listhtml);
|
$("#courseList").append(listhtml);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -47,20 +47,53 @@ function getSimpleName(coursename, unique){
|
|||||||
return department+" "+course_nbr+" ("+unique+")";
|
return department+" "+course_nbr+" ("+unique+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateConflicts(){
|
||||||
|
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) {
|
||||||
|
var isConflicted = [];
|
||||||
|
if(response.isConflict){
|
||||||
|
var between = response.between;
|
||||||
|
var text = "";
|
||||||
|
for(var i = 0; i<between.length;i++){
|
||||||
|
text+="Conflict between: "+ getSimpleName(between[i][0].coursename,between[i][0].unique) + " and "+getSimpleName(between[i][1].coursename,between[i][1].unique);
|
||||||
|
isConflicted.push(between[i][0].unique);
|
||||||
|
isConflicted.push(between[i][1].unique);
|
||||||
|
if(i != between.length-1){
|
||||||
|
text+= "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px;'>"+text+"</>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#clear").click(function(){
|
$("#clear").click(function(){
|
||||||
clear();
|
clear();
|
||||||
});
|
});
|
||||||
$("#courseList li").click(function(){
|
$("#courseList li").click(function(){
|
||||||
//makeLine($(this).attr("id"));
|
//GACKY FIX
|
||||||
if($(this).find("p").is(":hidden")){
|
$(this).find("#listMoreInfo").click(function(){
|
||||||
$(this).find("p").fadeIn(200);
|
window.open(courses[$(this).closest("li").attr("id")].link);
|
||||||
|
});
|
||||||
|
$(this).find("#listRemove").click(function(){
|
||||||
|
var thisForm = this;
|
||||||
|
chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) {
|
||||||
|
$(thisForm).closest("li").fadeOut(200);
|
||||||
|
console.log($(thisForm).closest("ul").children(":visible").length);
|
||||||
|
$(thisForm).closest("ul").find("> p").remove();
|
||||||
|
if($(thisForm).closest("ul").children(':visible').length===1){
|
||||||
|
$("#empty").fadeIn(200);
|
||||||
|
}
|
||||||
|
updateConflicts();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if($(this).find("#moreInfo").is(":hidden")){
|
||||||
|
$(this).find("#moreInfo").fadeIn(200);
|
||||||
//alert("hello");
|
//alert("hello");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$(this).find("p").fadeOut(200);
|
$(this).find("#moreInfo").fadeOut(200);
|
||||||
}
|
}
|
||||||
// window.open(courses[$(this).attr("id")].link);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,10 +133,7 @@ function clear(){
|
|||||||
chrome.storage.sync.set({savedCourses: []});
|
chrome.storage.sync.set({savedCourses: []});
|
||||||
console.log("cleared");
|
console.log("cleared");
|
||||||
$("#courseList").fadeOut(300,function(){
|
$("#courseList").fadeOut(300,function(){
|
||||||
$("#empty").show();
|
$("#empty").fadeIn(200);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
function update(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
17
todo
17
todo
@@ -8,18 +8,23 @@ TODO as of 7/10/18:
|
|||||||
- eureka integration
|
- eureka integration
|
||||||
- underline Courses maybe? click to go to using the planner link thing
|
- underline Courses maybe? click to go to using the planner link thing
|
||||||
- schedule generator
|
- schedule generator
|
||||||
- show schedule conflicts on the course page
|
- show schedule conflicts on the course page, and on the registration courselist
|
||||||
-highlight in red on save course screen
|
- highlight in red on save course screen
|
||||||
- sync saved
|
- sync saved
|
||||||
-use maps for schedule conflict
|
- "more at a glance" info on course list screen
|
||||||
-added/removing/action toasts
|
- use maps for schedule conflict
|
||||||
|
- refresh the page get description
|
||||||
|
- update page with schedule conflict information
|
||||||
|
|
||||||
CLEAN UP:
|
CLEAN UP:
|
||||||
Everything lmao
|
Everything lmao
|
||||||
|
|
||||||
KNOWN BUGS:
|
KNOWN BUGS:
|
||||||
- FIX POP UP CARD NOT FILLING FULL LENGTH
|
- FIX POP UP CARD NOT FILLING FULL LENGTH
|
||||||
|
- FIX toast bug
|
||||||
|
- FIX save course when no times blank
|
||||||
|
- FIX Open popup flickering
|
||||||
|
- FIX DIST ICON NOT SCALING IN TD PROBLEM
|
||||||
|
|
||||||
IN-PROGRESS:
|
IN-PROGRESS:
|
||||||
- icon
|
- icon
|
||||||
@@ -44,4 +49,4 @@ FIXED/DONE as of 7/10/18:
|
|||||||
- popup.html
|
- popup.html
|
||||||
- Schedule Conflicts
|
- Schedule Conflicts
|
||||||
- when almost everything is blank: M 379H as example
|
- when almost everything is blank: M 379H as example
|
||||||
|
- added/removing/action toasts
|
||||||
|
|||||||
Reference in New Issue
Block a user