From 26bf18266266d8a3957875d0b08ecd457d535410 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 9 Sep 2016 23:11:48 -0700 Subject: Fix bug with currency/symbol settings not being selected properly --- public/js/setup.coffee | 12 +++++++----- public/js/setup.js | 15 ++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public/js/setup.coffee b/public/js/setup.coffee index 744de8a0..d796c897 100644 --- a/public/js/setup.coffee +++ b/public/js/setup.coffee @@ -15,16 +15,17 @@ $(-> $("#currency option[value='CAD']").attr('selected', 'selected') $('#currency').change(-> + currency = $(this).val() + return unless currency + $('#symbol option').remove() - symbol = $(this).val() - return unless symbol - symbols = Object.keys(data[symbol]) + symbols = Object.keys(data[currency]) $.each(symbols, (i, v) -> return if v == 'localbitcoins' $('#symbol').append("") ) - switch $(this).val() + switch currency when 'CAD' $("#symbol option[value='quadrigacx']").attr('selected', 'selected') when 'USD' @@ -39,10 +40,11 @@ $(-> $('#title').val(data.title) $('#logo').val(data.logo) $('#address').val(data.address) - $("#symbol option[value='#{data.symbol}']").attr('selected', 'selected') $('#commission').val(data.commission) $('#unit').val(data.unit) + $("#currency option[value='#{data.currency}']").attr('selected', 'selected') $('#currency').change() + $("#symbol option[value='#{data.symbol}']").attr('selected', 'selected') $('#setup').fadeIn() $('#title').focus() ) diff --git a/public/js/setup.js b/public/js/setup.js index ea3808ea..e96bd00d 100644 --- a/public/js/setup.js +++ b/public/js/setup.js @@ -21,20 +21,20 @@ }); $("#currency option[value='CAD']").attr('selected', 'selected'); $('#currency').change(function() { - var symbol, symbols; - $('#symbol option').remove(); - symbol = $(this).val(); - if (!symbol) { + var currency, symbols; + currency = $(this).val(); + if (!currency) { return; } - symbols = Object.keys(data[symbol]); + $('#symbol option').remove(); + symbols = Object.keys(data[currency]); $.each(symbols, function(i, v) { if (v === 'localbitcoins') { return; } return $('#symbol').append(""); }); - switch ($(this).val()) { + switch (currency) { case 'CAD': return $("#symbol option[value='quadrigacx']").attr('selected', 'selected'); case 'USD': @@ -53,10 +53,11 @@ $('#title').val(data.title); $('#logo').val(data.logo); $('#address').val(data.address); - $("#symbol option[value='" + data.symbol + "']").attr('selected', 'selected'); $('#commission').val(data.commission); $('#unit').val(data.unit); + $("#currency option[value='" + data.currency + "']").attr('selected', 'selected'); $('#currency').change(); + $("#symbol option[value='" + data.symbol + "']").attr('selected', 'selected'); $('#setup').fadeIn(); return $('#title').focus(); }); -- cgit v1.2.3