From f3b930579f1b53e325b7bf905774a65f549b3e6f Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Thu, 5 Mar 2015 08:00:14 -0800 Subject: [PATCH] Automatically generate fundraiser percentage text. Using this span, we can update the number in the fundraising percentage text automatically. The downside is that non-javascript browsers will not receive a fundraising percentage, but the upside is that fewer things need to be calculated by hand, and now only the amount raised so far needs updated. --- www/conservancy/static/supporter-page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/conservancy/static/supporter-page.js b/www/conservancy/static/supporter-page.js index ab3cd5cd..93aadb17 100644 --- a/www/conservancy/static/supporter-page.js +++ b/www/conservancy/static/supporter-page.js @@ -9,8 +9,10 @@ $(document).ready(function() { var soFar = $('span#fundraiser-so-far').text(); var noCommaGoal = goal.replace(/,/g, ""); var noCommaSoFar = soFar.replace(/,/g, ""); + var percentage = (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100; - $("#progressbar").progressbar({ value: (parseFloat(noCommaSoFar) / parseFloat(noCommaGoal)) * 100 }); + $('span#fundraiser-percentage').text(percentage.toFixed(2) + "%"); + $("#progressbar").progressbar({ value: percentage }); $('.toggle-content').hide();