You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

const appModal = $('#modalDownloadQueue');
const appModalContent = $('#modal_content');
function proc_notification(icon, title, text) {
Swal.fire({
title: title,
icon: icon,
text: text
})
}
$('.queue_btn').on('click', () => {
console.log('Get Queue!');
$.ajax({
url: '/api/v1/get/queue'
}).done( (res) => {
console.log(res);
appModalContent.html(res);
appModal.modal('toggle');
})
})
$('#download_btn').on('click', () => {
let artist = $('#search_bar').val();
// Prevent
$('#search_bar').val('');
let icon = 'error';
let title = 'What the flip?!';
let text = 'You need to add an artist bro..';
if (artist) {
$("#loader-wrapper").fadeIn(300);
$.ajax({
url: `/api/v1/get/artist/${artist}`,
}).done(function (res) {
text = res.message;
if (res.status === 200) {
icon = 'success';
title = 'Shazam!';
}
$("#loader-wrapper").fadeOut(700);
proc_notification(icon, title, text);
});
} else {
proc_notification(icon, title, text);
}
})