Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function petition_ajax_refresh() {
  2.         $.ajax({
  3.           url: settings.petition.api_base + '/petitions/' + settings.petition.petition_id + '.json',
  4.           method: 'GET',
  5.           cache: false,
  6.           success: function(data) {
  7.             var response = data.results[0];
  8.             var width = 1;
  9.             if (response.signatureCount < response.signatureThreshold) {
  10.               var calc = (Math.round((response.signatureCount / response.signatureThreshold * 100) + "e+1") + "e-1");
  11.               width = Math.max(calc, 1);
  12.             }
  13.             else {
  14.               width = 100;
  15.             }
  16.  
  17.             $('.signatures-needed', context).text(response.signaturesNeeded.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
  18.             $('.signature-meter > span', context).width(width + '%');
  19.             $('.signatures-number', context).text(response.signatureCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
  20.           }
  21.         });
  22.  
  23.       }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement