added semesters column to db

This commit is contained in:
Sriram Hariharan
2018-12-30 15:40:36 -06:00
parent 1b50d2d5a9
commit 1a7d334cf5
3 changed files with 63 additions and 11 deletions

BIN
grades.db

Binary file not shown.

View File

@@ -33,9 +33,38 @@ $(function () {
$('[title*="next listing"]').remove(); $('[title*="next listing"]').remove();
loadDataBase(); loadDataBase();
//make heading and modal //make heading and modal
if(!$("#kw_results_table").length){ if (!$("#kw_results_table").length) {
$("table thead th:last-child").after('<th scope=col>Plus</th>'); $("table thead th:last-child").after('<th scope=col>Plus</th>');
var modhtml = '<div class=modal id=myModal><div class=modal-content><span class=close>×</span><div class=card><div class=cardcontainer><h2 class=title id="title">Computer Fluency (C S 302)</h2><h2 class=profname id="profname">with Bruce Porter</h2><div id="topbuttons" class=topbuttons><button class=matbut id="rateMyProf" style="background: #4CAF50;"> RMP </button><button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button><button class=matbut id="textbook" style="background: #FFC107;"> Textbook </button><button class=matbut id="Syllabi"> Past Syllabi </button><button class=matbut id="saveCourse" style="background: #F44336;"> Save Course +</button></div></div></div><div class=card><div class=cardcontainer style=""><ul class=description id="description" style="list-style-type:disc"></ul></div></div><div class=card ><div id="chartcontainer" class=cardcontainer><div id=chart></div></div></div>'; var modhtml = `<div class=modal id=myModal>
<div class=modal-content>
<span class=close>×</span>
<div class=card>
<div class=cardcontainer>
<h2 class=title id="title">Computer Fluency (C S 302)</h2>
<h2 class=profname id="profname">with Bruce Porter</h2>
<div id="topbuttons" class=topbuttons>
<button class=matbut id="rateMyProf" style="background: #4CAF50;"> RMP </button>
<button class=matbut id="eCIS" style="background: #CDDC39;"> eCIS </button>
<button class=matbut id="textbook" style="background: #FFC107;"> Textbook </button>
<button class=matbut id="Syllabi"> Past Syllabi </button>
<button class=matbut id="saveCourse" style="background: #F44336;"> Save Course +</button>
</div>
</div>
</div>
<div class=card>
<div class=cardcontainer style="">
<ul class=description id="description" style="list-style-type:disc"></ul>
</div>
</div>
<div class=card >
<select id="semesters">
</select>
<div id="chartcontainer" class=cardcontainer>
<div id=chart></div>
</div>
</div>
</div>
</div>`;
$("#container").prepend(modhtml); $("#container").prepend(modhtml);
$("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>"); $("#myModal").prepend("<div id='snackbar'>defaultmessage..</div>");
//go through all the rows in the list //go through all the rows in the list
@@ -49,7 +78,7 @@ $(function () {
//update the conflicts //update the conflicts
update(); update();
/*Handle the button clicks*/ /*Handle the button clicks*/
$("tbody").on('click','.distButton',function () { $("tbody").on('click', '.distButton', function () {
var row = $(this).closest('tr'); var row = $(this).closest('tr');
getCourseInfo(row); getCourseInfo(row);
getDistribution(); getDistribution();
@@ -99,18 +128,23 @@ $(function () {
}); });
}); });
function loadNextPages(inHTML){ function loadNextPages(inHTML) {
var html = $('<div/>').html(inHTML).contents(); var html = $('<div/>').html(inHTML).contents();
let next = html.find("#next_nav_link"); let next = html.find("#next_nav_link");
if(next.length){ if (next.length) {
let link = next.prop('href'); let link = next.prop('href');
console.log(link); console.log(link);
chrome.runtime.sendMessage({method: "GET", action: "xhttp", url:link, data:""}, function(response){ chrome.runtime.sendMessage({
if(response){ method: "GET",
action: "xhttp",
url: link,
data: ""
}, function (response) {
if (response) {
var nextpage = $('<div/>').html(response).contents(); var nextpage = $('<div/>').html(response).contents();
var current = $('tbody'); var current = $('tbody');
nextpage.find('tbody>tr').each(function(){ nextpage.find('tbody>tr').each(function () {
if(!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0 )){ if (!($(this).find('td').hasClass("course_header") && $(this).has('th').length == 0)) {
$(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom; display:block;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`); $(this).append(`<td data-th="Plus"><input type="image" class="distButton" id="distButton" style="vertical-align: bottom; display:block;" width="20" height="20" src='${chrome.extension.getURL('images/disticon.png')}'/></td>`);
} }
current.append($(this)); current.append($(this));
@@ -322,6 +356,8 @@ function getDistribution() {
function openDialog(dep, cls, sem, professor, res) { function openDialog(dep, cls, sem, professor, res) {
$("#myModal").fadeIn(fadetime); $("#myModal").fadeIn(fadetime);
//initial text on the "save course button" //initial text on the "save course button"
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
command: "alreadyContains", command: "alreadyContains",
unique: uniquenum unique: uniquenum
@@ -334,9 +370,16 @@ function openDialog(dep, cls, sem, professor, res) {
}); });
//set if no grade distribution //set if no grade distribution
var data; var data;
$("#semesters").empty();
if (typeof res == 'undefined' || profname == "") { if (typeof res == 'undefined' || profname == "") {
data = []; data = [];
$("#semesters").append("<option>No Data</option>")
} else { } else {
var semesters = res.values[0][18].split(",");
semesters.unshift('Aggregate');
for (var i = 0; i < semesters.length; i++) {
$("#semesters").append(`<option>${semesters[i]}</option>`)
}
data = res.values[0]; data = res.values[0];
} }
var modal = document.getElementById('myModal'); var modal = document.getElementById('myModal');

9
todo
View File

@@ -27,3 +27,12 @@ DONE/FIXED:
- Showing the icon on the flags pages - Showing the icon on the flags pages
- Easter egg, no course messages - Easter egg, no course messages
- search by unique number - search by unique number
for FIXING DB:
ALTER TABLE agg ADD semesters
update agg
set semesters = (select group_concat(sem) from grades where agg.prof = grades.prof and agg.course_nbr = grades.course_nbr and agg.dept = grades.dept);