fixed conflicts error and smoothed animation

This commit is contained in:
Sriram Hariharan
2019-01-12 01:04:24 -06:00
parent 3adbb95744
commit 8e747290a8

View File

@@ -6,6 +6,7 @@ setCourseList();
// var modhtml = '<div class=modal id=myModal><div class=modal-content><span class=close>×</span><div class=card><div class=cardcontainer></div></div></div></div>'; // var modhtml = '<div class=modal id=myModal><div class=modal-content><span class=close>×</span><div class=card><div class=cardcontainer></div></div></div></div>';
// $("#html").prepend(modhtml); // $("#html").prepend(modhtml);
getSemesters(); getSemesters();
var canremove = true;
function setCourseList() { function setCourseList() {
$("#courseList").empty() $("#courseList").empty()
@@ -106,7 +107,7 @@ function updateConflicts() {
text += "<br>"; text += "<br>";
} }
} }
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px 5px 5px 10px'>" + text + "</>"); $("#courseList").prepend("<p id='conflict' style='font-size:small; font-weight:bold; color:red; margin:5px 5px 5px 10px'>" + text + "</>");
} }
}); });
} }
@@ -141,25 +142,31 @@ $(document).ready(function () {
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/ /* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
$(this).find("#listRemove").click(function () { $(this).find("#listRemove").click(function () {
var thisForm = this; var thisForm = this;
$(thisForm).closest("ul").find(">p").remove(); if (canremove) {
chrome.runtime.sendMessage({ canremove = false;
command: "courseStorage", $(thisForm).closest("ul").find("#conflict").remove();
course: courses[$(thisForm).closest("li").attr("id")], chrome.runtime.sendMessage({
action: "remove" command: "courseStorage",
}, function (response) { course: courses[$(thisForm).closest("li").attr("id")],
$(thisForm).closest("li").fadeOut(200); action: "remove"
if ($(thisForm).closest("ul").children(':visible').length === 1) { }, function (response) {
showEmpty(); $(thisForm).closest("li").fadeOut(200);
} if ($(thisForm).closest("ul").children(':visible').length === 1) {
updateConflicts(); showEmpty();
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, {
command: "updateCourseList"
});
} }
canremove = true;
console.log('computedconflicts');
updateConflicts();
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, {
command: "updateCourseList"
});
}
});
}); });
}); }
}); });
/* 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")) {
@@ -223,7 +230,7 @@ $(document).ready(function () {
exportlink.setAttribute('download', 'my_courses.json'); exportlink.setAttribute('download', 'my_courses.json');
exportlink.click(); exportlink.click();
} else { } else {
alert('You have no Saved Courses to export.'); alert('No Saved Courses to Export.');
} }
}); });
}); });