cleaned up some code
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
||||
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function (request, sender, sendResponse) {
|
||||
console.log(sender.tab ?
|
||||
"from a content script:" + sender.tab.url :
|
||||
"from the extension");
|
||||
if (request.greeting == "hello")
|
||||
sendResponse({ farewell: "goodbye" });
|
||||
});
|
||||
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;
|
||||
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;
|
||||
});
|
||||
|
||||
|
||||
chrome.runtime.onInstalled.addListener(function() {
|
||||
chrome.storage.sync.set({color: '#3aa757'}, function() {
|
||||
console.log("The color is green.");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
33
content.js
33
content.js
@@ -11,7 +11,7 @@ var description;
|
||||
$(document).ready( function() {
|
||||
loadDataBase();
|
||||
//make heading
|
||||
$("table thead th:nth-child(8)").after('<th scope=col>Dist</th>');
|
||||
$("table thead th:nth-child(9)").after('<th scope=col>Dist</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>Computer Fluency (C S 302)</h2><h2 class=profname>with Bruce Porter</h2><div class=topbuttons><button class=matbut id="rateMyProf"> RMP </button><button class=matbut id="eCIS"> eCIS </button><button class=matbut id="saveCourse"> Save Course </button></div></div></div><div class=card><div class=cardcontainer><h2 class=description></h2></div></div><div class=card><div class=cardcontainer><div id=chart></div></div></div></div>'
|
||||
$("#container").prepend(modhtml);
|
||||
//console.log(grades);
|
||||
@@ -21,7 +21,8 @@ $(document).ready( function() {
|
||||
|
||||
} else if($(this).has('th').length == 0){
|
||||
var rating;
|
||||
var profname = $(this).find('td').eq(4).text() + "";
|
||||
var profname = $(this).find('td[data-th="Instructor"]').text() + "";
|
||||
console.log(profname);
|
||||
if(profname == ""){
|
||||
//console.log("No Professor");
|
||||
rating = "No Prof :(";
|
||||
@@ -32,15 +33,17 @@ $(document).ready( function() {
|
||||
$(this).append('<td data-th="Dist"><input type="image" class="distButton" style="vertical-align: bottom;" width="30" height="30" src='+chrome.extension.getURL('disticon.png')+' /></td>');
|
||||
}
|
||||
});
|
||||
$(this).find(".distButton").click(function(){
|
||||
//var coursename = $(this).closest(':has(.course_header)').find('.course_header');
|
||||
//CLEAN UP, "gack"- Michael Scott
|
||||
$(".distButton").click(function(){
|
||||
var row = $(this).closest('tr');
|
||||
getCourseInfo(row);
|
||||
//console.log(profname + " "+department+" "+course_nbr);
|
||||
//console.log(coursename);
|
||||
getDistribution();
|
||||
});
|
||||
$("#saveCourse").click(function(){
|
||||
|
||||
});
|
||||
$("#rateMyProf").click(function(){
|
||||
window.open(rmpLink);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -50,9 +53,11 @@ function getCourseInfo(row){
|
||||
coursename = $(this).find('td').text() + "";
|
||||
}
|
||||
if($(this).is(row)){
|
||||
profurl = $(this).find('td a').prop('href');
|
||||
profname = $(this).find('td').eq(4).text().split(', ')[0];
|
||||
profinit = $(this).find('td').eq(4).text().split(',')[1];
|
||||
profurl = $(this).find('td[data-th="Unique"] a').prop('href');
|
||||
profname = $(this).find('td[data-th="Instructor"]').text().split(', ')[0];
|
||||
profinit = $(this).find('td[data-th="Instructor"]').text().split(',')[1];
|
||||
//COME BACK AND FINISH
|
||||
console.log($(this).find('td[data-th="Days"] >span').text());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -101,12 +106,6 @@ function openDialog(dep,cls,sem,professor,res){
|
||||
span.onclick = function() {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
$("#saveCourse").click(function(){
|
||||
|
||||
});
|
||||
$("#rateMyProf").click(function(){
|
||||
window.open(rmpLink);
|
||||
});
|
||||
chart = Highcharts.chart('chart', {
|
||||
chart: {
|
||||
type: 'column',
|
||||
@@ -212,7 +211,7 @@ function getDescription(){
|
||||
$(".description").animate({'opacity': 0}, 400, function(){
|
||||
$(this).html(description).animate({'opacity': 1}, 300);
|
||||
});
|
||||
var first = object.find('td').eq(4).text();
|
||||
var first = object.find('td[data-th="Instructor"]').text();
|
||||
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2));
|
||||
first = first.substring(2);
|
||||
rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query="+first+" "+profname+";&facetSearch=true";
|
||||
|
||||
BIN
icons/icon128.png
Normal file
BIN
icons/icon128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
icons/icon16.png
Normal file
BIN
icons/icon16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
icons/icon32.png
Normal file
BIN
icons/icon32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
icons/icon48.png
Normal file
BIN
icons/icon48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
|
||||
|
||||
"name": "UT Course Extension",
|
||||
"version": "0.1.0",
|
||||
"description": "Chrome Extension to show more information on the UT Course catalog",
|
||||
"permissions": [
|
||||
"declarativeContent",
|
||||
"storage",
|
||||
"*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*",
|
||||
"*://*.ratemyprofessors.com/*",
|
||||
"*://*.catalog.utexas.edu/ribbit/"
|
||||
],
|
||||
"*://*.ratemyprofessors.com/*",
|
||||
"*://*.catalog.utexas.edu/ribbit/"
|
||||
],
|
||||
"content_scripts": [{
|
||||
"css": ["styles.css"],
|
||||
"js": ["sql-memory-growth.js","highcharts.js","jquery-3.3.1.min.js","content.js"],
|
||||
@@ -16,9 +18,23 @@
|
||||
}],
|
||||
"web_accessible_resources": [
|
||||
"grades.db","disticon.png"],
|
||||
"background": {
|
||||
"background": {
|
||||
"scripts": ["background.js"],
|
||||
"persistent": true
|
||||
|
||||
},
|
||||
"browser_action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "icons/icon16.png",
|
||||
"32": "icons/icon32.png",
|
||||
"48": "icons/icon48.png",
|
||||
"128": "icons/icon128.png"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"16": "icons/icon16.png",
|
||||
"32": "icons/icon32.png",
|
||||
"48": "icons/icon48.png",
|
||||
"128": "icons/icon128.png"
|
||||
}
|
||||
}
|
||||
15
popup.html
Normal file
15
popup.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
button {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="changeColor"></button>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user