From fd17454fa271010f776805b6296fcaa01ae3725c Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 26 Mar 2019 14:16:54 -0600 Subject: [PATCH] Add balance card to home page, enable pull-to-refresh --- www/css/styles.css | 32 ++++++++++++++++++++++++++++++++ www/js/home.js | 38 ++++++++++++++++++++++++++++++++++++++ www/pages/home.html | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 www/css/styles.css create mode 100644 www/js/home.js diff --git a/www/css/styles.css b/www/css/styles.css new file mode 100644 index 0000000..c6d9435 --- /dev/null +++ b/www/css/styles.css @@ -0,0 +1,32 @@ +/* +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ +/* + Created on : Mar 26, 2019, 1:03:44 PM + Author : Skylar Ittner +*/ + +h1.display { + font-size: 8rem; + font-weight: 300; + margin: 0; +} + +h2.display { + font-size: 6rem; + font-weight: 300; + margin: 0; +} + +h3.display { + font-size: 4rem; + font-weight: 300; + margin: 0; +} + +.card-header .secondary-text { + font-weight: 300; + margin-left: 1em; +} \ No newline at end of file diff --git a/www/js/home.js b/www/js/home.js new file mode 100644 index 0000000..b0f5ba0 --- /dev/null +++ b/www/js/home.js @@ -0,0 +1,38 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +var accountBalance = 0.0; + +$(".view-main").on("ptr:refresh", ".ptr-content", function () { + loadHomePage(function () { + setTimeout(app.ptr.done, 750); + }); +}); + +function loadBalance(callback) { + $("#balance-error-icon").css("display", "none"); + $("#balance-loading").css("display", ""); + callAPI("checkbalance", { + key: localStorage.getItem("key") + }, function (data) { + accountBalance = data.balance; + $("#balance-amount").text(data.balance); + $("#balance-loading").css("display", "none"); + $("#balance-error").text(""); + callback(true); + }, function (msg) { + $("#balance-loading").css("display", "none"); + $("#balance-error-icon").css("display", ""); + $("#balance-error").text(msg); + callback(false); + }); +} + +function loadHomePage(callback) { + loadBalance(function () { + callback(); + }); +} \ No newline at end of file diff --git a/www/pages/home.html b/www/pages/home.html index a282673..ffa28fa 100644 --- a/www/pages/home.html +++ b/www/pages/home.html @@ -18,13 +18,39 @@ -
+
+
+
+
+
+ Balance +
+ + +
+
+
+
+

$0.00

+
+ +
+
+
+
@@ -36,4 +62,14 @@
+ + + +
\ No newline at end of file