/* * 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/. */ $("#typecodebtn").on("click", function () { app.dialog.prompt('Enter the recipient\'s code', 'Send Money', function (code) { if (code != "") { app.preloader.show(); callAPI("getprofile", { key: localStorage.getItem("key"), id: code }, function (data) { $("#publicid").val(code); loadSendMoneyPage(); }, function (msg) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); } }); }); function sendMoney(id, amount, name) { if (id == "0") { return; } if (amount <= 0) { app.dialog.alert("Please specify an amount.", "Error"); } else if (amount > 999.99) { app.dialog.alert("Please specify an amount less than $999.99.", "Error"); } app.preloader.show(); callAPI("sendmoney", { key: localStorage.getItem("key"), to: id, amount: amount }, function (data) { app.preloader.hide(); router.navigate("/moneysent/" + (amount * 1.0).toFixed(2) + "/" + name); }, function (msg) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); } function loadSendMoneyPage() { app.preloader.show(); if ($("#publicid").val() == "0") { app.preloader.hide(); $("#step1").removeClass("display-none"); $("#step2").addClass("display-none"); } else { $("#step1").addClass("display-none"); $("#step2").removeClass("display-none"); callAPI("getprofile", { key: localStorage.getItem("key"), id: $("#publicid").val() }, function (data) { app.preloader.hide(); console.log("Profile", data.profile); $("#person-name").text(data.profile.name); if (data.profile.verified) { $("#verified-badge").removeClass("display-none"); } else { $("#unverified-badge").removeClass("display-none"); } }, function (msg) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); } } $(".preset-amount-button").click(function () { $($(this).data("target")).val($(this).data("amount")); }); $("#sendbtn").click(function () { sendMoney($("#publicid").val(), $("#amount-box").val(), $("#person-name").text()); });