Sql working

This commit is contained in:
10001shh
2018-07-03 17:16:07 -05:00
parent 330bdc89b0
commit 4f31b3e963
5 changed files with 88 additions and 6 deletions

12
background.js Normal file
View File

@@ -0,0 +1,12 @@
chrome.runtime.onMessage.addListener(function(request, sender, response) {
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);
return true;
});

View File

@@ -1,4 +1,11 @@
$(document).ready( function() {
sql = window.SQL;
loadBinaryFile('grades.db', function(data){
var sqldb = new SQL.Database(data);
// Database is ready
var res = sqldb.exec("SELECT * from agg where dept like '%C S%' and course_nbr like '%314%'");
console.log(res[0].values);
});
$("table thead th:nth-child(5)").after('<th scope=col>Rating</th>');
$('table').find('tr').each(function(){
var rating;
@@ -9,17 +16,44 @@ $(document).ready( function() {
rating = "No Prof :(";
} else {
console.log(profurl);
//getProfessorTID();
//getProfessorFullName(profurl);
console.log(profname);
// console.log(lastname[0]);
rating = "Hello";
}
$(this).find('td').eq(4).after('<td data-th="Rating"><a href="http://example.com">'+rating+'</a></td>');
});
});
function loadBinaryFile(path,success) {
var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL(path), true);
xhr.responseType = "arraybuffer";
xhr.onload = function() {
var data = new Uint8Array(xhr.response);
var arr = new Array();
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
success(arr.join(""));
};
xhr.send();
};
// function getProfessorTID(profname) {
// var name = profname.split(',');
// var lastname = profname[0];
// var firstinit = profname[1].substring(1);
// console.log(lastname + " "+firstinit);
function getProfessorFullName(profurl){
}
// return new Promise((resolve, reject) => {
// chrome.runtime.sendMessage({
// method: "POST",
// url: "http://www.ratemyprofessors.com/search.jsp",
// data: "queryBy=teacherName&schoolName=university+of+texas+at+austin&query="+profname+"&facetSearch=true"
// }, function(response) {
// if (response) {
// console.log(response);
// }
// });
// });
// }
//http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university of texas at austin&query="+url+"&facetSearch=true"

BIN
grades.db Normal file

Binary file not shown.

View File

@@ -5,11 +5,19 @@
"version": "0.1.0",
"description": "Chrome Extension to show more information on the UT Course catalog",
"permissions": [
"https://utdirect.utexas.edu/apps/registrar/course_schedule/*",
"*://*.ratemyprofessors.com/*"
],
"content_scripts": [{
"css": ["styles.css"],
"js": ["jquery-3.3.1.min.js","content.js"],
"js": ["sql.js","jquery-3.3.1.min.js","content.js"],
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
}]
}],
"web_accessible_resources": [
"grades.db"],
"background": {
"scripts": ["background.js"],
"persistent": true
}
}

28
sql.js Normal file

File diff suppressed because one or more lines are too long