moved getting semesters into background, message calling in popup

This commit is contained in:
Hariharan
2019-08-20 15:02:21 -05:00
parent 7ab78949ed
commit 12837ed19e
3 changed files with 72 additions and 47 deletions

View File

@@ -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>`);
}
});
}