add first uri handler

This commit is contained in:
Manuel Araoz 2014-07-01 19:35:15 -03:00
commit 433f1570de
4 changed files with 43 additions and 6 deletions

View file

@ -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;
});

View file

@ -26,10 +26,6 @@ angular
templateUrl: 'addresses.html',
validate: true
})
.when('/join/:id', {
templateUrl: 'join.html',
validate: true
})
.when('/transactions', {
templateUrl: 'transactions.html',
validate: true
@ -49,6 +45,9 @@ angular
.when('/unsupported', {
templateUrl: 'unsupported.html'
})
.when('/uri_payment/:data', {
templateUrl: 'uri_payment.html'
})
.otherwise({
templateUrl: '404.html'
});

View file

@ -3,9 +3,11 @@
var UriHandler = function() {};
UriHandler.prototype.register = function() {
var base = window.location.origin + '/';
var url = base + '#/uri_payment/%s';
console.log(url);
navigator.registerProtocolHandler('bitcoin',
'uri=%s',
'Copay');
url, 'Copay');
};
angular.module('copayApp.services').value('uriHandler', new UriHandler());