Changeset - 83c97a002998
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 9 years ago 2015-03-21 14:03:28
bkuhn@ebb.org
Perform math on number variable without comma

The math performed for the number of donors should be done on the number
without the comma, so that NaN doesn't show on the site.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/supporter-page.js
Show inline comments
 
/* Copyright (C) 2012-2013 Denver Gingerich, 
 
** Copyright (C) 2013-2014 Bradley M. Kuhn.
 
** License: GPLv3-or-later
 
**  Find a copy of GPL at https://sfconservancy.org/GPLv3
 
*/
 

	
 
$(document).ready(function() {
 
    var goal  = $('span#fundraiser-goal').text();
 
    var soFar = $('span#fundraiser-so-far').text();
 
    var donationCount = $('span#fundraiser-donation-count').text();
 
    var noCommaGoal = parseFloat(goal.replace(/,/g, ""));
 
    var noCommaSoFar = parseFloat(soFar.replace(/,/g, ""));
 
    var noCommaDonationCount = parseInt(donationCount.replace(/,/g, ""));
 
    var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100;
 
    var curValue = 0.00;
 
    var incrementSoFar = 0.00;
 
    var curDonationCount = 0;
 
    var riseLevelPercent = 0.5;
 
    var incrementDonationCount = Math.round( (riseLevelPercent / 100) * donationCount );
 
    var incrementDonationCount = Math.round( (riseLevelPercent / 100) * noCommaDonationCount );
 

	
 
    $('span#fundraiser-percentage').css({ 'color'        : 'green',
 
                                          'font-weight'  : 'bold',
 
                                          'float'        : 'right',
 
                                          'margin-right' : '40%',
 
                                          'margin-top'   : '2.5%',
 
                                          'text-align'   : 'inherit'});
 
    function riseDonationProgressBar() {
 
        if (curValue >= percentage) {
 
            $('span#fundraiser-so-far').text(soFar);
 
            $("#progressbar").progressbar({ value :  percentage });
 
            $('span#fundraiser-percentage').text(percentage.toFixed(1) + "%");
 
        } else {
 
            var newVal = (curValue / 100.00) * noCommaGoal;
 
            $("#progressbar").progressbar({ value:  curValue });
 
            $('span#fundraiser-so-far').text(newVal.toLocaleString());
 
            curValue += riseLevelPercent;
 
            setTimeout(riseDonationProgressBar, 50);
 
        }
 
    }
 
    function riseDonationCount() {
 
        if (curDonationCount >= noCommaDonationCount) {
 
            $('span#fundraiser-donation-count').text(donationCount);
 
        } else {
0 comments (0 inline, 0 general)