<commit_before>/**
 * @fileOverview PocketCreateCtrl angular controller
 */
'use strict';

define(['./module', 'darkwallet'], function (controllers, DarkWallet) {
  controllers.controller('PocketCreateCtrl', ['$scope', '$wallet', '$history', 'watch', '$tabs', 'modals', 'notify', '_Filter', function($scope, $wallet, $history, watch, $tabs, modals, notify, _) {

    /**
     * Scope variables
     */
    $scope.newPocket = {};


    /**
     * Create a pocket
     */
    $scope.createPocket = function() {
        if ($scope.newPocket.name) {
            var identity = DarkWallet.getIdentity();
            // Don't need the password for old style
            var askPassword = (identity.store.get('version') > 4) ? modals.password : function(title, cb) {cb();};
            askPassword('<PASSWORD> your <PASSWORD>', function(password) {

                // create pocket
                try {
                    identity.wallet.pockets.createPocket($scope.newPocket.name, password);
                } catch (e) {
                    if (e.message.slice(0,4)==='ccm:') {
                        notify.warning(_('Invalid Password'));
                    } else {
                        notify.warning(e.message);
                    }
                    return;
                }
                var pocketIndex = identity.wallet.pockets.hdPockets.length-1;

                // generate an address
                $wallet.generateAddress(pocketIndex, 0);

                // select the pocket
                $scope.selectPocket($scope.newPocket.name, pocketIndex);

                // reset pocket form
                $scope.newPocket = {name:''};
            });
        } else {
            // cancel
            $tabs.open();
        }
    };
}]);
});<commit_msg>Fix relocation to new pocket.<commit_after>/**
 * @fileOverview PocketCreateCtrl angular controller
 */
'use strict';

define(['./module', 'darkwallet'], function (controllers, DarkWallet) {
  controllers.controller('PocketCreateCtrl', ['$scope', '$wallet', '$history', 'watch', '$tabs', 'modals', 'notify', '$location', '_Filter', function($scope, $wallet, $history, watch, $tabs, modals, notify, $location, _) {

    /**
     * Scope variables
     */
    $scope.newPocket = {};


    /**
     * Create a pocket
     */
    $scope.createPocket = function() {
        if ($scope.newPocket.name) {
            var identity = DarkWallet.getIdentity();
            // Don't need the password for old style
            var askPassword = (identity.store.get('version') > 4) ? modals.password : function(title, cb) {cb();};
            askPassword('Write your unlock password', function(password) {

                // create pocket
                try {
                    identity.wallet.pockets.createPocket($scope.newPocket.name, password);
                } catch (e) {
                    if (e.message.slice(0,4)==='ccm:') {
                        notify.warning(_('Invalid Password'));
                    } else {
                        notify.warning(e.message);
                    }
                    return;
                }
                var pocketIndex = identity.wallet.pockets.hdPockets.length-1;

                // generate an address
                $wallet.generateAddress(pocketIndex, 0);

                // reset pocket form
                $scope.newPocket = {name:''};

                // Go to the new pocket
                $location.path('/wallet/dashboard/'+pocketIndex);
            });
        } else {
            // cancel
            $tabs.open();
        }
    };
}]);
});
{'fraction_non_alphanumeric': 0.14361405465699945, 'fraction_numerical': 0.002788622420524261, 'mean_word_length': 1.6433308769344142, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517601', 'n_tokens_mistral': 975, 'n_tokens_neox': 929, 'n_words': 198}