/** * @file */ function displayPowerUpAmount() { var $ = jQuery; if ($('.power-up-amount').length > 0) { var fmt = function (x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') }; var raised = parseFloat($("#donate-donations").text().replace(/,|\$/g, '')), goal = parseFloat($("#donate-goal").text().replace(/,|\$/g, '')), amount = parseFloat($('#edit-amount-levels-amount').val()) || 0.0; if (raised < goal) { var match = Math.max(Math.min(amount, goal - raised), 0); $('.base-amount').text(fmt(amount)); $('.match-amount').text(fmt(match)); $('.power-up-amount').text(fmt(amount + match)); } else { $("#power-up-box").remove(); } } } (function ($) { $(document).ready(function () { $('#edit-email').focus(function () { $(this).val(''); }); function pad(num, size) { var s = '0' + num; return s.substr(s.length - size); } function powerUpTimer() { var powerUp = new Date('Tue, 18 Dec 2012 16:47:47 -0800'); var now = new Date(); var timeDiff = powerUp.getTime() - now.getTime(); if (timeDiff <= 0) { clearTimeout(timer); timeDiff = 0; } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $('#days').html(days); $('#hours').html(pad(hours, 2)); $('#minutes').html(pad(minutes, 2)); $('#seconds').html(pad(seconds, 2)); var timer = setTimeout(function () { powerUpTimer(); }, 1000); } // Power Up Your Donation additions. powerUpTimer(); var multiplier = parseInt($('.pane-node-field-powerup-multiple').text()); if (multiplier > 1) { $('body.donate-powerup #eff-donate-counter').append('