comparison gpp/downloads/static/js/downloads-get.js @ 404:41411066b16d

Fixing #199; redid the downloads so the user has more control about how to save the file.
author Brian Neal <bgneal@gmail.com>
date Sun, 27 Mar 2011 23:21:17 +0000
parents
children
comparison
equal deleted inserted replaced
403:6e425c9b9d16 404:41411066b16d
1 $(document).ready(function() {
2 $('.dl-button').each(function(n) {
3 var button = $(this);
4 var id = button.attr('id');
5 var numeric_id = -1;
6 if (id.match(/dl-(\d+)/))
7 {
8 numeric_id = RegExp.$1;
9 }
10 button.click(function() {
11 button.attr('disabled', 'disabled').val('Getting link, stand by...');
12 $.ajax({
13 url: '/downloads/request/',
14 type: 'POST',
15 data: { id: numeric_id },
16 dataType: 'json',
17 success: function(result) {
18 var link_id = result.id;
19 var div = $('#link-' + link_id);
20 div.hide();
21 div.html(
22 'Thank you! Your download is now ready. <a href="' + result.url +
23 '">Click here to download</a>.');
24 div.fadeIn(3000);
25 },
26 error: function (xhr, textStatus, ex) {
27 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
28 xhr.responseText);
29 }
30 });
31 });
32 });
33 });