From 960b64affe60b1ccbdcc0b3568f6d63e8e6b95c8 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Thu, 1 May 2014 19:08:35 -0300 Subject: [PATCH] added import from text backup --- index.html | 3 +++ js/controllers/import.js | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 542a75b53..71a065a0a 100644 --- a/index.html +++ b/index.html @@ -188,7 +188,10 @@

{{title}}

+
Select a backup file
+
Or just pate the backup text here
+
diff --git a/js/controllers/import.js b/js/controllers/import.js index 2d5630915..27510d60c 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -4,6 +4,13 @@ angular.module('copay.import').controller('ImportController', function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) { $scope.title = 'Import a backup'; + + var _importBackup = function(encryptedObj) { + var passphrase = Passphrase.getBase64($scope.password); + $rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase); + controllerUtils.startNetwork($rootScope.wallet); + }; + $scope.getFile = function() { var reader = new FileReader(); @@ -11,17 +18,18 @@ angular.module('copay.import').controller('ImportController', reader.onloadend = function(evt) { if (evt.target.readyState == FileReader.DONE) { // DONE == 2 var encryptedObj = evt.target.result; - var passphrase = Passphrase.getBase64($scope.password); - $rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase); - controllerUtils.startNetwork($rootScope.wallet); + _importBackup(encryptedObj); } }; + }; - $scope.import = function() { - if ($scope.password != '') { + $scope.import = function() { + if ($scope.password != '') { + if ($scope.backupText != '') { + _importBackup($scope.backupText); + } else { reader.readAsBinaryString($scope.file); } - }; - + } }; });