moved getting semesters into background, message calling in popup
This commit is contained in:
34
js/popup.js
34
js/popup.js
@@ -378,31 +378,15 @@ function showImportExportPopup() {
|
||||
}
|
||||
|
||||
function getSemesters() {
|
||||
var schedule_list = 'https://registrar.utexas.edu/schedules';
|
||||
$.get(schedule_list, function (response) {
|
||||
if (response) {
|
||||
htmlToNode(response).find('.callout2>ul>li>a').each(function (i) {
|
||||
if (i < Popup.num_semesters) {
|
||||
let sem_name = $(this).text().trim();
|
||||
if (sem_name != "Course Schedule Archive") {
|
||||
$("#semesters").append(`<option>${sem_name}</option>`);
|
||||
$.get($(this).attr('href'), function (response) {
|
||||
if (response) {
|
||||
let response_node = htmlToNode(response);
|
||||
let name = response_node.find(".page-title").text().substring(17).trim();
|
||||
response_node.find('.gobutton>a').each(function () {
|
||||
let link = $(this).attr('href');
|
||||
var sem_num = link.substring(link.lastIndexOf('/') + 1).trim();
|
||||
$("option").each(function () {
|
||||
if ($(this).text() == name)
|
||||
$(this).val(sem_num);
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
chrome.runtime.sendMessage({
|
||||
command: "currentSemesters"
|
||||
}, function(response){
|
||||
let { semesters } = response;
|
||||
console.log(semesters);
|
||||
let semester_names = Object.keys(semesters);
|
||||
for(let i = 0; i<semester_names.length;i++){
|
||||
let name = semester_names[i];
|
||||
$("#semesters").append(`<option value='${semesters[name]}'>${name}</option>`);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user