Add FAB to home screen for quickly scanning any recognized barcode (tracking, drop box, crypto wallet)
This commit is contained in:
parent
0d168c3420
commit
c173912190
@ -14,6 +14,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
height: calc(100% - calc(var(--f7-card-margin-vertical) * 2));
|
||||
}
|
||||
|
||||
#scan-barcode-fab a svg {
|
||||
height: calc(var(--f7-fab-size) / 2);
|
||||
width: calc(var(--f7-fab-size) / 2);
|
||||
fill: var(--f7-fab-text-color);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Receipt viewer
|
||||
|
2
www/assets/images/qrcode-viewfinder.svg
Normal file
2
www/assets/images/qrcode-viewfinder.svg
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg version="1.1" viewBox="0 0 135.47 135.47" xmlns="http://www.w3.org/2000/svg"><path d="m7.7889 1.5896c-3.4235 0-6.2013 2.7778-6.2013 6.2013v28.939c0 3.4365 2.7778 6.2008 6.2013 6.2008 3.4235 0 6.2008-2.7643 6.2008-6.2008v-22.738h22.738c3.4365 0 6.2008-2.7773 6.2008-6.2008 0-3.4235-2.7643-6.2013-6.2008-6.2013zm90.954 0c-3.4365 0-6.2008 2.7778-6.2008 6.2013 0 3.4235 2.7643 6.2008 6.2008 6.2008h22.738v22.738c0 3.4365 2.7643 6.2008 6.2008 6.2008s6.2013-2.7643 6.2013-6.2008v-28.939c0-3.4235-2.7648-6.2013-6.2013-6.2013zm-63.538 24.747c-4.8995-1e-6 -8.871 4.1383-8.871 8.8715v17.742c0 5.0641 3.9715 8.8715 8.871 8.8715h17.743c4.8977 0 8.871-3.8075 8.871-8.8715v-17.742c0-4.7332-3.9733-8.8715-8.871-8.8715zm47.314 0c-4.8977-1e-6 -8.871 4.1383-8.871 8.8715v17.742c0 5.0641 3.9733 8.8715 8.871 8.8715h17.743c4.8978 0 8.871-3.8075 8.871-8.8715v-17.742c0-4.7332-3.9734-8.8715-8.871-8.8715zm-47.314 8.8715h17.743v17.742h-17.743zm47.314 0h17.743v17.742h-17.743zm-39.922 4.4355c-1.6338 0-2.9568 1.4968-2.9568 2.9568v2.9573c0 1.7927 1.323 2.9568 2.9568 2.9568h2.9573c1.6265 0 2.9568-1.1641 2.9568-2.9568v-2.9573c0-1.4601-1.3305-2.9568-2.9568-2.9568zm47.314 0c-1.6265 0-2.9573 1.4968-2.9573 2.9568v2.9568c0 1.7927 1.331 2.9573 2.9573 2.9573h2.9568c1.6264 0 2.9568-1.1646 2.9568-2.9573v-2.9568c0-1.4601-1.3305-2.9568-2.9568-2.9568zm-16.264 34.005v35.486h11.828v-17.742h5.9142v5.9142h17.742v-23.658h-5.9142v5.9142h-11.828v-5.9142zm-38.442 0.0011c-4.8995 0-8.8715 4.1402-8.8715 8.8715v17.742c0 5.0641 3.972 8.8715 8.8715 8.8715h17.742c4.8977 0 8.8715-3.8074 8.8715-8.8715v-17.742c0-4.7313-3.9739-8.8715-8.8715-8.8715zm0 8.8715h17.742v17.742h-17.742zm7.3923 4.4355c-1.6338 0-2.9568 1.4968-2.9568 2.9568v2.9573c0 1.7927 1.323 2.9568 2.9568 2.9568h2.9573c1.6265 0 2.9568-1.1641 2.9568-2.9568v-2.9573c0-1.46-1.3305-2.9568-2.9568-2.9568zm-34.809 5.583c-3.4235 0-6.2013 2.7648-6.2013 6.2013v28.939c0 3.4365 2.7778 6.2008 6.2013 6.2008h28.939c3.4365-1e-5 6.2008-2.7643 6.2008-6.2008 0-3.4365-2.7643-6.2013-6.2008-6.2013h-22.738v-22.737c0-3.4365-2.7773-6.2013-6.2008-6.2013zm119.89 0c-3.4365 0-6.2013 2.7648-6.2013 6.2013v22.737h-22.737c-3.4365 0-6.2013 2.7648-6.2013 6.2013 0 3.4365 2.7648 6.2008 6.2013 6.2008h28.939c3.4365-1e-5 6.2008-2.7643 6.2008-6.2008v-28.939c0-3.4365-2.7643-6.2013-6.2008-6.2013zm-36.288 10.681v5.9142h5.9142v-5.9142zm11.828 0v5.9142h5.9142v-5.9142z" stroke-width=".26458"/></svg>
|
After Width: | Height: | Size: 2.4 KiB |
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
var walletPubKeyRegex = /^[0-9a-zA-Z]{25,}$/;
|
||||
var walletPubKeyRegex = /^(bc1|[13]|D)[a-zA-HJ-NP-Z0-9]{25,}$/;
|
||||
|
||||
function scanWalletQrCode(callback) {
|
||||
scanBarcode(function (result) {
|
||||
|
52
www/assets/js/home.js
Normal file
52
www/assets/js/home.js
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
function openGenericBarcodeScanner() {
|
||||
scanBarcode(function (result) {
|
||||
var code = "";
|
||||
var action = "";
|
||||
if (result.startsWith("https://helena.express/track#")) {
|
||||
// tracking code from receipt
|
||||
code = result.split("#")[1];
|
||||
action = "track";
|
||||
} else if (result.startsWith("https://helena.express/dropandsend#")) {
|
||||
code = result.split("#")[1];
|
||||
action = "pickupcode";
|
||||
} else if (result.startsWith("https://helena.express/das/pickup#")) {
|
||||
code = result.split("#")[1];
|
||||
action = "pickupcode";
|
||||
} else if (result.startsWith("http") && result.includes("#")) {
|
||||
if (trackingcoderegex.test(result.split("#")[1])) {
|
||||
code = result.split("#")[1];
|
||||
action = "track";
|
||||
}
|
||||
} else if (walletPubKeyRegex.test(result)) {
|
||||
code = result;
|
||||
action = "cryptowallet";
|
||||
} else if (trackingcoderegex.test(result)) {
|
||||
code = result;
|
||||
action = "track";
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case "track":
|
||||
openTrackingInfoPage(code);
|
||||
break;
|
||||
case "pickupcode":
|
||||
sendPickupCode(code);
|
||||
break;
|
||||
case "cryptowallet":
|
||||
router.navigate("/crypto/balance/" + code);
|
||||
break;
|
||||
default:
|
||||
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
||||
return;
|
||||
}
|
||||
}, function () {
|
||||
app.dialog.alert("Something went wrong and we can't scan right now.", "Error");
|
||||
});
|
||||
}
|
@ -64,6 +64,7 @@
|
||||
<script src="assets/js/rates.js"></script>
|
||||
<script src="assets/js/account.js"></script>
|
||||
<script src="assets/js/shop.js"></script>
|
||||
<script src="assets/js/home.js"></script>
|
||||
<script src="assets/js/crypto.js"></script>
|
||||
|
||||
<script src="routes.js"></script>
|
||||
|
@ -22,6 +22,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fab fab-right-bottom" id="scan-barcode-fab">
|
||||
<a href="#" onclick="openGenericBarcodeScanner()">
|
||||
<svg version="1.1" viewBox="0 0 135.47 135.47" xmlns="http://www.w3.org/2000/svg"><path d="m7.7889 1.5896c-3.4235 0-6.2013 2.7778-6.2013 6.2013v28.939c0 3.4365 2.7778 6.2008 6.2013 6.2008 3.4235 0 6.2008-2.7643 6.2008-6.2008v-22.738h22.738c3.4365 0 6.2008-2.7773 6.2008-6.2008 0-3.4235-2.7643-6.2013-6.2008-6.2013zm90.954 0c-3.4365 0-6.2008 2.7778-6.2008 6.2013 0 3.4235 2.7643 6.2008 6.2008 6.2008h22.738v22.738c0 3.4365 2.7643 6.2008 6.2008 6.2008s6.2013-2.7643 6.2013-6.2008v-28.939c0-3.4235-2.7648-6.2013-6.2013-6.2013zm-63.538 24.747c-4.8995-1e-6 -8.871 4.1383-8.871 8.8715v17.742c0 5.0641 3.9715 8.8715 8.871 8.8715h17.743c4.8977 0 8.871-3.8075 8.871-8.8715v-17.742c0-4.7332-3.9733-8.8715-8.871-8.8715zm47.314 0c-4.8977-1e-6 -8.871 4.1383-8.871 8.8715v17.742c0 5.0641 3.9733 8.8715 8.871 8.8715h17.743c4.8978 0 8.871-3.8075 8.871-8.8715v-17.742c0-4.7332-3.9734-8.8715-8.871-8.8715zm-47.314 8.8715h17.743v17.742h-17.743zm47.314 0h17.743v17.742h-17.743zm-39.922 4.4355c-1.6338 0-2.9568 1.4968-2.9568 2.9568v2.9573c0 1.7927 1.323 2.9568 2.9568 2.9568h2.9573c1.6265 0 2.9568-1.1641 2.9568-2.9568v-2.9573c0-1.4601-1.3305-2.9568-2.9568-2.9568zm47.314 0c-1.6265 0-2.9573 1.4968-2.9573 2.9568v2.9568c0 1.7927 1.331 2.9573 2.9573 2.9573h2.9568c1.6264 0 2.9568-1.1646 2.9568-2.9573v-2.9568c0-1.4601-1.3305-2.9568-2.9568-2.9568zm-16.264 34.005v35.486h11.828v-17.742h5.9142v5.9142h17.742v-23.658h-5.9142v5.9142h-11.828v-5.9142zm-38.442 0.0011c-4.8995 0-8.8715 4.1402-8.8715 8.8715v17.742c0 5.0641 3.972 8.8715 8.8715 8.8715h17.742c4.8977 0 8.8715-3.8074 8.8715-8.8715v-17.742c0-4.7313-3.9739-8.8715-8.8715-8.8715zm0 8.8715h17.742v17.742h-17.742zm7.3923 4.4355c-1.6338 0-2.9568 1.4968-2.9568 2.9568v2.9573c0 1.7927 1.323 2.9568 2.9568 2.9568h2.9573c1.6265 0 2.9568-1.1641 2.9568-2.9568v-2.9573c0-1.46-1.3305-2.9568-2.9568-2.9568zm-34.809 5.583c-3.4235 0-6.2013 2.7648-6.2013 6.2013v28.939c0 3.4365 2.7778 6.2008 6.2013 6.2008h28.939c3.4365-1e-5 6.2008-2.7643 6.2008-6.2008 0-3.4365-2.7643-6.2013-6.2008-6.2013h-22.738v-22.737c0-3.4365-2.7773-6.2013-6.2008-6.2013zm119.89 0c-3.4365 0-6.2013 2.7648-6.2013 6.2013v22.737h-22.737c-3.4365 0-6.2013 2.7648-6.2013 6.2013 0 3.4365 2.7648 6.2008 6.2013 6.2008h28.939c3.4365-1e-5 6.2008-2.7643 6.2008-6.2008v-28.939c0-3.4365-2.7643-6.2013-6.2008-6.2013zm-36.288 10.681v5.9142h5.9142v-5.9142zm11.828 0v5.9142h5.9142v-5.9142z" stroke-width=".26458"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="page-content noselect">
|
||||
<div class="row justify-content-center margin-top">
|
||||
<div class="col-100 medium-90 xlarge-75">
|
||||
|
@ -52,6 +52,17 @@ var routes = [
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/crypto/balance/:walletaddress',
|
||||
content: compiledPages.crypto(),
|
||||
name: 'crypto',
|
||||
on: {
|
||||
pageAfterIn: function (e, page) {
|
||||
console.log(page);
|
||||
displayWalletBalance(page.route.params.walletaddress);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
|
Loading…
x
Reference in New Issue
Block a user