basic message passing
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
||||||
|
if(request.greeting == "hello") {
|
||||||
|
getSaved(request,sender,response);
|
||||||
|
}
|
||||||
|
else{
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
const method = request.method ? request.method.toUpperCase() : "GET";
|
const method = request.method ? request.method.toUpperCase() : "GET";
|
||||||
xhr.open(method, request.url, true);
|
xhr.open(method, request.url, true);
|
||||||
@@ -8,12 +12,14 @@ chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
|||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
}
|
}
|
||||||
xhr.send(request.data);
|
xhr.send(request.data);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.runtime.onInstalled.addListener(function() {
|
|
||||||
chrome.storage.sync.set({color: '#3aa757'}, function() {
|
|
||||||
console.log("The color is green.");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
function getSaved(request, sender, sendResponse) {
|
||||||
|
console.log(sender.tab ?
|
||||||
|
"from a content script:" + sender.tab.url :
|
||||||
|
"from the extension");
|
||||||
|
sendResponse({farewell: "goodbye"});
|
||||||
|
}
|
||||||
21
content.js
21
content.js
@@ -46,6 +46,9 @@ $(document).ready( function() {
|
|||||||
getDistribution();
|
getDistribution();
|
||||||
});
|
});
|
||||||
$("#saveCourse").click(function(){
|
$("#saveCourse").click(function(){
|
||||||
|
chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
|
||||||
|
console.log(response.farewell);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
$("#Syllabi").click(function(){
|
$("#Syllabi").click(function(){
|
||||||
@@ -151,10 +154,6 @@ else{
|
|||||||
}
|
}
|
||||||
var building = place.substring(0,place.search(/\d/)-1);
|
var building = place.substring(0,place.search(/\d/)-1);
|
||||||
return output + " at "+time.replace(/\./g,'').replace(/\-/g,' to ')+" in "+"<a style='font-size:medium' target='_blank' href='"+"https://maps.utexas.edu/buildings/UTM/"+building+"''>"+place.substring(0,place.search(/\d/)-1)+"</>";
|
return output + " at "+time.replace(/\./g,'').replace(/\-/g,' to ')+" in "+"<a style='font-size:medium' target='_blank' href='"+"https://maps.utexas.edu/buildings/UTM/"+building+"''>"+place.substring(0,place.search(/\d/)-1)+"</>";
|
||||||
}
|
|
||||||
|
|
||||||
function order(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
function getDistribution(){
|
function getDistribution(){
|
||||||
var query = "select * from agg";
|
var query = "select * from agg";
|
||||||
@@ -192,7 +191,7 @@ var color = "black";
|
|||||||
else if(status.includes("closed") || status.includes("cancelled")){
|
else if(status.includes("closed") || status.includes("cancelled")){
|
||||||
color = "#F44336";
|
color = "#F44336";
|
||||||
}
|
}
|
||||||
$(".title").append("<span style='color:"+color+";font-size:large;'>"+" #"+uniquenum+"</>");
|
$(".title").append("<span style='color:"+color+";font-size:medium;'>"+" #"+uniquenum+"</>");
|
||||||
var name;
|
var name;
|
||||||
if(profname == ""){
|
if(profname == ""){
|
||||||
name = "Undecided Professor ";
|
name = "Undecided Professor ";
|
||||||
@@ -201,10 +200,10 @@ if(profname == ""){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
name = profname.substring(0,1)+profname.substring(1).toLowerCase();
|
name = profinit+". "+profname.substring(0,1)+profname.substring(1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".profname").html("<h2 class=profname>with "+"<span id=lastname style='font-size: larger;font-weight:medium;'>"+name+"<span/></h2");
|
$(".profname").text("with "+ name);
|
||||||
//console.log(coursename);
|
//console.log(coursename);
|
||||||
span.onclick = function() {
|
span.onclick = function() {
|
||||||
$(".modal").fadeOut(200);
|
$(".modal").fadeOut(200);
|
||||||
@@ -276,6 +275,7 @@ chart = Highcharts.chart('chart', {
|
|||||||
series: [{
|
series: [{
|
||||||
name: 'Grades',
|
name: 'Grades',
|
||||||
data: [{y: data[6], color: '#4CAF50'}, {y: data[7], color: '#8BC34A'}, {y: data[8], color: '#CDDC39'}, {y: data[9], color: '#FFEB3B'}, {y: data[10], color: '#FFC107'}, {y: data[11], color: '#FFA000'}, {y: data[12], color: '#F57C00'}, {y: data[13], color: '#FF5722'}, {y: data[14], color: '#FF5252'}, {y: data[15], color: '#E64A19'}, {y: data[16], color: '#F44336'}, {y: data[17], color: '#D32F2F'}]
|
data: [{y: data[6], color: '#4CAF50'}, {y: data[7], color: '#8BC34A'}, {y: data[8], color: '#CDDC39'}, {y: data[9], color: '#FFEB3B'}, {y: data[10], color: '#FFC107'}, {y: data[11], color: '#FFA000'}, {y: data[12], color: '#F57C00'}, {y: data[13], color: '#FF5722'}, {y: data[14], color: '#FF5252'}, {y: data[15], color: '#E64A19'}, {y: data[16], color: '#F44336'}, {y: data[17], color: '#D32F2F'}]
|
||||||
|
|
||||||
}]
|
}]
|
||||||
}, function(chart) { // on complete
|
}, function(chart) { // on complete
|
||||||
if(data.length == 0){
|
if(data.length == 0){
|
||||||
@@ -338,7 +338,6 @@ chrome.runtime.sendMessage({
|
|||||||
output+=sentence;
|
output+=sentence;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
description = output;
|
description = output;
|
||||||
$(".description").animate({'opacity': 0}, 200, function(){
|
$(".description").animate({'opacity': 0}, 200, function(){
|
||||||
$(this).html(description).animate({'opacity': 1}, 200);
|
$(this).html(description).animate({'opacity': 1}, 200);
|
||||||
@@ -346,17 +345,13 @@ chrome.runtime.sendMessage({
|
|||||||
var first = object.find('td[data-th="Instructor"]').text();
|
var first = object.find('td[data-th="Instructor"]').text();
|
||||||
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2));
|
first = first.substring(first.indexOf(", "),first.indexOf(" ",first.indexOf(", ")+2));
|
||||||
first = first.substring(2);
|
first = first.substring(2);
|
||||||
var prop = [first.substring(0,1)+first.substring(1).toLowerCase(),profname.substring(0,1)+profname.substring(1).toLowerCase()];
|
|
||||||
rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query="+first+" "+profname+";&facetSearch=true";
|
rmpLink = "http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university+of+texas+at+austin&queryoption=HEADER&query="+first+" "+profname+";&facetSearch=true";
|
||||||
if(profname == ""){
|
if(profname == ""){
|
||||||
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept="+department+"&s_in_search_course_num="+course_nbr;
|
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?s_in_action_sw=S&s_in_search_type_sw=C&s_in_max_nbr_return=10&s_in_search_course_dept="+department+"&s_in_search_course_num="+course_nbr;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?&s_in_action_sw=S&s_in_search_type_sw=N&s_in_search_name="+prop[1]+"%2C%20"+prop[0];
|
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?&s_in_action_sw=S&s_in_search_type_sw=N&s_in_search_name="+profname.substring(0,1)+profname.substring(1).toLowerCase()+"%2C%20"+first.substring(0,1)+first.substring(1).toLowerCase();
|
||||||
}
|
}
|
||||||
$("#lastname").animate({'opacity': 0}, 200, function(){
|
|
||||||
$(this).html(prop[0]+" "+prop[1]).animate({'opacity': 1}, 200);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
.profname {
|
.profname {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 0px;
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user