diff --git a/css/popup.css b/css/popup.css
index 8fde24d8..0bc9148a 100644
--- a/css/popup.css
+++ b/css/popup.css
@@ -35,6 +35,8 @@ body {
bottom: 0;
right: 0;
float: right;
+ display: flex;
+ vertical-align: middle;
margin-right: 5px;
}
.matbut {
@@ -148,4 +150,19 @@ body {
.card:focus:not(:active)::after {
animation: ripple 1s ease-out;
+}
+
+input[type=number]{
+ width: 80px;
+ font-weight: bold;
+}
+::placeholder{
+
+};
+input[type=number]::-webkit-inner-spin-button,
+input[type=number]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ margin: 0;
}
\ No newline at end of file
diff --git a/css/styles.css b/css/styles.css
index b0755001..c67e454e 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -35,6 +35,7 @@
font-size: x-large;
font-weight: bold;
padding-top: 5px;
+ line-height: 1;
padding-left: 5px;
margin: 5px 0px 5px 0px;
}
@@ -49,7 +50,7 @@
margin-left: 5px;
padding-bottom: 5px;
font-size: medium;
- margin-top: 10px;
+ margin-top: 5px;
}
.dateTimePlace {
diff --git a/js/background.js b/js/background.js
index c8c44d96..b0c2f29d 100644
--- a/js/background.js
+++ b/js/background.js
@@ -1,40 +1,41 @@
/* Handle messages and their commands from content and popup scripts*/
chrome.runtime.onMessage.addListener(function (request, sender, response) {
- if (request.command == "courseStorage") {
- if (request.action == "add") {
- add(request, sender, response);
- }
- if (request.action == "remove") {
- remove(request, sender, response);
- }
- } else if (request.command == "isSingleConflict") {
- isSingleConflict(request.dtarr, request.unique, response);
- } else if (request.command == "checkConflicts") {
- checkConflicts(response);
- } else if (request.command == "updateStatus") {
- updateStatus();
- } else if (request.command == "alreadyContains") {
- alreadyContains(request.unique, response);
- } else if (request.command == "updateTabs") {
- updateTabs();
- } else if(request.command == "updateCourseList"){
- chrome.tabs.query({}, function (tabs) {
- for (var i = 0; i < tabs.length; i++) {
- chrome.tabs.sendMessage(tabs[i].id, {
- command: "updateCourseList"
- });
+
+ switch(request.command){
+ case "courseStorage":
+ if (request.action == "add") {
+ add(request, sender, response);
}
- });
- } else {
- const xhr = new XMLHttpRequest();
- const method = request.method ? request.method.toUpperCase() : "GET";
- xhr.open(method, request.url, true);
- xhr.onload = () => response(xhr.responseText);
- xhr.onerror = () => response(xhr.statusText);
- if (method == "POST") {
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- }
- xhr.send(request.data);
+ if (request.action == "remove") {
+ remove(request, sender, response);
+ }
+ break;
+ case "isSingleConflict":
+ isSingleConflict(request.dtarr, request.unique, response);
+ break;
+ case "checkConflicts":
+ checkConflicts(response);
+ break;
+ case "updateStatus":
+ updateStatus();
+ break;
+ case "alreadyContains":
+ alreadyContains(request.unique, response);
+ break;
+ case "updateCourseList":
+ updateTabs();
+ break;
+ default:
+ const xhr = new XMLHttpRequest();
+ const method = request.method ? request.method.toUpperCase() : "GET";
+ xhr.open(method, request.url, true);
+ xhr.onload = () => response(xhr.responseText);
+ xhr.onerror = () => response(xhr.statusText);
+ if (method == "POST") {
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+ xhr.send(request.data);
+ break;
}
return true;
});
diff --git a/js/import.js b/js/import.js
index 52b86a39..fe61fc2d 100644
--- a/js/import.js
+++ b/js/import.js
@@ -65,7 +65,7 @@ function getInfo(classurl) {
action: "add"
}, function () {
chrome.runtime.sendMessage({
- command: "updateTabs"
+ command: "updateCourseList"
});
});
}
diff --git a/js/options.js b/js/options.js
index b25a6d1b..d376f673 100644
--- a/js/options.js
+++ b/js/options.js
@@ -1,3 +1,5 @@
+var manifestData = chrome.runtime.getManifest();
+$("#version").text(manifestData.version);
chrome.storage.sync.get('courseConflictHighlight', function(data) {
if(data.courseConflictHighlight){
off();
diff --git a/js/popup.js b/js/popup.js
index 48d7f3cb..7b766fe0 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -6,9 +6,7 @@ setCourseList();
// var modhtml = '
';
// $("#html").prepend(modhtml);
-var emptyText = ["Doesn't Look Like Anything To Me.", "You Can't Fail Classes You're Not In."];
-$("#main").text(emptyText[Math.floor(Math.random()*emptyText.length)]);
function setCourseList(){
$("#courseList").empty()
chrome.storage.sync.get('savedCourses', function (data) {
@@ -17,9 +15,8 @@ function setCourseList(){
if (courses.length != 0) {
$("#empty").hide();
$("#courseList").show();
-
} else{
- $("#empty").show();
+ showEmpty();
}
// build and append the course list element
for (var i = 0; i < courses.length; i++) {
@@ -44,6 +41,19 @@ function setCourseList(){
});
}
+
+
+function showEmpty(){
+ var emptyText = ["Doesn't Look Like Anything To Me.", "You Can't Fail Classes You're Not In.", "Pro-Tip: Don't Take O-Chem.",
+ "No Work Happens On PCL 5th Floor.", "Sophomore But Freshman By Credit.", "Pain is temporary, GPA is forever.",
+ "You've Yee'd Your Last Haw.","lol everything is already waitlisted.", "At Least You're Not At A&M.",
+ `It's ${moment().format("h:mm")} and OU Still Sucks.`, 'TeXAs iS BaCK GuYZ', "'Academically Challenged'",
+ 'Does McCombs teach Parseltongue?']
+ $("#courseList").hide();
+ $("#empty").fadeIn(200);
+ $("#main").html(emptyText[Math.floor(Math.random()*emptyText.length)]);
+}
+
/* prettify the name for the conflict messages*/
function getSimpleName(coursename, unique) {
var department = coursename.substring(0, coursename.search(/\d/) - 2);
@@ -118,9 +128,7 @@ $(document).ready(function () {
}, function (response) {
$(thisForm).closest("li").fadeOut(200);
if ($(thisForm).closest("ul").children(':visible').length === 1) {
- $("#courseList").fadeOut(300, function () {
- $("#empty").fadeIn(200);
- });
+ showEmpty();
}
updateConflicts();
chrome.tabs.query({}, function (tabs) {
@@ -154,29 +162,28 @@ $(document).ready(function () {
$("#impexp").click(function(){
if($("#impexp>i").text() == 'close'){
- $(".settings").find('#import').remove();
- $(".settings").find('#export').remove();
+ $('#import').hide();
+ $('#export').hide();
$("#impexp>i").text('import_export');
} else{
$("#impexp>i").text('close');
- $(".settings").prepend(`
-
-
- `);
+ $('#import').show();
+ $('#export').show();
}
- })
- $(".settings").on('click', '#import', function () {
+ });
+ $("#search").click(function(){
+ if($("#search>i").text() == 'close'){
+ $("#search>i").text('search');
+ $("#class_id").hide();
+ } else{
+ $("#search>i").text('close');
+ $("#class_id").show();
+ }
+ });
+ $('#import').click(function () {
$("#importOrig").click();
});
- $(".settings").on('click', '#export',function () {
+ $('#export').click(function () {
chrome.storage.sync.get('savedCourses', function (data) {
var exportArray = JSON.stringify(data.savedCourses, null, 4);
var exportlink = document.createElement('a');
@@ -186,6 +193,18 @@ $(document).ready(function () {
exportlink.click();
});
});
+ $("#class_id").on("keyup", function(e){
+ if(e.keyCode == 13){
+ var unique = $(this).val();
+ if(!isNaN(unique)){
+ if(unique.length == 5){
+ getInfo("20192", unique);
+ return;
+ }
+ }
+ alert("Invalid Input");
+ }
+ })
$("#open").click(function () {
chrome.tabs.create({
'url': "options.html"
@@ -198,6 +217,7 @@ $(document).ready(function () {
});
});
+
$("#importOrig").change(function(e){
var files = e.target.files;
var reader = new FileReader();
@@ -216,7 +236,7 @@ $("#importOrig").change(function(e){
});
}
});
- setCourseList(impCourses);
+ setCourseList();
}
} catch(err){
@@ -314,7 +334,90 @@ function clear() {
});
$("#courseList").empty()
console.log("cleared");
- $("#courseList").fadeOut(300, function () {
- $("#empty").fadeIn(200);
- });
-}
\ No newline at end of file
+ showEmpty();
+}
+
+
+/*Course object for passing to background*/
+function Course(coursename, unique, profname, datetimearr, status, link, registerlink) {
+ this.coursename = coursename;
+ this.unique = unique;
+ this.profname = profname;
+ this.datetimearr = datetimearr;
+ this.status = status;
+ this.link = link;
+ this.registerlink = registerlink;
+}
+
+
+function getInfo(sem, unique) {
+ var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", link, false);
+ xhr.send();
+ var response = xhr.responseText;
+ if (response) {
+ var output = "";
+ var object = $('').html(response).contents();
+ var c = getCourseObject(object, link);
+ console.log(c);
+ chrome.runtime.sendMessage({
+ command: "courseStorage",
+ course: c,
+ action: "add"
+ }, function () {
+ chrome.runtime.sendMessage({
+ command: "updateCourseList"
+ });
+ setCourseList();
+ });
+ }
+}
+
+
+/*For a row, get all the course information and add the date-time-lines*/
+function getCourseObject(object, link) {
+ let coursename = object.find("#details h2").text();
+ let uniquenum = object.find('td[data-th="Unique"]').text();
+ let profname = object.find("td[data-th='Instructor']").text().split(', ')[0];
+ if (profname.indexOf(" ") == 0) {
+ profname = profname.substring(1);
+ }
+ let datetimearr = getDtarr(object);
+ let status = object.find('td[data-th="Status"]').text();
+ let indlink = link;
+ let registerlink = object.find('td[data-th="Add"] a').prop('href');
+ return new Course(coursename, uniquenum, profname, datetimearr, status, indlink, registerlink);
+}
+
+/* For a row, get the date-time-array for checking conflicts*/
+function getDtarr(object) {
+ var numlines = object.find('td[data-th="Days"]>span').length;
+ var dtarr = [];
+ for (var i = 0; i < numlines; i++) {
+ var date = object.find('td[data-th="Days"]>span:eq(' + i + ')').text();
+ var time = object.find('td[data-th="Hour"]>span:eq(' + i + ')').text();
+ var place = object.find('td[data-th="Room"]>span:eq(' + i + ')').text();
+ for (var j = 0; j < date.length; j++) {
+ var letter = date.charAt(j);
+ var day = "";
+ if (letter == "T" && j < date.length - 1 && date.charAt(j + 1) == "H") {
+ dtarr.push(["TH", convertTime(time), place]);
+ } else {
+ if (letter != "H") {
+ dtarr.push([letter, convertTime(time), place]);
+ }
+ }
+ }
+ }
+ return dtarr;
+}
+
+/*Convert time to 24hour format*/
+function convertTime(time) {
+ var converted = time.replace(/\./g, '').split("-");
+ for (var i = 0; i < 2; i++) {
+ converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm");
+ }
+ return converted;
+}
diff --git a/manifest.json b/manifest.json
index 34705367..41ab3aed 100644
--- a/manifest.json
+++ b/manifest.json
@@ -20,13 +20,12 @@
"js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/import.js"],
"matches": ["https://utdirect.utexas.edu/registrar/waitlist/wl_see_my_waitlists.WBX", "https://utdirect.utexas.edu/registration/classlist.WBX*"]
}
-
],
"web_accessible_resources": [
"grades.db", "images/disticon.png"
],
"background": {
- "scripts": ["js/background.js"],
+ "scripts": ["js/background.js", "js/moment.min.js", "js/jquery-3.3.1.min.js"],
"persistent": true
},
"browser_action": {
diff --git a/options.html b/options.html
index ad10a216..31c561d9 100644
--- a/options.html
+++ b/options.html
@@ -10,7 +10,7 @@
Conflict Highlighting
- Made by Sriram Hariharan, 2018
+
(v), Sriram Hariharan, 2018