MediaWiki:FR2013/Resources/BannerFormAmountOptions.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
<script>
/**
 * Localize amount options in banner forms.
 *
 * Dependencies: FR2013/Resources/Country2Currency.js
 *               FR2013/Resources/CurrencyLocalize.js
 */

$(document).ready( function () {

    var currency = getCurrency(Geo.country);
    var language = mw.config.get('wgUserLanguage');

    // do fun things to localize currency in the banner and form
    $("input[name='amount']").each(function(index){
        var id = $(this).attr("id");
        var $label = $("label[for='" + id + "']");
        var amount = convertAsk($(this).val(), currency, Geo.country);
        $(this).val(amount);
        $label.html(currencyLocalize(currency, amount, language));
    });

    $otherLabel = $("#input_label_other");
    $otherLabel.html( 
        currencyLocalize(
            currency,
            $otherLabel.html().replace('$',''), // strip the $ sign already on there
            language
        )
    );

});
</script>