removing from saved
This commit is contained in:
@@ -87,12 +87,13 @@ function add(request, sender, sendResponse) {
|
||||
function remove(request, sender, sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function(data) {
|
||||
var courses = data.savedCourses;
|
||||
console.log(courses);
|
||||
var index = 0;
|
||||
console.log(courses.length);
|
||||
while(index<courses.length && courses[index].unique != request.course.unique){
|
||||
index++;
|
||||
}
|
||||
courses.splice(index,1);
|
||||
console.log(courses);
|
||||
chrome.storage.sync.set({savedCourses: courses});
|
||||
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(){
|
||||
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"
|
||||
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>');
|
||||
chrome.runtime.sendMessage({command: "alreadyContains",unique: $(this).find('td[data-th="Unique"]').text()}, function(response) {
|
||||
if(response.alreadyContains){
|
||||
//DO SOMETHING IF ALREADY CONTAINS
|
||||
console.log("ALREADY CONTAINS IN THIS ROW");
|
||||
}
|
||||
});
|
||||
// chrome.runtime.sendMessage({command: "alreadyContains",unique: $(this).find('td[data-th="Unique"]').text()}, function(response) {
|
||||
// if(response.alreadyContains){
|
||||
// //DO SOMETHING IF ALREADY CONTAINS
|
||||
// $(thisForm).find('td').each(function(){
|
||||
// // $(this).css('font-weight','bold');
|
||||
// $(this).css('color','#4CAF50');
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.truncate {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.matbut:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
|
||||
10
popup.html
10
popup.html
@@ -6,15 +6,15 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="card" id="header">
|
||||
<h2 id='headertext'>Saved Courses</h2>
|
||||
<div id="buttons" style="padding: 10px 0px 5px 10px;">
|
||||
<button id="clear" class="matbut" style="background:#4CAF50">Clear</button>
|
||||
<button id="open" class="matbut" style="background:#FFC107">Options</button>
|
||||
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
|
||||
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button>
|
||||
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px">Schedule</button>
|
||||
<button id="open" class="matbut" style="font-size:medium;background:#FFC107;margin: 10px;">Options</button>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<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="moment.min.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 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 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);
|
||||
}
|
||||
});
|
||||
@@ -47,20 +47,53 @@ function getSimpleName(coursename, 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() {
|
||||
$("#clear").click(function(){
|
||||
clear();
|
||||
});
|
||||
$("#courseList li").click(function(){
|
||||
//makeLine($(this).attr("id"));
|
||||
if($(this).find("p").is(":hidden")){
|
||||
$(this).find("p").fadeIn(200);
|
||||
//GACKY FIX
|
||||
$(this).find("#listMoreInfo").click(function(){
|
||||
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");
|
||||
}
|
||||
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: []});
|
||||
console.log("cleared");
|
||||
$("#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
|
||||
- underline Courses maybe? click to go to using the planner link thing
|
||||
- schedule generator
|
||||
- show schedule conflicts on the course page
|
||||
-highlight in red on save course screen
|
||||
- show schedule conflicts on the course page, and on the registration courselist
|
||||
- highlight in red on save course screen
|
||||
- sync saved
|
||||
-use maps for schedule conflict
|
||||
-added/removing/action toasts
|
||||
- "more at a glance" info on course list screen
|
||||
- use maps for schedule conflict
|
||||
- refresh the page get description
|
||||
- update page with schedule conflict information
|
||||
|
||||
CLEAN UP:
|
||||
Everything lmao
|
||||
|
||||
KNOWN BUGS:
|
||||
- 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:
|
||||
- icon
|
||||
@@ -44,4 +49,4 @@ FIXED/DONE as of 7/10/18:
|
||||
- popup.html
|
||||
- Schedule Conflicts
|
||||
- when almost everything is blank: M 379H as example
|
||||
|
||||
- added/removing/action toasts
|
||||
|
||||
Reference in New Issue
Block a user