annotate downloads/static/js/downloads-get.js @ 1180:6d65aa69420e

Add 2019 MP3 links.
author Brian Neal <bgneal@gmail.com>
date Wed, 01 Jan 2020 12:54:35 -0600
parents f56798c96ec2
children
rev   line source
bgneal@404 1 $(document).ready(function() {
bgneal@404 2 $('.dl-button').each(function(n) {
bgneal@404 3 var button = $(this);
bgneal@404 4 var id = button.attr('id');
bgneal@404 5 var numeric_id = -1;
bgneal@404 6 if (id.match(/dl-(\d+)/))
bgneal@404 7 {
bgneal@404 8 numeric_id = RegExp.$1;
bgneal@404 9 }
bgneal@404 10 button.click(function() {
bgneal@404 11 button.attr('disabled', 'disabled').val('Getting link, stand by...');
bgneal@404 12 $.ajax({
bgneal@404 13 url: '/downloads/request/',
bgneal@404 14 type: 'POST',
bgneal@404 15 data: { id: numeric_id },
bgneal@404 16 dataType: 'json',
bgneal@404 17 success: function(result) {
bgneal@404 18 var link_id = result.id;
bgneal@404 19 var div = $('#link-' + link_id);
bgneal@404 20 div.hide();
bgneal@1151 21 div.addClass('success callout');
bgneal@404 22 div.html(
bgneal@404 23 'Thank you! Your download is now ready. <a href="' + result.url +
bgneal@404 24 '">Click here to download</a>.');
bgneal@404 25 div.fadeIn(3000);
bgneal@404 26 },
bgneal@404 27 error: function (xhr, textStatus, ex) {
bgneal@404 28 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
bgneal@404 29 xhr.responseText);
bgneal@404 30 }
bgneal@404 31 });
bgneal@404 32 });
bgneal@404 33 });
bgneal@404 34 });