diff --git a/css/popup.css b/css/popup.css
index 4507d85b..8fde24d8 100644
--- a/css/popup.css
+++ b/css/popup.css
@@ -26,14 +26,17 @@ body {
}
.settingsbut {
+ margin-right: 0px;
+ border: 0px
+}
+
+.settings {
position: absolute;
bottom: 0;
right: 0;
float: right;
margin-right: 5px;
- border: 0px
}
-
.matbut {
border: none;
outline: none;
@@ -88,6 +91,40 @@ body {
transform-origin: 50% 50%;
}
+.modal {
+ display: none;
+ position: fixed;
+ z-index: 1;
+ padding-top: 100px;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgb(0, 0, 0);
+ background-color: rgba(0, 0, 0, 0.4);
+}
+
+.modal-content {
+ background-color: #fefefe;
+ margin: auto;
+ max-height: 85%;
+ overflow-y: auto;
+ padding: 20px;
+ border: 1px solid #888;
+ width: 50%;
+}
+
+/* The Close Button */
+
+.close {
+ color: #aaaaaa;
+ float: right;
+ padding: 5px;
+ font-size: 28px;
+ font-weight: bold;
+}
+
+
@keyframes ripple {
0% {
transform: scale(0, 0);
diff --git a/js/popup.js b/js/popup.js
index 6a9ebb8e..56eb7960 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -1,50 +1,45 @@
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) {
- var isConflicted = [];
- if (response.isConflict) {
- var between = response.between;
- var text = "";
- for (var i = 0; i < between.length; i++) {
- text += "CONFLICT: " + getSimpleName(between[i][0].coursename, between[i][0].unique) + " and " + getSimpleName(between[i][1].coursename, between[i][1].unique);
- isConflicted.push(between[i][0].unique);
- isConflicted.push(between[i][1].unique);
- if (i != between.length - 1) {
- text += "
";
- }
+
+setCourseList();
+
+ // var modhtml = '
';
+ // $("#html").prepend(modhtml);
+
+function setCourseList(){
+ $("#courseList").empty()
+ chrome.storage.sync.get('savedCourses', function (data) {
+ updateConflicts();
+ courses = data.savedCourses
+ if (courses.length != 0) {
+ $("#empty").hide();
+ $("#courseList").show();
+
+ } else{
+ $("#empty").show();
+ }
+ // build and append the course list element
+ for (var i = 0; i < courses.length; i++) {
+ var color;
+ status = courses[i].status;
+ if (status.includes("open")) {
+ color = "#4CAF50";
+ } else if (status.includes("waitlisted")) {
+ color = "#FF9800"
+ } else if (status.includes("closed") || status.includes("cancelled")) {
+ color = "#FF5722";
}
- $("#courseList").prepend("" + text + ">");
+ var department = courses[i].coursename.substring(0, courses[i].coursename.search(/\d/) - 2);
+ var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/), courses[i].coursename.indexOf(" ", courses[i].coursename.search(/\d/)));
+ var profname = prettifyName(courses[i].profname);
+ if (profname == "") {
+ profname = "Undecided Professor";
+ }
+ var listhtml = "
" + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "
►
" + makeLine(i) + "
";
+ $("#courseList").append(listhtml);
}
});
- courses = data.savedCourses;
- if (courses.length != 0) {
- $("#empty").hide();
- }
- // build and append the course list element
- for (var i = 0; i < courses.length; i++) {
- var color;
- status = courses[i].status;
- if (status.includes("open")) {
- color = "#4CAF50";
- } else if (status.includes("waitlisted")) {
- color = "#FF9800"
- } else if (status.includes("closed") || status.includes("cancelled")) {
- color = "#FF5722";
- }
- var department = courses[i].coursename.substring(0, courses[i].coursename.search(/\d/) - 2);
- var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/), courses[i].coursename.indexOf(" ", courses[i].coursename.search(/\d/)));
- var profname = prettifyName(courses[i].profname);
- if (profname == "") {
- profname = "Undecided Professor";
- }
- var listhtml = "" + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "
►
" + makeLine(i) + "
";
- $("#courseList").append(listhtml);
- }
-});
+}
/* prettify the name for the conflict messages*/
function getSimpleName(coursename, unique) {
@@ -84,7 +79,7 @@ function updateConflicts() {
/* Handle the button clicks */
$(document).ready(function () {
- $("#courseList li").click(function () {
+ $("#courseList").on('click', 'li', function () {
$(this).find("#listMoreInfo").click(function () {
window.open(courses[$(this).closest("li").attr("id")].link);
});
@@ -153,6 +148,41 @@ $(document).ready(function () {
'url': 'https://registrar.utexas.edu/schedules'
});
});
+
+ $("#impexp").click(function(){
+ if($("#impexp>i").text() == 'close'){
+ $(".settings").find('#import').remove();
+ $(".settings").find('#export').remove();
+ $("#impexp>i").text('import_export');
+ } else{
+ $("#impexp>i").text('close');
+ $(".settings").prepend(`
+
+
+ `);
+ }
+ })
+ $(".settings").on('click', '#import', function () {
+ $("#importOrig").click();
+ });
+ $(".settings").on('click', '#export',function () {
+ chrome.storage.sync.get('savedCourses', function (data) {
+ var exportArray = JSON.stringify(data.savedCourses, null, 4);
+ var exportlink = document.createElement('a');
+ var url = window.URL.createObjectURL(new Blob([exportArray], {type: "octet/stream"}));
+ exportlink.setAttribute('href', url);
+ exportlink.setAttribute('download', 'my_courses.json' );
+ exportlink.click();
+ });
+ });
$("#open").click(function () {
chrome.tabs.create({
'url': "options.html"
@@ -165,6 +195,46 @@ $(document).ready(function () {
});
});
+$("#importOrig").change(function(e){
+ var files = e.target.files;
+ var reader = new FileReader();
+ reader.onload = function(){
+ try{
+ var impCourses = JSON.parse(this.result);
+ console.log(impCourses);
+ if(impCourses && impCourses.length && (impCourses.length == 0 || validateObject(impCourses))){
+ chrome.storage.sync.set({
+ savedCourses: impCourses
+ });
+ chrome.tabs.query({}, function (tabs) {
+ for (var i = 0; i < tabs.length; i++) {
+ chrome.tabs.sendMessage(tabs[i].id, {
+ command: "updateCourseList"
+ });
+ }
+ });
+ setCourseList(impCourses);
+ }
+ } catch(err){
+
+ }
+ importOrig.value = ''; //make sure to clear input value after every import
+ }
+ reader.readAsText(files[0]);
+});
+
+function validateObject(impCourses){
+ for(var i = 0; i(No Courses Saved)
-