From a7a15cec8b574d6988b3932caa7db9ebb4c31094 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 11 Mar 2015 18:36:01 -0700 Subject: [PATCH] Better handle no value situations. The issue where these values were empty was not properly handled. --- www/conservancy/static/supporter-page.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/www/conservancy/static/supporter-page.js b/www/conservancy/static/supporter-page.js index fd7b3477..364da1b4 100644 --- a/www/conservancy/static/supporter-page.js +++ b/www/conservancy/static/supporter-page.js @@ -8,23 +8,20 @@ $(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 = goal.replace(/,/g, ""); - var noCommaSoFar = soFar.replace(/,/g, ""); + 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 incrementDonationCount = 0; - $('span#fundraiser-percentage').text(""); $('span#fundraiser-percentage').css({ 'color' : 'green', 'font-weight' : 'bold', 'float' : 'right', 'margin-right' : '40%', 'margin-top' : '2.5%', 'text-align' : 'inherit'}); - $("#progressbar").progressbar({ value: curValue }); - function riseDonationProgressBar() { if (curValue >= percentage) { $('span#fundraiser-so-far').text(soFar); @@ -50,7 +47,11 @@ $(document).ready(function() { if (noCommaDonationCount > 0) { riseDonationCount(); } - riseDonationProgressBar(); + if (noCommaSoFar > 0.00 and noCommaGoal > 0.00) { + $('span#fundraiser-percentage').text(""); + $("#progressbar").progressbar({ value: curValue }); + riseDonationProgressBar(); + } $('.toggle-content').hide();