This commit is contained in:
10001shh
2018-08-30 21:35:46 -05:00
parent af0d8a775e
commit 6b6a35e9b5
3 changed files with 91 additions and 82 deletions

View File

@@ -1,8 +1,8 @@
$(function () { $(function () {
const materialColors = ['#4CAF50', '#CDDC39', const materialColors = ['#4CAF50', '#CDDC39',
'#FFC107', '#2196F3', '#F57C00', '#9C27B0', '#FF5722', '#673AB7', '#FFC107', '#2196F3', '#F57C00', '#9C27B0', '#FF5722', '#673AB7',
'#FF5252', '#E91E63', '#009688', '#00BCD4', '#FF5252', '#E91E63', '#009688', '#00BCD4',
'#4E342E', '#424242', '#9E9E9E' '#4E342E', '#424242', '#9E9E9E'
]; ];
const days = new Map([ const days = new Map([
["M", "Monday"], ["M", "Monday"],
@@ -10,7 +10,7 @@ $(function () {
["W", "Wednesday"], ["W", "Wednesday"],
["TH", "Thursday"], ["TH", "Thursday"],
["F", "Friday"] ["F", "Friday"]
]); ]);
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 id="colorStrip" style="height:10px;"></div><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: #2196F3;">More Info</button><button id="register" class="matbut" style="font-size:medium; margin-right: auto; margin-left:10px; background: #4CAF50;">Register</button><button id="remove" class="matbut" style="font-size:medium;margin:10px;background: #FF0000;">Remove</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 id="colorStrip" style="height:10px;"></div><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: #2196F3;">More Info</button><button id="register" class="matbut" style="font-size:medium; margin-right: auto; margin-left:10px; background: #4CAF50;">Register</button><button id="remove" class="matbut" style="font-size:medium;margin:10px;background: #FF0000;">Remove</button></div></div></div></div>');
@@ -45,73 +45,77 @@ $(function () {
events: classSchedules, events: classSchedules,
slotLabelFormat: [ slotLabelFormat: [
'h:mm A' // lower level of text 'h:mm A' // lower level of text
], ],
eventRender: function (event, element, view) { eventRender: function (event, element, view) {
$(element).css("padding", "5px"); $(element).css("padding", "5px");
$(element).css("margin-bottom", "5px"); $(element).css("margin-bottom", "5px");
}, },
eventClick: function (data, event, view) { eventClick: function (data, event, view) {
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(fadetime);
$("#colorStrip").css('background-color', data.color); $("#colorStrip").css('background-color', data.color);
currindex = data.index; currindex = data.index;
var currLink = savedCourses[currindex].link; $("#classname").html(`${savedCourses[currindex].coursename} <span style='font-size:small'>(${savedCourses[currindex].unique})</span>`);
var currunique = savedCourses[currindex].unique; $("#timelines").append(makeLine(savedCourses[currindex].datetimearr));
$("#classname").html(`${savedCourses[currindex].coursename} <span style='font-size:small'>(${savedCourses[currindex].unique})</span>`);
$("#timelines").append(makeLine(savedCourses[currindex].datetimearr));
var uncapProf = prettifyName(savedCourses[currindex].profname); var uncapProf = prettifyName(savedCourses[currindex].profname);
if (uncapProf == "") { if (uncapProf == "") {
uncapProf = "Undecided"; uncapProf = "Undecided";
}
$("#prof").html(`with <span style='font-weight:bold;'>${uncapProf}</span>`);
let status = savedCourses[currindex].status;
if(status.includes("closed") || status.includes("cancelled")){
$("#register").text("Class Closed").css("background-color","#FF5722");
} else{
$("#register").text("Register").css("background-color","#4CAF50").click(function () {
let registerlink = savedCourses[currindex].registerlink;
setTimeout(() => {
window.open(registerlink);
}, butdelay);
});
// When the user clicks on <span> (x), close the modal
$(".close").click(() => {
$("#myModal").fadeOut(fadetime);
});
$("#info").click(() => {
setTimeout(() => {
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);
});
}
} }
}); $("#prof").html(`with <span style='font-weight:bold;'>${uncapProf}</span>`);
});
/* convert from the dtarr and maek the time lines*/ let status = savedCourses[currindex].status;
function makeLine(datetimearr) { if (status.includes("closed") || status.includes("cancelled")) {
$(".time").remove(); $("#register").text("Class Closed").css("background-color", "#FF5722");
} else {
$("#register").text("Register").css("background-color", "#4CAF50");
}
}
});
});
// When the user clicks on <span> (x), close the modal
$(".close").click(() => {
$("#myModal").fadeOut(fadetime);
});
$("#info").click(() => {
var currLink = savedCourses[currindex].link;
setTimeout(() => {
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);
});
$("#register").click(function () {
let registerlink = savedCourses[currindex].registerlink;
let status = savedCourses[currindex].status;
if (!(status.includes("closed") || status.includes("cancelled"))) {
setTimeout(() => {
window.open(registerlink);
}, butdelay);
}
});
/* convert from the dtarr and maek the time lines*/
function makeLine(datetimearr) {
$(".time").remove();
//converted times back //converted times back
console.log(datetimearr); console.log(datetimearr);
var dtmap = new Map([]); var dtmap = new Map([]);
@@ -205,21 +209,21 @@ function makeLine(datetimearr) {
classSchedules.push({ classSchedules.push({
title: `${department}-${course_nbr} with ${uncapProf}`, title: `${department}-${course_nbr} with ${uncapProf}`,
start: moment().format("YYYY-MM-") + start: moment().format("YYYY-MM-") +
moment() moment()
.day(fullday) .day(fullday)
._d.toString() ._d.toString()
.split(" ")[2] + .split(" ")[2] +
"T" + "T" +
session[1][0] + session[1][0] +
":00", ":00",
end: moment().format("YYYY-MM-") + end: moment().format("YYYY-MM-") +
moment() moment()
.day(fullday) .day(fullday)
._d.toString() ._d.toString()
.split(" ")[2] + .split(" ")[2] +
"T" + "T" +
session[1][1] + session[1][1] +
":00", ":00",
color: materialColors[colorCounter], color: materialColors[colorCounter],
index: i, index: i,
allday: false allday: false

View File

@@ -24,7 +24,7 @@
<span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span> <span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span>
</h2> </h2>
<div style=" margin-bottom: 0px; display:inline-block"></div> <div style=" margin-bottom: 0px; display:inline-block"></div>
<button title='Options' class="settingsbut" id='open'> <button title='Options' style="background-color:white;" class="settingsbut" id='open'>
<i style='color:#FF9800' class="material-icons"> <i style='color:#FF9800' class="material-icons">
settings settings
</i></button> </i></button>

5
todo
View File

@@ -3,8 +3,13 @@ TODO as of 8/28/18
FEATURES: FEATURES:
- something to fill the space to the rght of the main popup window - something to fill the space to the rght of the main popup window
- Location in popup extra info
- import into UT registration plus
- import calendar
BUGS TO FIX: BUGS TO FIX:
- online classes no times in popup link
DONE/FIXED: DONE/FIXED:
- unneeded Logout message on individual course pages - unneeded Logout message on individual course pages