<commit_before>var util = require('util');
var Tab = require('../client/tab').Tab;

var LoginTab = function ()
{
  Tab.call(this);
};

util.inherits(LoginTab, Tab);

LoginTab.prototype.tabName = 'login';
LoginTab.prototype.pageMode = 'single';
LoginTab.prototype.parent = 'main';

LoginTab.prototype.generateHtml = function ()
{
  return require('../../templates/tabs/login.jade')();
};

LoginTab.prototype.angular = function (module) {
  module.controller('LoginCtrl', ['$scope', '$element', '$routeParams',
                                  '$location', 'rpId', '$rootScope',
                                  'rpPopup', '$timeout', 'rpFileDialog','rpNW',
                                  function ($scope, $element, $routeParams,
                                            $location, $id, $rootScope,
                                            popup, $timeout, filedialog, rpNW)
  {
    if ($id.loginStatus) {
      $location.path('/balance');
      return;
    }

    if(!!store.get('walletfile')) {
      $scope.walletfile = store.get('walletfile');
      angular.element("#login_password").focus();
    }

    $scope.fileInputClick = function(element){
      filedialog.openFile(function(evt) {
        $scope.$apply(function() {
          store.set('walletfile', evt);
          $scope.walletfile = evt;
          angular.element("#login_password").focus();
        });
      }, false);
    };

    $scope.mode = 'open';

    // wallet file drang & drop
    rpNW.dnd("walletfile", {
      onDrop: function(e) {
        $scope.$apply(function() {
          store.set('walletfile', e.dataTransfer.files[0].path);
          $scope.walletfile = e.dataTransfer.files[0].path;
          angular.element("#login_password").focus();
        });
      }
    });

    $scope.error = '';
    $scope.username = '';
    $scope.password = '';
    $scope.loginForm && $scope.loginForm.$setPristine(true);
    $scope.backendMessages = [];

    // Autofill fix
    $timeout(function(){
      $scope.$apply(function () {
        $scope.username = $element.find('input[name="login_username"]').val();
        $scope.password = $element.find('input[name="login_password"]').val();
      });
    }, 1000);

    $rootScope.$on("$blobError", function (e, err) {
      console.log("BLOB ERROR", arguments);
      $scope.backendMessages.push({'backend': err.backend, 'message': err.message});
    });

    var updateFormFields = function(){
      var username;
      var password;

      // There are multiple login forms due to the Ripple URI login feature.
      // But only one of them should be visible and that's the one we want.
      username = $element.find('input[name="login_username"]:visible').eq(0).val();
      password = $element.find('input[name="login_password"]:visible').eq(0).val();

      if ("string" === typeof username) {
        $scope.loginForm.login_username.$setViewValue(username);
      }
      if ("string" === typeof password) {<commit_msg>[FIX] Display proper address for unfunded wallets (DC-152)<commit_after>var util = require('util');
var Tab = require('../client/tab').Tab;

var LoginTab = function ()
{
  Tab.call(this);
};

util.inherits(LoginTab, Tab);

LoginTab.prototype.tabName = 'login';
LoginTab.prototype.pageMode = 'single';
LoginTab.prototype.parent = 'main';

LoginTab.prototype.generateHtml = function ()
{
  return require('../../templates/tabs/login.jade')();
};

LoginTab.prototype.angular = function (module) {
  module.controller('LoginCtrl', ['$scope', '$element', '$routeParams',
                                  '$location', 'rpId', '$rootScope',
                                  'rpPopup', '$timeout', 'rpFileDialog','rpNW',
                                  function ($scope, $element, $routeParams,
                                            $location, $id, $rootScope,
                                            popup, $timeout, filedialog, rpNW)
  {
    if ($id.loginStatus) {
      $location.path('/balance');
      return;
    }

    if(!!store.get('walletfile')) {
      $scope.walletfile = store.get('walletfile');
      angular.element("#login_password").focus();
    }

    $scope.fileInputClick = function(element){
      filedialog.openFile(function(evt) {
        $scope.$apply(function() {
          store.set('walletfile', evt);
          $scope.walletfile = evt;
          angular.element("#login_password").focus();
        });
      }, false);
    };

    $scope.mode = 'open';

    // wallet file drang & drop
    rpNW.dnd("walletfile", {
      onDrop: function(e) {
        $scope.$apply(function() {
          store.set('walletfile', e.dataTransfer.files[0].path);
          $scope.walletfile = e.dataTransfer.files[0].path;
          angular.element("#login_password").focus();
        });
      }
    });

    $scope.error = '';
    $scope.username = '';
    $scope.password = '';
    $scope.loginForm && $scope.loginForm.$setPristine(true);
    $scope.backendMessages = [];
    $rootScope.address = '';

    // Autofill fix
    $timeout(function(){
      $scope.$apply(function () {
        $scope.username = $element.find('input[name="login_username"]').val();
        $scope.password = $element.find('input[name="login_password"]').val();
      });
    }, 1000);

    $rootScope.$on("$blobError", function (e, err) {
      console.log("BLOB ERROR", arguments);
      $scope.backendMessages.push({'backend': err.backend, 'message': err.message});
    });

    var updateFormFields = function(){
      var username;
      var password;

      // There are multiple login forms due to the Ripple URI login feature.
      // But only one of them should be visible and that's the one we want.
      username = $element.find('input[name="login_username"]:visible').eq(0).val();
      password = $element.find('input[name="login_password"]:visible').eq(0).val();

      if ("string" === typeof username) {
        $scope.loginForm.login_username.$setViewValue(username);
      }
      if ("string" === typeof password) {
{'fraction_non_alphanumeric': 0.17217768871075484, 'fraction_numerical': 0.003173012692050768, 'mean_word_length': 2.492128279883382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6160480', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1717, 'n_words': 310}