mirror of https://github.com/BTCPrivate/copay.git
add first uri handler
This commit is contained in:
parent
16293b035d
commit
433f1570de
16
index.html
16
index.html
|
@ -884,6 +884,21 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- URI PAYMENT -->
|
||||||
|
<script type="text/ng-template" id="uri_payment.html">
|
||||||
|
<h3 class="text-center">
|
||||||
|
Preparing payment...
|
||||||
|
</h3>
|
||||||
|
<div data-ng-init="" data-ng-controller="UriPaymentController">
|
||||||
|
<p>Protocol: {{protocol}}</p>
|
||||||
|
<p>To: {{address}}</p>
|
||||||
|
<p>Amount: {{amount}}</p>
|
||||||
|
<p>Message:</p>
|
||||||
|
<div class="alert-box secondary radius">{{message}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- NOT FOUND -->
|
<!-- NOT FOUND -->
|
||||||
<script type="text/ng-template" id="404.html">
|
<script type="text/ng-template" id="404.html">
|
||||||
<h2 class="text-center">404</h2>
|
<h2 class="text-center">404</h2>
|
||||||
|
@ -938,6 +953,7 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
||||||
<script src="js/controllers/setup.js"></script>
|
<script src="js/controllers/setup.js"></script>
|
||||||
<script src="js/controllers/import.js"></script>
|
<script src="js/controllers/import.js"></script>
|
||||||
<script src="js/controllers/settings.js"></script>
|
<script src="js/controllers/settings.js"></script>
|
||||||
|
<script src="js/controllers/uriPayment.js"></script>
|
||||||
|
|
||||||
<script src="js/init.js"></script>
|
<script src="js/init.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams) {
|
||||||
|
var data = $routeParams.data;
|
||||||
|
var splitDots = data.split(':');
|
||||||
|
$scope.protocol = splitDots[0];
|
||||||
|
data = splitDots[1];
|
||||||
|
var splitQuestion = data.split('?');
|
||||||
|
$scope.address = splitQuestion[0];
|
||||||
|
data = decodeURIComponent(splitQuestion[1]);
|
||||||
|
var search = splitQuestion[1];
|
||||||
|
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||||
|
function(key, value) {
|
||||||
|
return key === "" ? value : decodeURIComponent(value);
|
||||||
|
});
|
||||||
|
$scope.amount = data.amount;
|
||||||
|
$scope.message = data.message;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
|
@ -26,10 +26,6 @@ angular
|
||||||
templateUrl: 'addresses.html',
|
templateUrl: 'addresses.html',
|
||||||
validate: true
|
validate: true
|
||||||
})
|
})
|
||||||
.when('/join/:id', {
|
|
||||||
templateUrl: 'join.html',
|
|
||||||
validate: true
|
|
||||||
})
|
|
||||||
.when('/transactions', {
|
.when('/transactions', {
|
||||||
templateUrl: 'transactions.html',
|
templateUrl: 'transactions.html',
|
||||||
validate: true
|
validate: true
|
||||||
|
@ -49,6 +45,9 @@ angular
|
||||||
.when('/unsupported', {
|
.when('/unsupported', {
|
||||||
templateUrl: 'unsupported.html'
|
templateUrl: 'unsupported.html'
|
||||||
})
|
})
|
||||||
|
.when('/uri_payment/:data', {
|
||||||
|
templateUrl: 'uri_payment.html'
|
||||||
|
})
|
||||||
.otherwise({
|
.otherwise({
|
||||||
templateUrl: '404.html'
|
templateUrl: '404.html'
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
var UriHandler = function() {};
|
var UriHandler = function() {};
|
||||||
|
|
||||||
UriHandler.prototype.register = function() {
|
UriHandler.prototype.register = function() {
|
||||||
|
var base = window.location.origin + '/';
|
||||||
|
var url = base + '#/uri_payment/%s';
|
||||||
|
console.log(url);
|
||||||
navigator.registerProtocolHandler('bitcoin',
|
navigator.registerProtocolHandler('bitcoin',
|
||||||
'uri=%s',
|
url, 'Copay');
|
||||||
'Copay');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
angular.module('copayApp.services').value('uriHandler', new UriHandler());
|
angular.module('copayApp.services').value('uriHandler', new UriHandler());
|
||||||
|
|
Loading…
Reference in New Issue