diff options
author | Paul Duncan <pabs@pablotron.org> | 2020-03-06 21:01:40 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2020-03-06 21:01:40 -0500 |
commit | 2ac74dc3448e4c799351ed60241848e286239836 (patch) | |
tree | 5e4e12f373d0948ac75ed1131c1525ede565980b /public/face.js | |
parent | c922baf33c15fed5877f49484f4c43911d81b0c3 (diff) | |
download | alonzo-mood-calculator-2ac74dc3448e4c799351ed60241848e286239836.tar.bz2 alonzo-mood-calculator-2ac74dc3448e4c799351ed60241848e286239836.zip |
ui cleanup
Diffstat (limited to 'public/face.js')
-rw-r--r-- | public/face.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/public/face.js b/public/face.js index cb10e0b..1e8e2ad 100644 --- a/public/face.js +++ b/public/face.js @@ -3,7 +3,11 @@ jQuery(function($) { // default base price var BASE_PRICE = 55.73; + + // current price (fetched below from current.json) var CURRENT = 0; + + // path to JSON data var DATA_URL = './current.json'; /** @@ -218,6 +222,21 @@ jQuery(function($) { return false; }); + // set base price + $('#base').text(BASE_PRICE); + + $('#help-toggle').click(function() { + // toggle help visibility + $('#help').toggleClass('hidden'); + + // update text + var text = $('#help').hasClass('hidden') ? 'Show Help' : 'Hide Help'; + $(this).text(text); + + // stop event + return false; + }); + // fetch current price as percent and populate #rate $.ajax({ method: 'GET', @@ -226,7 +245,10 @@ jQuery(function($) { }).fail(function(r) { alert("Couldn't fetch current data."); }).done(function(r) { + // cache current price CURRENT = to_percent(r.ask); + + // update field $('#rate').val(CURRENT); }); }); |