deleting from calendar
This commit is contained in:
@@ -244,7 +244,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
||||
#classname {
|
||||
font-weight: bold;
|
||||
margin-bottom: -10px;
|
||||
font-size: medium;
|
||||
font-size: large;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
@@ -254,7 +254,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 30%;
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
#prof {
|
||||
@@ -266,6 +266,12 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
body a:link,
|
||||
body a:visited {
|
||||
font-weight: bold;
|
||||
color: #3c87a3;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
||||
@@ -13,13 +13,14 @@ $(function () {
|
||||
]);
|
||||
const fadetime = 150;
|
||||
const butdelay = 75;
|
||||
$("#calendar").prepend('<div id="myModal" class="modal"><div class="modal-content"><span class="close">×</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">×</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
|
||||
var colorCounter = 0;
|
||||
// Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR'
|
||||
var classSchedules = [];
|
||||
var savedCourses = [];
|
||||
var currLink = "";
|
||||
var currindex = 0;
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
// Iterate through each saved course and add to 'event'
|
||||
savedCourses = data.savedCourses;
|
||||
@@ -53,11 +54,12 @@ $(function () {
|
||||
},
|
||||
eventClick: function (data, event, view) {
|
||||
$("#myModal").fadeIn(fadetime);
|
||||
currLink = savedCourses[data.index].link;
|
||||
var currunique = savedCourses[data.index].unique;
|
||||
$("#classname").html(`${savedCourses[data.index].coursename} <span style='font-size:small'>(${savedCourses[data.index].unique})</span>`);
|
||||
$("#timelines").append(makeLine(savedCourses[data.index].datetimearr));
|
||||
$("#prof").html(`with <span style='font-weight:bold;'>${savedCourses[data.index].profname}</span>`);
|
||||
currindex = data.index;
|
||||
currLink = savedCourses[currindex].link;
|
||||
var currunique = savedCourses[currindex].unique;
|
||||
$("#classname").html(`${savedCourses[currindex].coursename} <span style='font-size:small'>(${savedCourses[currindex].unique})</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);
|
||||
}, 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*/
|
||||
$(document).keydown((e) => {
|
||||
if (e.keyCode == 27) {
|
||||
@@ -189,6 +210,11 @@ $(function () {
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function (request, sender, sendResponse) {
|
||||
if (request.command == "updateCourseList" || request.command == "courseAdded") {
|
||||
updateCalendar();
|
||||
}
|
||||
});
|
||||
|
||||
function updateCalendar() {
|
||||
chrome.storage.sync.get("savedCourses", function (data) {
|
||||
savedCourses = data.savedCourses
|
||||
setAllEvents(data.savedCourses);
|
||||
@@ -198,4 +224,3 @@ $(function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -50,6 +50,45 @@ $(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);
|
||||
chrome.runtime.sendMessage({
|
||||
command: "courseStorage",
|
||||
@@ -68,40 +107,7 @@ $(function () {
|
||||
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 */
|
||||
function update() {
|
||||
|
||||
50
js/popup.js
50
js/popup.js
@@ -2,7 +2,9 @@ var courses;
|
||||
// get the courses from storage
|
||||
chrome.storage.sync.get('savedCourses', function (data) {
|
||||
//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 = [];
|
||||
if (response.isConflict) {
|
||||
var between = response.between;
|
||||
@@ -28,11 +30,9 @@ chrome.storage.sync.get('savedCourses', function(data) {
|
||||
status = courses[i].status;
|
||||
if (status.includes("open")) {
|
||||
color = "#4CAF50";
|
||||
}
|
||||
else if(status.includes("waitlisted")){
|
||||
} else if (status.includes("waitlisted")) {
|
||||
color = "#FF9800"
|
||||
}
|
||||
else if(status.includes("closed") || status.includes("cancelled")){
|
||||
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||
color = "#F44336";
|
||||
}
|
||||
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 */
|
||||
function updateConflicts() {
|
||||
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) {
|
||||
chrome.runtime.sendMessage({
|
||||
command: "checkConflicts"
|
||||
}, function (response) {
|
||||
var isConflicted = [];
|
||||
if (response.isConflict) {
|
||||
var between = response.between;
|
||||
@@ -80,7 +82,11 @@ $(document).ready(function() {
|
||||
$(this).find("#listRemove").click(function () {
|
||||
var thisForm = this;
|
||||
$(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);
|
||||
if ($(thisForm).closest("ul").children(':visible').length === 1) {
|
||||
$("#courseList").fadeOut(300, function () {
|
||||
@@ -90,7 +96,9 @@ $(document).ready(function() {
|
||||
updateConflicts();
|
||||
chrome.tabs.query({}, function (tabs) {
|
||||
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*/
|
||||
if ($(this).find("#moreInfo").is(":hidden")) {
|
||||
$(this).find("#moreInfo").fadeIn(200);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$(this).find("#moreInfo").fadeOut(200);
|
||||
}
|
||||
});
|
||||
@@ -107,13 +114,19 @@ $(document).ready(function() {
|
||||
clear();
|
||||
});
|
||||
$("#schedule").click(function () {
|
||||
chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'});
|
||||
chrome.tabs.create({
|
||||
'url': 'https://registrar.utexas.edu/schedules'
|
||||
});
|
||||
});
|
||||
$("#open").click(function () {
|
||||
chrome.tabs.create({ 'url': "options.html"});
|
||||
chrome.tabs.create({
|
||||
'url': "options.html"
|
||||
});
|
||||
});
|
||||
$("#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++) {
|
||||
if (dtmap.has(String(datetimearr[i][1]))) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
@@ -146,10 +158,14 @@ function makeLine(index){
|
||||
|
||||
/*Clear the list and the storage of courses*/
|
||||
function clear() {
|
||||
chrome.storage.sync.set({savedCourses: []});
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: []
|
||||
});
|
||||
chrome.tabs.query({}, function (tabs) {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user