replaced unique search for time being

This commit is contained in:
Sriram Hariharan
2019-07-28 13:38:00 -05:00
parent becb70be12
commit c1cf6dd730
4 changed files with 63 additions and 40 deletions

View File

@@ -32,6 +32,10 @@ const butdelay = 75;
//This extension may be super lit, but you know what's even more lit? //This extension may be super lit, but you know what's even more lit?
//Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann //Matthew Tran's twitter and insta: @MATTHEWTRANN and @matthew.trann
console.log('UT Registration Plus is running on this page.');
var utplanner = false;
if (document.querySelector('#fos_fl')) { if (document.querySelector('#fos_fl')) {
let params = (new URL(document.location)).searchParams; let params = (new URL(document.location)).searchParams;
@@ -44,12 +48,26 @@ if (document.querySelector('#fos_fl')) {
} }
} }
} }
next = $("#next_nav_link"); next = $("#next_nav_link");
chrome.storage.sync.get('loadAll', function (data) { if(next){
if (data.loadAll) { chrome.storage.sync.get('loadAll', function (data) {
$('[title*="next listing"]').remove(); if (data.loadAll) {
} $('[title*="next listing"]').remove();
}); }
});
}
if($('html').hasClass('gr__utexas_collegescheduler_com')){
utplanner = true;
$.initialize("table.section-detail-grid", function() {
$(this).find('thead>tr').append('<th> Plus</th')
$(this).find('tbody>tr').each(function(){
$(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>`);
})
});
}
loadDataBase(); loadDataBase();
//make heading and modal //make heading and modal
@@ -111,7 +129,7 @@ if (!$("#kw_results_table").length) {
//update the conflicts //update the conflicts
update(0); update(0);
/*Handle the button clicks*/ /*Handle the button clicks*/
$("tbody").on('click', '#distButton', function () { $("body").on('click', '#distButton', function () {
var row = $(this).closest('tr'); var row = $(this).closest('tr');
$('.modal-content').stop().animate({ $('.modal-content').stop().animate({
scrollTop: 0 scrollTop: 0
@@ -338,7 +356,7 @@ function Course(coursename, unique, profname, datetimearr, status, link, registe
/*For a row, get all the course information and add the date-time-lines*/ /*For a row, get all the course information and add the date-time-lines*/
function getCourseInfo(row) { function getCourseInfo(row) {
console.log('WHAT'); console.log(row);
semesterCode = new URL(window.location.href).pathname.split('/')[4]; semesterCode = new URL(window.location.href).pathname.split('/')[4];
$("h2.dateTimePlace").remove(); $("h2.dateTimePlace").remove();
$('table').find('tr').each(function () { $('table').find('tr').each(function () {
@@ -789,4 +807,4 @@ function loadBinaryFile(path, success) {
success(arr.join("")); success(arr.join(""));
}; };
xhr.send(); xhr.send();
}; };

1
js/jquery.initialize.min.js vendored Normal file
View File

@@ -0,0 +1 @@
(function($){"use strict";var combinators=[" ",">","+","~"];var fraternisers=["+","~"];var complexTypes=["ATTR","PSEUDO","ID","CLASS"];function grok(msobserver){if(!$.find.tokenize){msobserver.isCombinatorial=true;msobserver.isFraternal=true;msobserver.isComplex=true;return}msobserver.isCombinatorial=false;msobserver.isFraternal=false;msobserver.isComplex=false;var token=$.find.tokenize(msobserver.selector);for(var i=0;i<token.length;i++){for(var j=0;j<token[i].length;j++){if(combinators.indexOf(token[i][j].type)!=-1)msobserver.isCombinatorial=true;if(fraternisers.indexOf(token[i][j].type)!=-1)msobserver.isFraternal=true;if(complexTypes.indexOf(token[i][j].type)!=-1)msobserver.isComplex=true}}}var MutationSelectorObserver=function(selector,callback,options){this.selector=selector.trim();this.callback=callback;this.options=options;grok(this)};var msobservers=[];msobservers.initialize=function(selector,callback,options){var seen=[];var callbackOnce=function(){if(seen.indexOf(this)==-1){seen.push(this);$(this).each(callback)}};$(options.target).find(selector).each(callbackOnce);var msobserver=new MutationSelectorObserver(selector,callbackOnce,options);this.push(msobserver);var observer=new MutationObserver(function(mutations){var matches=[];for(var m=0;m<mutations.length;m++){if(mutations[m].type=="attributes"){if(mutations[m].target.matches(msobserver.selector))matches.push(mutations[m].target);if(msobserver.isFraternal)matches.push.apply(matches,mutations[m].target.parentElement.querySelectorAll(msobserver.selector));else matches.push.apply(matches,mutations[m].target.querySelectorAll(msobserver.selector))}if(mutations[m].type=="childList"){for(var n=0;n<mutations[m].addedNodes.length;n++){if(!(mutations[m].addedNodes[n]instanceof Element))continue;if(mutations[m].addedNodes[n].matches(msobserver.selector))matches.push(mutations[m].addedNodes[n]);if(msobserver.isFraternal)matches.push.apply(matches,mutations[m].addedNodes[n].parentElement.querySelectorAll(msobserver.selector));else matches.push.apply(matches,mutations[m].addedNodes[n].querySelectorAll(msobserver.selector))}}}for(var i=0;i<matches.length;i++)$(matches[i]).each(msobserver.callback)});var defaultObeserverOpts={childList:true,subtree:true,attributes:msobserver.isComplex};observer.observe(options.target,options.observer||defaultObeserverOpts);return observer};$.fn.initialize=function(callback,options){return msobservers.initialize(this.selector,callback,$.extend({},$.initialize.defaults,options))};$.initialize=function(selector,callback,options){return msobservers.initialize(selector,callback,$.extend({},$.initialize.defaults,options))};$.initialize.defaults={target:document.documentElement,observer:null}})(jQuery);

View File

@@ -482,35 +482,38 @@ function Course(coursename, unique, profname, datetimearr, status, link, registe
function getInfo(sem, unique) { function getInfo(sem, unique) {
var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`; var link = `https://utdirect.utexas.edu/apps/registrar/course_schedule/${sem}/${unique}/`;
var xhr = new XMLHttpRequest(); window.open(link);
xhr.open("GET", link, false); // $.ajax({
xhr.send(); // url: link,
var response = xhr.responseText; // success: function (response) {
if (response) { // console.log(response)
var output = ""; // if (response) {
var object = $('<div/>').html(response).contents(); // var output = "";
console.log(object.find('.error').text()); // var object = $('<div/>').html(response).contents();
if (object.find('.error').text().trim() == 'No class was found for your input.') { // console.log(object.find('.error').text());
window.confirm(`Could not find a course with unique number: ${unique}`); // if (object.find('.error').text().trim() == 'No class was found for your input.') {
} else { // window.confirm(`Could not find a course with unique number: ${unique}`);
var c = getCourseObject(object, link); // } else {
console.log(c); // var c = getCourseObject(object, link);
if (c.coursename) { // console.log(c);
chrome.runtime.sendMessage({ // if (c.coursename) {
command: "courseStorage", // chrome.runtime.sendMessage({
course: c, // command: "courseStorage",
action: "add" // course: c,
}, function () { // action: "add"
chrome.runtime.sendMessage({ // }, function () {
command: "updateCourseList" // chrome.runtime.sendMessage({
}); // command: "updateCourseList"
setCourseList(); // });
}); // setCourseList();
} else { // });
window.confirm("There Was An Error. Please check if you are logged into Utexas.") // } else {
} // window.confirm("There Was An Error. Please check if you are logged into Utexas.")
} // }
} // }
// }
// }
// });
} }

View File

@@ -9,14 +9,15 @@
"declarativeContent", "declarativeContent",
"storage", "storage",
"*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*", "*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*",
"*://*.utexas.collegescheduler.com/terms/*/schedules/*",
"*://*.catalog.utexas.edu/ribbit/", "*://*.catalog.utexas.edu/ribbit/",
"*://*.registrar.utexas.edu/schedules/*", "*://*.registrar.utexas.edu/schedules/*",
"*://*.login.utexas.edu/login/*" "*://*.login.utexas.edu/login/*"
], ],
"content_scripts": [{ "content_scripts": [{
"css": ["css/styles.css"], "css": ["css/styles.css"],
"js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/content.js"], "js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/jquery.initialize.min.js", "js/content.js"],
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"] "matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*", "https://utexas.collegescheduler.com/terms/*"]
}, { }, {
"css": ["css/styles.css"], "css": ["css/styles.css"],
"js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/import.js"], "js": ["js/moment.min.js", "js/sql-memory-growth.js", "js/highcharts.js", "js/jquery-3.3.1.min.js", "js/import.js"],
@@ -44,4 +45,4 @@
"48": "icons/icon48.png", "48": "icons/icon48.png",
"128": "icons/icon128.png" "128": "icons/icon128.png"
} }
} }