button disabling
This commit is contained in:
@@ -13,13 +13,12 @@ $(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 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: #FF9800;">More Info</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">×</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>');
|
||||
// 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'
|
||||
@@ -56,7 +55,7 @@ $(function () {
|
||||
$("#myModal").fadeIn(fadetime);
|
||||
$("#colorStrip").css('background-color', data.color);
|
||||
currindex = data.index;
|
||||
currLink = savedCourses[currindex].link;
|
||||
var 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));
|
||||
@@ -66,12 +65,52 @@ $(function () {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* convert from the dtarr and maek the time lines*/
|
||||
function makeLine(datetimearr) {
|
||||
/* convert from the dtarr and maek the time lines*/
|
||||
function makeLine(datetimearr) {
|
||||
$(".time").remove();
|
||||
//converted times back
|
||||
console.log(datetimearr);
|
||||
@@ -101,35 +140,6 @@ $(function () {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
});
|
||||
/*Close Modal when hit escape*/
|
||||
$(document).keydown((e) => {
|
||||
if (e.keyCode == 27) {
|
||||
|
||||
@@ -130,22 +130,16 @@ function update() {
|
||||
}, function (response) {
|
||||
if (response.isConflict && data.courseConflictHighlight) {
|
||||
$(thisForm).find('td').each(function () {
|
||||
$(this).css('color', '#F44336');
|
||||
$(this).css('text-decoration', 'line-through');
|
||||
$(this).css('font-weight', 'normal');
|
||||
$(this).css('color', '#F44336').css('text-decoration', 'line-through').css('font-weight', 'normal');
|
||||
});
|
||||
} else {
|
||||
$(thisForm).find('td').each(function () {
|
||||
$(this).css('color', 'black');
|
||||
$(this).css('text-decoration', 'none');
|
||||
$(this).css('font-weight', 'normal');
|
||||
$(this).css('color', 'black').css('text-decoration', 'none').css('font-weight', 'normal');
|
||||
});
|
||||
}
|
||||
if (response.alreadyContains) {
|
||||
$(thisForm).find('td').each(function () {
|
||||
$(this).css('color', '#4CAF50');
|
||||
$(this).css('text-decoration', 'none');
|
||||
$(this).css('font-weight', 'bold');
|
||||
$(this).css('color', '#4CAF50').css('text-decoration', 'none').css('font-weight', 'bold');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,12 +88,18 @@ $(document).ready(function () {
|
||||
$(this).find("#listMoreInfo").click(function () {
|
||||
window.open(courses[$(this).closest("li").attr("id")].link);
|
||||
});
|
||||
$(this).find("#register").click(function () {
|
||||
let status = courses[$(this).closest("li").attr("id")].status;
|
||||
if(status.includes("closed") || status.includes("cancelled")){
|
||||
$(this).find("#register").text("Class Closed").css("background-color","#FF5722");
|
||||
} else{
|
||||
$(this).find("#register").text("Register").css("background-color","#4CAF50").click(function () {
|
||||
let registerlink = courses[$(this).closest("li").attr("id")].registerlink;
|
||||
chrome.tabs.query({currentWindow: true, active: true}, function (tab) {
|
||||
chrome.tabs.update(tab.id, {url: registerlink});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
|
||||
$(this).find("#listRemove").click(function () {
|
||||
var thisForm = this;
|
||||
|
||||
Reference in New Issue
Block a user