From cac80ea94ed51973a27c8cd9645218c472a3f55e Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Wed, 2 Jan 2019 13:56:13 -0600 Subject: [PATCH] minor changes --- js/content.js | 15 ++++++- js/popup.js | 108 ++++++++++++++++++++++++++------------------------ todo | 2 +- 3 files changed, 71 insertions(+), 54 deletions(-) diff --git a/js/content.js b/js/content.js index 3e921aff..b7da9883 100644 --- a/js/content.js +++ b/js/content.js @@ -72,6 +72,11 @@ $(function () { if (!($(this).find('td').hasClass("course_header")) && $(this).has('th').length == 0) { //if a course row, then add the extension button $(this).append(``); + // if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) { + // $(this).find('td').each(function () { + // $(this).css('background-color', '#E0E0E0'); + // }); + // } } }); } @@ -151,12 +156,19 @@ function loadNextPages(inHTML) { nextpage.find('tbody>tr').each(function () { if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) { $(this).append(``); + // if ($(this).find('td[data-th="Status"]').text().includes('waitlisted')) { + // $(this).find('td').each(function () { + // $(this).css('background-color', '#E0E0E0'); + // }); + // } } current.append($(this)); }); loadNextPages(response); } }) + } else { + update(); } } @@ -377,7 +389,7 @@ function getDistribution(sem) { /*Open the modal and show all the data*/ function openDialog(dep, cls, sem, professor, res) { - $("#myModal").scrollTop(0); + $("#myModal").fadeIn(fadetime); //initial text on the "save course button" @@ -560,6 +572,7 @@ function setChart(data) { chart.renderer.text('Could not find data for this Instructor teaching this Course.', 100, 120) .css({ fontSize: '20px', + width: '300px', align: 'center', left: '160px' }) diff --git a/js/popup.js b/js/popup.js index 22b915d2..de657e34 100644 --- a/js/popup.js +++ b/js/popup.js @@ -3,20 +3,21 @@ var courses; setCourseList(); - // var modhtml = ''; - // $("#html").prepend(modhtml); +// var modhtml = ''; +// $("#html").prepend(modhtml); getSemesters(); -function setCourseList(){ +function setCourseList() { $("#courseList").empty() chrome.storage.sync.get('savedCourses', function (data) { updateConflicts(); courses = data.savedCourses + console.log(courses.length); if (courses.length != 0) { $("#empty").hide(); $("#courseList").show(); - } else{ + } else { showEmpty(); } // build and append the course list element @@ -44,15 +45,16 @@ function setCourseList(){ -function showEmpty(){ +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?'] + "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)]); + $("#main").html(emptyText[Math.floor(Math.random() * emptyText.length)]); } /* prettify the name for the conflict messages*/ @@ -161,24 +163,24 @@ $(document).ready(function () { }); }); - $("#impexp").click(function(){ - if($("#impexp>i").text() == 'close'){ + $("#impexp").click(function () { + if ($("#impexp>i").text() == 'close') { $('#import').hide(); $('#export').hide(); $("#impexp>i").text('import_export'); - } else{ + } else { $("#impexp>i").text('close'); $('#import').show(); $('#export').show(); } }); - $("#search").click(function(){ - if($("#search>i").text() == 'close') { + $("#search").click(function () { + if ($("#search>i").text() == 'close') { $("#search>i").text('search'); $("#class_id").hide(); $("#semcon").hide(); $("#semesters").hide(); - } else{ + } else { $("#search>i").text('close'); $("#class_id").show(); $("#semesters").show(); @@ -193,17 +195,19 @@ $(document).ready(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"})); + var url = window.URL.createObjectURL(new Blob([exportArray], { + type: "octet/stream" + })); exportlink.setAttribute('href', url); - exportlink.setAttribute('download', 'my_courses.json' ); - exportlink.click(); + exportlink.setAttribute('download', 'my_courses.json'); + exportlink.click(); }); }); - $("#class_id").on("keyup", function(e){ - if(e.keyCode == 13){ + $("#class_id").on("keyup", function (e) { + if (e.keyCode == 13) { var unique = $(this).val(); - if(!isNaN(unique)){ - if(unique.length == 5){ + if (!isNaN(unique)) { + if (unique.length == 5) { getInfo($("#semesters").find(":selected").val(), unique); return; } @@ -224,14 +228,14 @@ $(document).ready(function () { }); -$("#importOrig").change(function(e){ +$("#importOrig").change(function (e) { var files = e.target.files; var reader = new FileReader(); - reader.onload = function(){ - try{ + reader.onload = function () { + try { var impCourses = JSON.parse(this.result); console.log(impCourses); - if(impCourses && impCourses.length && (impCourses.length == 0 || validateObject(impCourses))){ + if (impCourses && impCourses.length && (impCourses.length == 0 || validateObject(impCourses))) { chrome.storage.sync.set({ savedCourses: impCourses }); @@ -244,20 +248,20 @@ $("#importOrig").change(function(e){ }); setCourseList(); } - } catch(err){ + } catch (err) { } importOrig.value = ''; //make sure to clear input value after every import - } - reader.readAsText(files[0]); -}); + } + reader.readAsText(files[0]); +}); -function validateObject(impCourses){ - for(var i = 0; i').html(response).contents(); object.find('.callout2>ul>li>a').each(function () { - if($(this).text() != "Course Schedule Archive"){ - var semname = $(this).text().split(" ")[0].substring(0,2)+" " +$(this).text().split(" ")[1]; + if ($(this).text() != "Course Schedule Archive") { + var semname = $(this).text().split(" ")[0].substring(0, 2) + " " + $(this).text().split(" ")[1]; chrome.runtime.sendMessage({ - method: "GET", - action: "xhttp", - url: $(this).attr('href'), - data: "" - }, function (response) { - if (response) { - var object = $('
').html(response).contents(); - object.find('.gobutton>a').each(function () { - var semnum = $(this).attr('href').substring($(this).attr('href').lastIndexOf('/')+1); - $("#semesters").append(``); - }); - } - }); + method: "GET", + action: "xhttp", + url: $(this).attr('href'), + data: "" + }, function (response) { + if (response) { + var object = $('
').html(response).contents(); + object.find('.gobutton>a').each(function () { + var semnum = $(this).attr('href').substring($(this).attr('href').lastIndexOf('/') + 1); + $("#semesters").append(``); + }); + } + }); } }); } @@ -400,7 +404,7 @@ function getInfo(sem, unique) { var object = $('
').html(response).contents(); var c = getCourseObject(object, link); console.log(c); - if(c.coursename){ + if (c.coursename) { chrome.runtime.sendMessage({ command: "courseStorage", course: c, @@ -463,4 +467,4 @@ function convertTime(time) { converted[i] = moment(converted[i], ["h:mm A"]).format("HH:mm"); } return converted; -} +} \ No newline at end of file diff --git a/todo b/todo index 98cb0e9c..bd6c1bc7 100644 --- a/todo +++ b/todo @@ -3,7 +3,6 @@ TODO as of 12/11/18 FEATURES: - work on UT Planner - work on multiple schedules -- all semester's grade distribution - polish - clean upcalendar export and add more options to screen - maybe show how many people have a class in their cart @@ -23,6 +22,7 @@ DONE/FIXED: - Location in popup extra info - Export calendar format - import courses from class schedule screen +- all semester's grade distribution - import into and export from UT registration plus - Showing the icon on the flags pages - Easter egg, no course messages