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?
//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')) {
let params = (new URL(document.location)).searchParams;
@@ -44,12 +48,26 @@ if (document.querySelector('#fos_fl')) {
}
}
}
next = $("#next_nav_link");
chrome.storage.sync.get('loadAll', function (data) {
if (data.loadAll) {
$('[title*="next listing"]').remove();
}
});
if(next){
chrome.storage.sync.get('loadAll', function (data) {
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();
//make heading and modal
@@ -111,7 +129,7 @@ if (!$("#kw_results_table").length) {
//update the conflicts
update(0);
/*Handle the button clicks*/
$("tbody").on('click', '#distButton', function () {
$("body").on('click', '#distButton', function () {
var row = $(this).closest('tr');
$('.modal-content').stop().animate({
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*/
function getCourseInfo(row) {
console.log('WHAT');
console.log(row);
semesterCode = new URL(window.location.href).pathname.split('/')[4];
$("h2.dateTimePlace").remove();
$('table').find('tr').each(function () {

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

View File

@@ -9,14 +9,15 @@
"declarativeContent",
"storage",
"*://*.utdirect.utexas.edu/apps/registrar/course_schedule/*",
"*://*.utexas.collegescheduler.com/terms/*/schedules/*",
"*://*.catalog.utexas.edu/ribbit/",
"*://*.registrar.utexas.edu/schedules/*",
"*://*.login.utexas.edu/login/*"
],
"content_scripts": [{
"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"],
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
"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/*", "https://utexas.collegescheduler.com/terms/*"]
}, {
"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"],