dynamic options, now store options as object rather than individually, waitlist scraping base
This commit is contained in:
26
js/import.js
26
js/import.js
@@ -5,9 +5,12 @@ $(function () {
|
||||
sem = waitlist ? $('[name="s_ccyys"]').val() : $("option[selected='selected']").val();
|
||||
if (waitlist) {
|
||||
$("[href='#top']").before(Template.Import.import_button());
|
||||
$("[name='wl_see_my_waitlists']").before(Template.import.store_waitlist_message());
|
||||
$("[name='wl_see_my_waitlists']").after(Template.Import.waitlist_import_button());
|
||||
} else
|
||||
extractWaitlistInfo();
|
||||
} else {
|
||||
$("table").after(Template.Import.import_button());
|
||||
}
|
||||
$("#import").prepend("<div id='snackbar'>import snackbar..</div>");
|
||||
|
||||
$("#import").click(function () {
|
||||
@@ -28,6 +31,27 @@ $(function () {
|
||||
});
|
||||
|
||||
|
||||
function extractWaitlistInfo(){
|
||||
let class_boxes = $("[name='wl_see_my_waitlists']>table");
|
||||
let waitlist_info = [];
|
||||
$(class_boxes).each(function(){
|
||||
let data = $(this).find('tr.tb span');
|
||||
let unique_num = $(data[0]).text().trim();
|
||||
let class_name = $(data[1]).text().trim().split('\n').filter(part => part.trim() != '').map(part => part.trim()).join(' ');
|
||||
let waitlist_size = $(this).find('tr.tbon:eq(2) td:eq(1)').text().trim().split(' of ')[1];
|
||||
|
||||
waitlist_info.push({
|
||||
"id": unique_num,
|
||||
"class": class_name,
|
||||
"wait": waitlist_size,
|
||||
"time": moment().format('DD-MM-YYYY HH:mm:ss')
|
||||
});
|
||||
});
|
||||
console.log(waitlist_info);
|
||||
return waitlist_info;
|
||||
}
|
||||
|
||||
|
||||
function importButtonAnimation(button) {
|
||||
let is_waitlisted_button = $(button).attr('id') == "import_waitlist";
|
||||
let return_text = is_waitlisted_button ? Text.waitlist_button_text_default : Text.button_text_default;
|
||||
|
||||
Reference in New Issue
Block a user