diff options
| author | Adam Soltys <[email protected]> | 2017-01-15 18:24:09 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2017-01-15 18:24:09 -0800 |
| commit | 7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e (patch) | |
| tree | 91bb1d1b8fe6ad77a48f0e429d9bfd35834c78d9 /static/js/setup.coffee | |
| parent | 0ae266bf88f9f79c7e99b272688126898303daa4 (diff) | |
| download | coinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.tar.gz coinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.zip | |
Initial Vueification
Diffstat (limited to 'static/js/setup.coffee')
| -rw-r--r-- | static/js/setup.coffee | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/static/js/setup.coffee b/static/js/setup.coffee new file mode 100644 index 00000000..d796c897 --- /dev/null +++ b/static/js/setup.coffee @@ -0,0 +1,65 @@ +g = exports ? this +g.proceed = false + +$(-> + $('#encryption-password').pwstrength(showVerdicts: false) + + $.getJSON("/js/rates.json", (data) -> + currencies = Object.keys(data) + currencies = currencies.sort() + currencies.pop() + + $.each(currencies, (i, v) -> + $('#currency').append("<option value='#{v}'>#{v}</option>") + ) + $("#currency option[value='CAD']").attr('selected', 'selected') + + $('#currency').change(-> + currency = $(this).val() + return unless currency + + $('#symbol option').remove() + symbols = Object.keys(data[currency]) + $.each(symbols, (i, v) -> + return if v == 'localbitcoins' + $('#symbol').append("<option value='#{v}'>#{v}</option>") + ) + + switch currency + when 'CAD' + $("#symbol option[value='quadrigacx']").attr('selected', 'selected') + when 'USD' + $("#symbol option[value='bitstamp']").attr('selected', 'selected') + ) + + user = $('#username').val() + $.getJSON("/#{user}.json", (data) -> + data.commission ?= 0 + data.unit ?= 'BTC' + $('#email').val(data.email) + $('#title').val(data.title) + $('#logo').val(data.logo) + $('#address').val(data.address) + $('#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() + ) + ) + + units = ['BTC', 'mBTC', 'µBTC', 'bits', 'satoshis'] + $.each(units, (i, v) -> + $('#unit').append("<option value='#{v}'>#{v}</option>") + ) + + $('#setup').submit(-> + $('#setup .form-control').blur() + if $('#setup .has-error').length > 0 + $('#setup .has-error').effect('shake', 500) + return false + ) +) + |
