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