appeal: Progress bar emphasizes current match program.
This commit is contained in:
		
							parent
							
								
									dd8d159fcb
								
							
						
					
					
						commit
						6908c135f2
					
				
					 2 changed files with 22 additions and 102 deletions
				
			
		|  | @ -21,106 +21,34 @@ $window.load(function() { | |||
| $(document).ready(function() { | ||||
|     var siteFinalGoal = $('span#site-fundraiser-final-goal').text(); | ||||
|     var noCommaSiteFinalGoal = parseInt(siteFinalGoal.replace(/,/g, "")); | ||||
|     var siteMiddleGoal = $('span#site-fundraiser-middle-goal').text(); | ||||
|     var noCommaSiteMiddleGoal = parseInt(siteMiddleGoal.replace(/,/g, "")); | ||||
|     if (!noCommaSiteMiddleGoal) { | ||||
|         noCommaSiteMiddleGoal = 0; | ||||
|     } | ||||
|     var siteSoFar = $('span#site-fundraiser-so-far').text(); | ||||
|     var noCommaSiteSoFar = parseInt(siteSoFar.replace(/,/g, "")); | ||||
|     var siteMatchCount = $('span#site-fundraiser-match-count').text(); | ||||
|     var noCommaSiteMatchCount = parseInt(siteMatchCount.replace(/,/g, "")); | ||||
|     if (! noCommaSiteMatchCount) { | ||||
|         noCommaSiteMatchCount = "0"; | ||||
|     } | ||||
|     var noCommaMatchFinalGoal = noCommaSiteFinalGoal - noCommaSiteMatchCount; | ||||
|     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) * noCommaDonationCount ); | ||||
|     $('#siteprogressbar').empty(); | ||||
| 
 | ||||
|     if (noCommaSiteSoFar >= noCommaSiteMiddleGoal) { | ||||
|         // We've got
 | ||||
|         var leftOver = noCommaMatchFinalGoal - noCommaSiteSoFar; | ||||
|         var supporterProgress = (noCommaSiteSoFar / noCommaSiteFinalGoal) * 100; | ||||
|         var needProgress = (leftOver / noCommaSiteFinalGoal) * 100; | ||||
| 
 | ||||
|         $('#siteprogressbar'). | ||||
|             multiprogressbar({ parts: [ | ||||
|                 { value: supporterProgress, | ||||
|                   text: noCommaSiteSoFar.toLocaleString() + " have joined!", | ||||
|                   barClass: "progress", textClass: "soFarText" }, | ||||
|                 { value: needProgress, | ||||
|                   text: leftOver.toLocaleString() + " more needed", | ||||
|                   barClass: "final-goal", textClass: "goalText" }, | ||||
|                 { value: 100, | ||||
|                   text: noCommaSiteMatchCount.toLocaleString() + " matched!", | ||||
|                   barClass: "progress", textClass: "soFarText" }, | ||||
|             ]}); | ||||
|     } else { | ||||
|         $('#siteprogressbar'). | ||||
|             multiprogressbar({ parts: [ | ||||
|                 { value: (noCommaSiteSoFar / noCommaSiteFinalGoal) * 100, | ||||
|                   text: siteSoFar + " joined!", | ||||
|                   barClass: "progress", textClass: "soFarText" }, | ||||
|                 { value: ((noCommaSiteMiddleGoal - noCommaSiteSoFar) / noCommaSiteFinalGoal) * 100, | ||||
|                   text: siteMiddleGoal + " will save our basic work", | ||||
|                   barClass: "middle-goal", textClass: "goalText" }, | ||||
|                 { value: | ||||
|                   ((noCommaMatchFinalGoal - noCommaSiteMiddleGoal) / noCommaSiteFinalGoal) * 100, | ||||
|                   text: noCommaMatchFinalGoal.toLocaleString() + " will save license compliance", | ||||
|                   barClass: "final-goal", textClass: "goalText" }, | ||||
|                 {  value: 100, | ||||
|                    text: siteMatchCount + " matched!", | ||||
|                    barClass: "progress", textClass: "soFarText" }, | ||||
|             ]}); | ||||
|     var barParts = [{ | ||||
|         value: (noCommaSiteMatchCount / noCommaSiteFinalGoal) * 100, | ||||
|         text: noCommaSiteMatchCount.toLocaleString() + " matched!", | ||||
|         barClass: "progress", | ||||
|         textClass: "soFarText", | ||||
|     }]; | ||||
|     if (barParts[0].value < 100) { | ||||
|         var matchesLeft = noCommaSiteFinalGoal - noCommaSiteMatchCount; | ||||
|         barParts.push({ | ||||
|             value: 100, | ||||
|             text: matchesLeft.toLocaleString() + " to go!", | ||||
|             barClass: "final-goal", | ||||
|             textClass: "goalText", | ||||
|         }); | ||||
|     } | ||||
|     $('#siteprogressbar').empty().multiprogressbar(barParts); | ||||
| 
 | ||||
|     $('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 { | ||||
|             $('span#fundraiser-donation-count').text(curDonationCount.toLocaleString()); | ||||
|             curDonationCount += incrementDonationCount; | ||||
|             setTimeout(riseDonationCount, 50); | ||||
|         } | ||||
|     } | ||||
|     if (noCommaDonationCount > 0) { | ||||
|         $('span#fundraiser-donation-count').text(""); | ||||
|         riseDonationCount(); | ||||
|     } | ||||
|     if (noCommaSoFar > 0.00 && noCommaGoal > 0.00) { | ||||
|         $('span#fundraiser-percentage').text(""); | ||||
|         $("#progressbar").progressbar({ value:  curValue }); | ||||
|         riseDonationProgressBar(); | ||||
|     } | ||||
| 
 | ||||
|     $('.toggle-content').hide(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -60,12 +60,7 @@ PIA will match up to 416. | |||
|     <div class="fundraiser-top-text"> | ||||
|       <em> | ||||
|         Let's stand up for software freedom together! | ||||
|         {% if sitefundgoal.fundraiser_goal_amount > sitefundgoal.fundraiser_so_far_amount %} | ||||
|         We still need | ||||
|         {{ sitefundgoal.fundraiser_goal_amount|subtract:sitefundgoal.fundraiser_donation_count_disclose_threshold|subtract:sitefundgoal.fundraiser_so_far_amount|intcomma }} | ||||
|         more Supporters to maintain our full range of activities in 2017. | ||||
|         {% endif %} | ||||
|         {% if sitefundgoal.fundraiser_donation_count_disclose_threshold > 1076 %} | ||||
|         {% if sitefundgoal.fundraiser_donation_count_disclose_threshold >= 1076 %} | ||||
|         416 Supporters were matched | ||||
|         {% else %} | ||||
|         The next {{ 1076|subtract:sitefundgoal.fundraiser_donation_count_disclose_threshold|intcomma }} Supporters who join or renew by January 15 <a href="/news/2016/nov/29/private-internet-access-2016-fundraising-match/">will count twice</a>, | ||||
|  | @ -74,16 +69,13 @@ PIA will match up to 416. | |||
|       </em> | ||||
| <div id="siteprogressbar"> | ||||
| <a href="/supporter"> | ||||
|   <span id="site-fundraiser-so-far">{{ sitefundgoal.fundraiser_so_far_amount|intcomma }}</span> have joined so far. | ||||
|   <span id="site-fundraiser-match-count">{{ sitefundgoal.fundraiser_donation_count_disclose_threshold|intcomma }}</span> Supporters have been matched. | ||||
|   {% if sitefundgoal.fundraiser_goal_amount > sitefundgoal.fundraiser_so_far_amount %} | ||||
|   We still need | ||||
|   {{ sitefundgoal.fundraiser_goal_amount|subtract:sitefundgoal.fundraiser_donation_count_disclose_threshold|subtract:sitefundgoal.fundraiser_so_far_amount|intcomma }} | ||||
|   more Supporters to reach | ||||
|   {% if sitefundgoal.fundraiser_donation_count_disclose_threshold < 1076 %} | ||||
|   <span id="site-fundraiser-match-count">{{ sitefundgoal.fundraiser_donation_count_disclose_threshold|subtract:660|intcomma }}</span> | ||||
|   {% else %} | ||||
|   That means we reached | ||||
|   <span id="site-fundraiser-match-count">416</span> | ||||
|   {% endif %} | ||||
|   our goal of <span id="site-fundraiser-final-goal">{{ sitefundgoal.fundraiser_goal_amount|intcomma }}</span>. | ||||
|   Supporters have been matched, out of | ||||
|   <span id="site-fundraiser-final-goal">416</span> possible. | ||||
| </a> | ||||
| </div> | ||||
| </div> | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Brett Smith
						Brett Smith