diff --git a/app/views/rubygems/show.html.erb b/app/views/rubygems/show.html.erb index 373543457c8..054a6927348 100644 --- a/app/views/rubygems/show.html.erb +++ b/app/views/rubygems/show.html.erb @@ -67,7 +67,7 @@ <% end %> -
+
<%= number_with_delimiter(@rubygem.downloads) %> total downloads diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 8957e4ade2e..d61c91bac11 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -23,6 +23,17 @@ $(document).ready(function() { }); }, 5000); } + + if ($('.downloads.counter').length > 0) { + setInterval(function() { + $.getJSON($('.downloads.counter').attr('data-href'), function(data) { + $('.downloads.counter strong:first') + .text(number_with_delimiter(data['total_downloads'])); + $('.downloads.counter strong:last') + .text(number_with_delimiter(data['latest_version_downloads'])); + }); + }, 5000); + } }); // http://kevinvaldek.com/number-with-delimiter-in-javascript