paypro: minor refactor - clean up whitespace in directives.
This commit is contained in:
parent
d58bfe9de8
commit
80ceca3b73
1 changed files with 142 additions and 135 deletions
|
|
@ -12,10 +12,22 @@ angular.module('copayApp.directives')
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function(scope, elem, attrs, ctrl) {
|
link: function(scope, elem, attrs, ctrl) {
|
||||||
var validator = function(value) {
|
var validator = function(value) {
|
||||||
var uri = copay.HDPath.parseBitcoinURI(value);
|
var uri;
|
||||||
|
|
||||||
// Is this a payment protocol URI (BIP-72)?
|
if (/^https?:\/\//.test(value)) {
|
||||||
if (uri && uri.merchant) {
|
uri = { merchant: value };
|
||||||
|
} else {
|
||||||
|
uri = copay.HDPath.parseBitcoinURI(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular Address
|
||||||
|
if (!uri || !uri.merchant) {
|
||||||
|
var a = new Address(value);
|
||||||
|
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === config.networkName);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payment Protocol URI (BIP-72)
|
||||||
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
||||||
var balance = $rootScope.availableBalance;
|
var balance = $rootScope.availableBalance;
|
||||||
var available = +(balance * config.unitToSatoshi).toFixed(0);
|
var available = +(balance * config.unitToSatoshi).toFixed(0);
|
||||||
|
|
@ -147,11 +159,6 @@ angular.module('copayApp.directives')
|
||||||
ctrl.$setValidity('validAddress', true);
|
ctrl.$setValidity('validAddress', true);
|
||||||
|
|
||||||
return 'Merchant: '+ uri.merchant;
|
return 'Merchant: '+ uri.merchant;
|
||||||
}
|
|
||||||
|
|
||||||
var a = new Address(value);
|
|
||||||
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === config.networkName);
|
|
||||||
return value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ctrl.$parsers.unshift(validator);
|
ctrl.$parsers.unshift(validator);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue