Ref and clean code
This commit is contained in:
parent
bb6b11be78
commit
95c0371f9b
4 changed files with 24 additions and 33 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, $state, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, moment, popupService, gettextCatalog, bwcError, $ionicHistory) {
|
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, $state, lodash, bitpayCardService, moment, popupService, gettextCatalog, $ionicHistory) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$scope.dateRange = 'last30Days';
|
$scope.dateRange = 'last30Days';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.controllers').controller('bitpayCardIntroController', function($scope, $log, $state, $timeout, $ionicHistory, storageService, externalLinkService, bitpayCardService, gettextCatalog, popupService) {
|
angular.module('copayApp.controllers').controller('bitpayCardIntroController', function($scope, $log, $state, $ionicHistory, storageService, externalLinkService, bitpayCardService, gettextCatalog, popupService) {
|
||||||
|
|
||||||
var checkOtp = function(obj, cb) {
|
var checkOtp = function(obj, cb) {
|
||||||
if (obj.otp) {
|
if (obj.otp) {
|
||||||
|
|
@ -41,12 +41,11 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
|
||||||
$ionicHistory.nextViewOptions({
|
$ionicHistory.nextViewOptions({
|
||||||
disableAnimate: true
|
disableAnimate: true
|
||||||
});
|
});
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home').then(function() {
|
||||||
if (data.cards[0]) {
|
if (data.cards[0]) {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.bitpayCard', {id: data.cards[0].id});
|
$state.transitionTo('tabs.bitpayCard', {id: data.cards[0].id});
|
||||||
}, 100);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('bitpayCardService', function($http, $log, $window, lodash, storageService, bitauthService, platformInfo) {
|
angular.module('copayApp.services').factory('bitpayCardService', function($http, $log, lodash, storageService, bitauthService, platformInfo) {
|
||||||
var root = {};
|
var root = {};
|
||||||
var BITPAY_CARD_NETWORK = 'livenet';
|
var BITPAY_CARD_NETWORK = 'livenet';
|
||||||
var BITPAY_CARD_API_URL = BITPAY_CARD_NETWORK == 'livenet' ? 'https://bitpay.com' : 'https://test.bitpay.com';
|
var BITPAY_CARD_API_URL = BITPAY_CARD_NETWORK == 'livenet' ? 'https://bitpay.com' : 'https://test.bitpay.com';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore, lodash) {
|
angular.module('copayApp.services').factory('incomingData', function($log, $state, $window, bitcore, lodash) {
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
@ -45,10 +45,9 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
||||||
// data extensions for Payment Protocol with non-backwards-compatible request
|
// data extensions for Payment Protocol with non-backwards-compatible request
|
||||||
if ((/^bitcoin:\?r=[\w+]/).exec(data)) {
|
if ((/^bitcoin:\?r=[\w+]/).exec(data)) {
|
||||||
data = decodeURIComponent(data.replace('bitcoin:?r=', ''));
|
data = decodeURIComponent(data.replace('bitcoin:?r=', ''));
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.send').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.send.confirm', {paypro: data});
|
$state.transitionTo('tabs.send.confirm', {paypro: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,8 +62,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
||||||
|
|
||||||
var amount = parsed.amount ? parsed.amount : '';
|
var amount = parsed.amount ? parsed.amount : '';
|
||||||
|
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.send').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
if (parsed.r) {
|
if (parsed.r) {
|
||||||
$state.transitionTo('tabs.send.confirm', {paypro: parsed.r});
|
$state.transitionTo('tabs.send.confirm', {paypro: parsed.r});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -74,31 +72,28 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
||||||
$state.transitionTo('tabs.send.amount', {toAddress: addr});
|
$state.transitionTo('tabs.send.amount', {toAddress: addr});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Plain URL
|
// Plain URL
|
||||||
} else if (/^https?:\/\//.test(data)) {
|
} else if (/^https?:\/\//.test(data)) {
|
||||||
var currentState = $state.current.name;
|
var currentState = $state.current.name;
|
||||||
if (lodash.indexOf(ignoreState, currentState) != -1) return false;
|
if (lodash.indexOf(ignoreState, currentState) != -1) return false;
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.send').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.send.confirm', {paypro: data});
|
$state.transitionTo('tabs.send.confirm', {paypro: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Plain Address
|
// Plain Address
|
||||||
} else if (bitcore.Address.isValid(data, 'livenet')) {
|
} else if (bitcore.Address.isValid(data, 'livenet')) {
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.send').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
} else if (bitcore.Address.isValid(data, 'testnet')) {
|
} else if (bitcore.Address.isValid(data, 'testnet')) {
|
||||||
$state.go('tabs.send');
|
$state.go('tabs.send').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Protocol
|
// Protocol
|
||||||
|
|
@ -112,30 +107,27 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
||||||
var secret = getParameterByName('secret', data);
|
var secret = getParameterByName('secret', data);
|
||||||
var email = getParameterByName('email', data);
|
var email = getParameterByName('email', data);
|
||||||
var otp = getParameterByName('otp', data);
|
var otp = getParameterByName('otp', data);
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.bitpayCardIntro', {
|
$state.transitionTo('tabs.bitpayCardIntro', {
|
||||||
secret: secret,
|
secret: secret,
|
||||||
email: email,
|
email: email,
|
||||||
otp: otp
|
otp: otp
|
||||||
});
|
});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Join
|
// Join
|
||||||
} else if (data && data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
} else if (data && data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.add.join', {url: data});
|
$state.transitionTo('tabs.add.join', {url: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Old join
|
// Old join
|
||||||
} else if (data && data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
} else if (data && data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home').then(function() {
|
||||||
$timeout(function() {
|
|
||||||
$state.transitionTo('tabs.add.join', {url: data});
|
$state.transitionTo('tabs.add.join', {url: data});
|
||||||
}, 100);
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue