paypro: remove old parse uri code. more debugging.

This commit is contained in:
Christopher Jeffrey 2014-07-30 17:20:50 -07:00 committed by Manuel Araoz
parent 7c39915dd0
commit 7915008433
3 changed files with 17 additions and 22 deletions

View File

@ -15,6 +15,12 @@ angular.module('copayApp.directives')
var validator = function(value) {
// Is payment protocol address?
var uri = copay.HDPath.parseBitcoinURI(value);
var total = '00001000';
console.log('TOTAL:');
console.log(total);
var amount = angular.element(document).find('#amount');
amount.prop('disabled', true);
amount.val(total);
if (uri && uri.merchant) {
scope.wallet.createPaymentTx(uri.merchant, function(ntxid, ca) {
var txp = scope.wallet.txProposals.txps[ntxid];
@ -22,8 +28,7 @@ angular.module('copayApp.directives')
var total = txp.merchant.total;
console.log('TOTAL:');
console.log(total);
var sendForm = angular.element(document).find('[name=sendForm]');
var amount = angular.element(sendForm).find('#amount')
var amount = angular.element(document).find('#amount');
amount.prop('disabled', true);
amount.val(total);
});

View File

@ -59,19 +59,6 @@ HDPath.parseBitcoinURI = function(uri) {
var splitQuestion = data.split('?');
ret.address = splitQuestion[0];
/*
if (splitQuestion.length > 1) {
var search = splitQuestion[1];
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
function(key, value) {
return key === "" ? value : decodeURIComponent(value);
});
ret.amount = parseFloat(data.amount);
ret.message = data.message;
ret.merchant = data.r;
}
*/
if (splitQuestion.length > 1) {
var data = {};
var search = splitQuestion[1];

View File

@ -25,11 +25,17 @@ var TxProposals = require('./TxProposals');
var PrivateKey = require('./PrivateKey');
var copayConfig = require('../../../config');
if (typeof angular !== 'undefined') {
var $http = angular.bootstrap().get('$http');
if (typeof window !== 'undefined') {
var G = window;
} else {
var G = global;
}
var $http = function $http(options, callback) {
if (typeof angular !== 'undefined') {
var $http = G.$http || angular.bootstrap().get('$http');
}
var $http = G.$http || function $http(options, callback) {
if (typeof options === 'string') {
options = { uri: options };
}
@ -81,7 +87,6 @@ var $http = function $http(options, callback) {
xhr.onload = function(event) {
var response = xhr.response;
var buf = new Uint8Array(response);
// return callback(null, xhr, buf);
var headers = {};
(xhr.getAllResponseHeaders() || '').replace(
/(?:\r?\n|^)([^:\r\n]+): *([^\r\n]+)/g,
@ -93,7 +98,7 @@ var $http = function $http(options, callback) {
};
xhr.onerror = function(event) {
return ret._error(null, event, null, options);
return ret._error(null, new Error(event.message), null, options);
};
if (options.body) {
@ -105,8 +110,6 @@ var $http = function $http(options, callback) {
return ret;
}
// require('request')(options, callback);
return ret;
}