replace scope variables - rename shuffle words function
This commit is contained in:
parent
7b3101f493
commit
14379b3c63
2 changed files with 24 additions and 23 deletions
|
|
@ -117,7 +117,7 @@
|
||||||
Please tap the words in order to confirm your backup phrase is correctly written.
|
Please tap the words in order to confirm your backup phrase is correctly written.
|
||||||
</p>
|
</p>
|
||||||
<div class="panel words text-left">
|
<div class="panel words text-left">
|
||||||
<span ng-repeat="cword in customWords track by $index" ng-show="customWords[$index]">
|
<span ng-repeat="cword in wordsC.customWords track by $index" ng-show="wordsC.customWords[$index]">
|
||||||
<button class="button radius tiny words" ng-click="removeButton($index, cword)">{{cword.word}}</button>
|
<button class="button radius tiny words" ng-click="removeButton($index, cword)">{{cword.word}}</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
$scope.customWords = [];
|
self.customWords = [];
|
||||||
self.walletName = fc.credentials.walletName;
|
self.walletName = fc.credentials.walletName;
|
||||||
|
|
||||||
var handleEncryptedWallet = function(client, cb) {
|
var handleEncryptedWallet = function(client, cb) {
|
||||||
|
|
@ -16,19 +16,6 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function init() {
|
|
||||||
$scope.passphrase = '';
|
|
||||||
_shuffleWords();
|
|
||||||
$scope.customWords = [];
|
|
||||||
self.step = 1;
|
|
||||||
self.deleted = false;
|
|
||||||
self.credentialsEncrypted = false;
|
|
||||||
self.selectComplete = false;
|
|
||||||
self.backupError = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic)
|
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic)
|
||||||
self.deleted = true;
|
self.deleted = true;
|
||||||
|
|
||||||
|
|
@ -40,6 +27,19 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
initWords();
|
initWords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
$scope.passphrase = '';
|
||||||
|
self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords);
|
||||||
|
self.customWords = [];
|
||||||
|
self.step = 1;
|
||||||
|
self.deleted = false;
|
||||||
|
self.credentialsEncrypted = false;
|
||||||
|
self.selectComplete = false;
|
||||||
|
self.backupError = false;
|
||||||
|
};
|
||||||
|
|
||||||
self.goToStep = function(n) {
|
self.goToStep = function(n) {
|
||||||
self.step = n;
|
self.step = n;
|
||||||
if (self.step == 1)
|
if (self.step == 1)
|
||||||
|
|
@ -56,14 +56,15 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
self.xPrivKey = fc.credentials.xPrivKey;
|
self.xPrivKey = fc.credentials.xPrivKey;
|
||||||
walletService.lock(fc);
|
walletService.lock(fc);
|
||||||
self.mnemonicWords = words.split(/[\u3000\s]+/);
|
self.mnemonicWords = words.split(/[\u3000\s]+/);
|
||||||
_shuffleWords();
|
self.shuffledMnemonicWords = shuffledWords(self.mnemonicWords);
|
||||||
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
|
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
|
||||||
self.useIdeograms = words.indexOf("\u3000") >= 0;
|
self.useIdeograms = words.indexOf("\u3000") >= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
function _shuffleWords() {
|
function shuffledWords(words) {
|
||||||
var sort = lodash.sortBy(self.mnemonicWords);
|
var sort = lodash.sortBy(words);
|
||||||
self.shuffledMnemonicWords = lodash.map(sort, function(w) {
|
|
||||||
|
return lodash.map(sort, function(w) {
|
||||||
return {
|
return {
|
||||||
word: w,
|
word: w,
|
||||||
selected: false
|
selected: false
|
||||||
|
|
@ -115,19 +116,19 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
word: item.word,
|
word: item.word,
|
||||||
prevIndex: index
|
prevIndex: index
|
||||||
};
|
};
|
||||||
$scope.customWords.push(newWord);
|
self.customWords.push(newWord);
|
||||||
self.shuffledMnemonicWords[index].selected = true;
|
self.shuffledMnemonicWords[index].selected = true;
|
||||||
self.shouldContinue();
|
self.shouldContinue();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeButton = function(index, item) {
|
$scope.removeButton = function(index, item) {
|
||||||
$scope.customWords.splice(index, 1);
|
self.customWords.splice(index, 1);
|
||||||
self.shuffledMnemonicWords[item.prevIndex].selected = false;
|
self.shuffledMnemonicWords[item.prevIndex].selected = false;
|
||||||
self.shouldContinue();
|
self.shouldContinue();
|
||||||
};
|
};
|
||||||
|
|
||||||
self.shouldContinue = function() {
|
self.shouldContinue = function() {
|
||||||
if ($scope.customWords.length == 12)
|
if (self.customWords.length == 12)
|
||||||
self.selectComplete = true;
|
self.selectComplete = true;
|
||||||
else
|
else
|
||||||
self.selectComplete = false;
|
self.selectComplete = false;
|
||||||
|
|
@ -138,7 +139,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
var separator = self.useIdeograms ? '\u3000' : ' ';
|
var separator = self.useIdeograms ? '\u3000' : ' ';
|
||||||
var customSentence = lodash.pluck($scope.customWords, 'word').join(separator);
|
var customSentence = lodash.pluck(self.customWords, 'word').join(separator);
|
||||||
var passphrase = $scope.passphrase || '';
|
var passphrase = $scope.passphrase || '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue