Wallet/js/controllers/import.js

27 lines
874 B
JavaScript
Raw Normal View History

2014-04-25 17:34:24 -03:00
'use strict';
angular.module('copay.import').controller('ImportController',
2014-05-01 18:33:36 -03:00
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
2014-04-25 17:34:24 -03:00
$scope.title = 'Import a backup';
2014-04-25 19:12:13 -03:00
$scope.getFile = function() {
var reader = new FileReader();
// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
2014-05-01 18:33:36 -03:00
var encryptedObj = evt.target.result;
var passphrase = Passphrase.getBase64($scope.password);
$rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
2014-04-25 19:12:13 -03:00
controllerUtils.startNetwork($rootScope.wallet);
}
};
2014-05-01 18:33:36 -03:00
$scope.import = function() {
if ($scope.password != '') {
reader.readAsBinaryString($scope.file);
}
};
2014-04-25 19:12:13 -03:00
};
2014-04-25 17:34:24 -03:00
});