view downloads/static/js/downloads-get.js @ 1154:4da4e32b314c

Do not restrict oEmbed support to just video. This will allow us to embed stuff from SoundClound and ReverbNation.
author Brian Neal <bgneal@gmail.com>
date Tue, 27 Dec 2016 10:21:37 -0600
parents f56798c96ec2
children
line wrap: on
line source
$(document).ready(function() {
    $('.dl-button').each(function(n) {
        var button = $(this);
        var id = button.attr('id');
        var numeric_id = -1;
        if (id.match(/dl-(\d+)/))
        {
            numeric_id = RegExp.$1;
        }
        button.click(function() {
           button.attr('disabled', 'disabled').val('Getting link, stand by...');
           $.ajax({
               url: '/downloads/request/', 
               type: 'POST',
               data: { id: numeric_id },
               dataType: 'json',
               success: function(result) {
                  var link_id = result.id;
                  var div = $('#link-' + link_id);
                  div.hide();
                  div.addClass('success callout');
                  div.html(
                     'Thank you! Your download is now ready. <a href="' + result.url +
                        '">Click here to download</a>.');
                  div.fadeIn(3000);
               },
               error: function (xhr, textStatus, ex) {
                   alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + 
                      xhr.responseText);
               }
           });
        });
    });
});