From 2ac74dc3448e4c799351ed60241848e286239836 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 6 Mar 2020 21:01:40 -0500 Subject: ui cleanup --- public/face.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'public/face.js') 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); }); }); -- cgit v1.2.3