impress/public/javascripts/pledgie.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2011-07-01 11:53:28 -07:00
(function () {
var PLEDGIE_CAMPAIGN_ID = $('meta[name=pledgie-campaign-id]').attr('content');
var pledgieURL = 'http://pledgie.com/campaigns/' + PLEDGIE_CAMPAIGN_ID + '.json?callback=?';
$.getJSON(pledgieURL, function (data) {
var campaign = data.campaign;
2011-07-01 12:18:05 -07:00
// Write the donors list if we need to
var donorsEl = $('#campaign-donors');
if(donorsEl.length) {
var donorsList = donorsEl.children('ol');
var pledges = campaign.pledges;
var pledge, pledgeEl;
for(var i in pledges) {
pledge = pledges[i];
pledgeEl = $('<li/>');
$('<strong/>', {text: pledge.display_name}).appendTo(pledgeEl);
$('<span/>', {text: pledge.date}).appendTo(pledgeEl);
pledgeEl.appendTo(donorsList);
}
2011-07-02 10:23:38 -07:00
if(pledges.length > 0) {
donorsEl.addClass('has-donors');
}
2011-07-01 11:53:28 -07:00
}
2011-07-01 12:18:05 -07:00
// Set campaign progress data
$('span.campaign-raised').text(campaign.amount_raised);
$('span.campaign-goal').text(campaign.goal);
var campaign_percent = campaign.amount_raised / campaign.goal * 100;
$('div.campaign-progress').css('width', campaign_percent + '%');
2011-07-01 11:53:28 -07:00
$(document.body).addClass('campaign-loaded');
});
})();