diff --git a/www/js/addfunds.js b/www/js/addfunds.js new file mode 100644 index 0000000..5d378c4 --- /dev/null +++ b/www/js/addfunds.js @@ -0,0 +1,87 @@ +/* + * 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 stripe = null; +var elements = null; +var card = null; + +function initPaymentPage() { + $("#tx-off-percent").text(+(SETTINGS["addfunds_percent"] * 100).toFixed(2)); + initStripe(); +} + +function initStripe() { + // Wait for Stripe to be loaded + if (typeof Stripe == 'undefined') { + setTimeout(initStripe, 500); + return; + } + stripe = Stripe(SETTINGS["stripe_pubkey"]); + elements = stripe.elements(); + + card = elements.create('card', {}); + + card.mount('#card-element'); + + card.addEventListener('change', function (event) { + var displayError = document.getElementById('card-errors'); + if (event.error) { + displayError.textContent = event.error.message; + } else { + displayError.textContent = ''; + } + }); +} + +function addFeesToAmount() { + if ($("#funds-amount").val() == "") { + return; + } + var amount = $("#funds-amount").val() * 1.0; + + var stripefees = 0.30 + (amount * 0.029); + var totalfees = amount * SETTINGS["addfunds_percent"]; + + amount = (amount + (stripefees > totalfees ? 0.30 : 0)) / + (1 - (stripefees > totalfees ? 0.029 : SETTINGS["addfunds_percent"])); + + $("#funds-amount").val(amount.toFixed(2)); +} + + +function chargeCard() { + if ($("#funds-amount").val() == "") { + return; + } + if (stripe == null) { + return; + } + app.preloader.show(); + stripe.createToken(card).then(function (result) { + if (result.error) { + // Inform the customer that there was an error. + app.preloader.hide(); + var errorElement = document.getElementById('card-errors'); + errorElement.textContent = result.error.message; + } else { + callAPI("addfunds", { + key: localStorage.getItem("key"), + amount: $("#funds-amount").val(), + token: result.token.id + }, function (response) { + app.preloader.hide(); + router.navigate("/fundsadded/" + response.charged_amount.toFixed(2) + "/" + response.final_amount.toFixed(2)); + }, function (error) { + app.preloader.hide(); + app.dialog.alert(error, "Error"); + }); + } + }); +} + +$(".preset-amount-button").click(function () { + $($(this).data("target")).val($(this).data("amount")); +}); \ No newline at end of file diff --git a/www/js/map.js b/www/js/map.js index 4446243..8dddd70 100644 --- a/www/js/map.js +++ b/www/js/map.js @@ -22,7 +22,7 @@ leafletmap.attributionControl.setPrefix(""); var leafletgllayer = L.mapboxGL({ attribution: "© OpenMapTiles © OpenStreetMap contributors", accessToken: 'none', - style: 'https://maps.netsyms.net/styles/klokantech-3d-gl/style.json', + style: SETTINGS["map_style_json"], pitch: 0 }); diff --git a/www/pages/addfunds.html b/www/pages/addfunds.html new file mode 100644 index 0000000..7880b43 --- /dev/null +++ b/www/pages/addfunds.html @@ -0,0 +1,67 @@ + + +
+ + + + +
+
+
+ +
+
+
+
+
$
+ +
+ +

+ + + +

+ +
+
+ Loading secure card form... +
+ +
+ +

+ We don't see your card number; it's sent directly and securely to our payment processor. +

+ Your account balance won't gain the entire amount you choose. + 7% (or the card fees, whichever is greater) is subtracted to + cover fees and maintenance costs. Tap here to add + the fees to your total. +

+ +
+
+ +
+
+
+ + + + +
\ No newline at end of file diff --git a/www/pages/fundsadded.html b/www/pages/fundsadded.html new file mode 100644 index 0000000..81a2877 --- /dev/null +++ b/www/pages/fundsadded.html @@ -0,0 +1,40 @@ + + +
+ + + + +
+ +
+ +
+
+
+
+ Checkmark + +

You paid ${{this.$route.params.amount}} total and added ${{this.$route.params.final_amount}} to your balance.

+ + Close +
+
+
+
+
+ +
+ +
\ No newline at end of file diff --git a/www/pages/home.html b/www/pages/home.html index 3005c0e..53b118b 100644 --- a/www/pages/home.html +++ b/www/pages/home.html @@ -50,7 +50,7 @@ {{else}}