deleting from calendar

This commit is contained in:
10001shh
2018-08-25 20:26:46 -05:00
parent 7b82ea4e44
commit 86dfdcfb03
4 changed files with 162 additions and 109 deletions

View File

@@ -244,7 +244,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
#classname { #classname {
font-weight: bold; font-weight: bold;
margin-bottom: -10px; margin-bottom: -10px;
font-size: medium; font-size: large;
} }
.modal-content { .modal-content {
@@ -254,7 +254,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
overflow-y: auto; overflow-y: auto;
padding: 20px; padding: 20px;
border: 1px solid #888; border: 1px solid #888;
width: 30%; width: 35%;
} }
#prof { #prof {
@@ -266,6 +266,12 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
margin: 10px; margin: 10px;
} }
body a:link,
body a:visited {
font-weight: bold;
color: #3c87a3;
}
.time { .time {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;

View File

@@ -13,13 +13,14 @@ $(function () {
]); ]);
const fadetime = 150; const fadetime = 150;
const butdelay = 75; const butdelay = 75;
$("#calendar").prepend('<div id="myModal" class="modal"><div class="modal-content"><span class="close">&times;</span><div class="card"><div class="cardcontainer"><div><div style="display:flex;"><h2 id="classname">Classname</h2></div><p id="prof">Prof</p></div><div id="timelines"></div><button id="info" class="matbut" style="font-size:medium; margin-right: auto; margin-left:auto; background: #FF9800;">More Info</button></div></div></div></div>'); $("#calendar").prepend('<div id="myModal" class="modal"><div class="modal-content"><span class="close">&times;</span><div class="card"><div class="cardcontainer"><div><div style="display:flex;"><h2 id="classname">Classname</h2></div><p id="prof">Prof</p></div><div id="timelines"></div><button id="info" class="matbut" style="font-size:medium; margin-right: auto; margin-left:auto; background: #FF9800;">More Info</button><button id="remove" class="matbut" style="font-size:medium;margin:10px;background: #FF0000;">Remove</button></div></div></div></div>');
// Counter to iterate through material colors to avoid duplicates // Counter to iterate through material colors to avoid duplicates
var colorCounter = 0; var colorCounter = 0;
// Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR' // Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR'
var classSchedules = []; var classSchedules = [];
var savedCourses = []; var savedCourses = [];
var currLink = ""; var currLink = "";
var currindex = 0;
chrome.storage.sync.get("savedCourses", function (data) { chrome.storage.sync.get("savedCourses", function (data) {
// Iterate through each saved course and add to 'event' // Iterate through each saved course and add to 'event'
savedCourses = data.savedCourses; savedCourses = data.savedCourses;
@@ -53,11 +54,12 @@ $(function () {
}, },
eventClick: function (data, event, view) { eventClick: function (data, event, view) {
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(fadetime);
currLink = savedCourses[data.index].link; currindex = data.index;
var currunique = savedCourses[data.index].unique; currLink = savedCourses[currindex].link;
$("#classname").html(`${savedCourses[data.index].coursename} <span style='font-size:small'>(${savedCourses[data.index].unique})</span>`); var currunique = savedCourses[currindex].unique;
$("#timelines").append(makeLine(savedCourses[data.index].datetimearr)); $("#classname").html(`${savedCourses[currindex].coursename} <span style='font-size:small'>(${savedCourses[currindex].unique})</span>`);
$("#prof").html(`with <span style='font-weight:bold;'>${savedCourses[data.index].profname}</span>`); $("#timelines").append(makeLine(savedCourses[currindex].datetimearr));
$("#prof").html(`with <span style='font-weight:bold;'>${savedCourses[currindex].profname}</span>`);
} }
}); });
}); });
@@ -103,6 +105,25 @@ $(function () {
window.open(currLink); window.open(currLink);
}, butdelay); }, butdelay);
}); });
$("#remove").click(() => {
setTimeout(() => {
chrome.runtime.sendMessage({
command: "courseStorage",
course: savedCourses[currindex],
action: "remove"
}, function (response) {
$("#myModal").fadeOut(fadetime);
updateCalendar();
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, {
command: "updateCourseList"
});
}
});
});
}, butdelay);
});
/*Close Modal when hit escape*/ /*Close Modal when hit escape*/
$(document).keydown((e) => { $(document).keydown((e) => {
if (e.keyCode == 27) { if (e.keyCode == 27) {
@@ -189,6 +210,11 @@ $(function () {
chrome.runtime.onMessage.addListener( chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) { function (request, sender, sendResponse) {
if (request.command == "updateCourseList" || request.command == "courseAdded") { if (request.command == "updateCourseList" || request.command == "courseAdded") {
updateCalendar();
}
});
function updateCalendar() {
chrome.storage.sync.get("savedCourses", function (data) { chrome.storage.sync.get("savedCourses", function (data) {
savedCourses = data.savedCourses savedCourses = data.savedCourses
setAllEvents(data.savedCourses); setAllEvents(data.savedCourses);
@@ -198,4 +224,3 @@ $(function () {
}); });
} }
}); });
});

View File

@@ -50,6 +50,45 @@ $(function () {
}); });
$("#saveCourse").click(function () { $("#saveCourse").click(function () {
saveCourse();
});
$("#Syllabi").click(function () {
setTimeout(function () {
window.open('https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=' + department + '&course_number=' + course_nbr + '&course_title=&unique=&instructor_first=&instructor_last=' + profname + '&course_type=In+Residence&search=Search');
}, butdelay);
});
$("#rateMyProf").click(function () {
setTimeout(function () {
window.open(rmpLink);
}, butdelay);
});
$("#eCIS").click(function () {
setTimeout(function () {
window.open(eCISLink);
}, butdelay);
});
$(document).keydown(function (e) {
/*Close Modal when hit escape*/
if (e.keyCode == 27) {
$("#myModal").fadeOut(fadetime);
$("#snackbar").attr("class", "");
} else if (e.keyCode == 13) {
/*save course when hit enter*/
saveCourse();
}
});
/*Listen for update mssage coming from popup*/
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.command == "updateCourseList") {
console.log("hello");
update();
}
});
});
function saveCourse() {
var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl); var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl);
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
command: "courseStorage", command: "courseStorage",
@@ -68,40 +107,7 @@ $(function () {
update(); update();
}); });
}); });
});
$("#Syllabi").click(function () {
setTimeout(function () {
window.open('https://utdirect.utexas.edu/apps/student/coursedocs/nlogon/?semester=&department=' + department + '&course_number=' + course_nbr + '&course_title=&unique=&instructor_first=&instructor_last=' + profname + '&course_type=In+Residence&search=Search');
}, butdelay);
});
$("#rateMyProf").click(function () {
setTimeout(function () {
window.open(rmpLink);
}, butdelay);
});
$("#eCIS").click(function () {
setTimeout(function () {
window.open(eCISLink);
}, butdelay);
});
/*Close Modal when hit escape*/
$(document).keydown(function (e) {
if (e.keyCode == 27) {
$("#myModal").fadeOut(fadetime);
} }
$("#snackbar").attr("class", "");
});
/*Listen for update mssage coming from popup*/
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.command == "updateCourseList") {
console.log("hello");
update();
}
});
});
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */ /* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
function update() { function update() {

View File

@@ -2,7 +2,9 @@ var courses;
// get the courses from storage // get the courses from storage
chrome.storage.sync.get('savedCourses', function (data) { chrome.storage.sync.get('savedCourses', function (data) {
//find, build, and show the messages for the conflicts in the saved courses //find, build, and show the messages for the conflicts in the saved courses
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { chrome.runtime.sendMessage({
command: "checkConflicts"
}, function (response) {
var isConflicted = []; var isConflicted = [];
if (response.isConflict) { if (response.isConflict) {
var between = response.between; var between = response.between;
@@ -28,11 +30,9 @@ chrome.storage.sync.get('savedCourses', function(data) {
status = courses[i].status; status = courses[i].status;
if (status.includes("open")) { if (status.includes("open")) {
color = "#4CAF50"; color = "#4CAF50";
} } else if (status.includes("waitlisted")) {
else if(status.includes("waitlisted")){
color = "#FF9800" color = "#FF9800"
} } else if (status.includes("closed") || status.includes("cancelled")) {
else if(status.includes("closed") || status.includes("cancelled")){
color = "#F44336"; color = "#F44336";
} }
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);
@@ -52,7 +52,9 @@ function getSimpleName(coursename, unique){
/* Update the conflict messages */ /* Update the conflict messages */
function updateConflicts() { function updateConflicts() {
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { chrome.runtime.sendMessage({
command: "checkConflicts"
}, function (response) {
var isConflicted = []; var isConflicted = [];
if (response.isConflict) { if (response.isConflict) {
var between = response.between; var between = response.between;
@@ -80,7 +82,11 @@ $(document).ready(function() {
$(this).find("#listRemove").click(function () { $(this).find("#listRemove").click(function () {
var thisForm = this; var thisForm = this;
$(thisForm).closest("ul").find("> p").remove(); $(thisForm).closest("ul").find("> p").remove();
chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) { chrome.runtime.sendMessage({
command: "courseStorage",
course: courses[$(thisForm).closest("li").attr("id")],
action: "remove"
}, function (response) {
$(thisForm).closest("li").fadeOut(200); $(thisForm).closest("li").fadeOut(200);
if ($(thisForm).closest("ul").children(':visible').length === 1) { if ($(thisForm).closest("ul").children(':visible').length === 1) {
$("#courseList").fadeOut(300, function () { $("#courseList").fadeOut(300, function () {
@@ -90,7 +96,9 @@ $(document).ready(function() {
updateConflicts(); updateConflicts();
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"
});
} }
}); });
}); });
@@ -98,8 +106,7 @@ $(document).ready(function() {
/* Show the times popout and more info options*/ /* Show the times popout and more info options*/
if ($(this).find("#moreInfo").is(":hidden")) { if ($(this).find("#moreInfo").is(":hidden")) {
$(this).find("#moreInfo").fadeIn(200); $(this).find("#moreInfo").fadeIn(200);
} } else {
else{
$(this).find("#moreInfo").fadeOut(200); $(this).find("#moreInfo").fadeOut(200);
} }
}); });
@@ -107,13 +114,19 @@ $(document).ready(function() {
clear(); clear();
}); });
$("#schedule").click(function () { $("#schedule").click(function () {
chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'}); chrome.tabs.create({
'url': 'https://registrar.utexas.edu/schedules'
});
}); });
$("#open").click(function () { $("#open").click(function () {
chrome.tabs.create({ 'url': "options.html"}); chrome.tabs.create({
'url': "options.html"
});
}); });
$("#calendar").click(function () { $("#calendar").click(function () {
chrome.tabs.create({ 'url': "calendar.html"}); chrome.tabs.create({
'url': "calendar.html"
});
}); });
}); });
@@ -129,8 +142,7 @@ function makeLine(index){
for (var i = 0; i < datetimearr.length; i++) { for (var i = 0; i < datetimearr.length; i++) {
if (dtmap.has(String(datetimearr[i][1]))) { if (dtmap.has(String(datetimearr[i][1]))) {
dtmap.set(String(datetimearr[i][1]), dtmap.get(String(datetimearr[i][1])) + datetimearr[i][0]); dtmap.set(String(datetimearr[i][1]), dtmap.get(String(datetimearr[i][1])) + datetimearr[i][0]);
} } else {
else{
dtmap.set(String(datetimearr[i][1]), datetimearr[i][0]); dtmap.set(String(datetimearr[i][1]), datetimearr[i][0]);
} }
} }
@@ -146,10 +158,14 @@ function makeLine(index){
/*Clear the list and the storage of courses*/ /*Clear the list and the storage of courses*/
function clear() { function clear() {
chrome.storage.sync.set({savedCourses: []}); chrome.storage.sync.set({
savedCourses: []
});
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"
});
} }
}); });
console.log("cleared"); console.log("cleared");