Last active
August 29, 2015 14:23
-
-
Save goffreder/768852992640c32f7be5 to your computer and use it in GitHub Desktop.
Average fund calculation for indiegogo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$('<div>').addClass('i-average-fund').insertBefore($('.i-progress-bar')); | |
$('<div>').addClass('i-ppl-needed').insertBefore($('.i-progress-bar')); | |
window.avgInterval = setInterval(function() { | |
var balanceTxt = $(".i-balance span span").text(); | |
var curr = balanceTxt[0]; | |
var balance = parseFloat($(".i-balance span span").text().replace(curr, '').replace(/,/g,'')); | |
var people = parseInt($(".i-raised-funders").text().replace(/,/g,'')); | |
var total = parseInt($(".i-goal-amount .currency").text().replace(/,/g,'').replace(curr, '')); | |
var avg = new Number((balance/people).toFixed(2)); | |
var pplneeded = new Number(((total-balance)/avg).toFixed(2)); | |
$('.i-average-fund').html('Avg. fund: <b>' + avg + curr + '</b>'); | |
$('.i-ppl-needed').html('<b>' + pplneeded.toLocaleString() + '</b> people needed'); | |
}, 1000); | |
})($); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment