/* * 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(); }); }