<commit_before>angular.module("app").controller "AccountController", ($scope, $location, $stateParams, Growl, Wallet, Utils, WalletAPI, $modal, Blockchain) ->

    name = $stateParams.name
    #$scope.accounts = Wallet.receive_accounts
    #$scope.account.balances = Wallet.balances[name]
    $scope.utils = Utils
    $scope.account = Wallet.accounts[name]
    console.log('act')
    console.log(Wallet.accounts[name])


    $scope.balances = Wallet.balances[name]
    $scope.formatAsset = Utils.formatAsset

    #Wallet.refresh_accounts()
    $scope.trust_level=Wallet.trust_levels[name]
    $scope.wallet_info = {file : "", password : ""}
    
    $scope.private_key = {value : ""}

    refresh_account = ->
        Wallet.get_account(name).then (acct) ->
            $scope.account = acct
            $scope.balances = Wallet.balances[name]
            Wallet.refresh_transactions_on_update()
    refresh_account()

    Blockchain.get_config().then (config) ->
        $scope.memo_size_max = config.memo_size_max

    $scope.import_key = ->
        WalletAPI.import_private_key($scope.private_key.value, $scope.account.name).then (response) ->
            $scope.private_key.value = ""
            Growl.notice "", "Your private key was successfully imported."
            refresh_account()

    $scope.register = ->
        console.log "paying with:"
        console.log $scope.payWith
        WalletAPI.account_register($scope.account.name, $scope.payWith).then (response) ->
            Wallet.refresh_account()

    $scope.import_wallet = ->
        WalletAPI.import_bitcoin($scope.wallet_info.file,$scope.wallet_info.password,$scope.account.name).then (response) ->
            $scope.wallet_info.file = ""
            $scope.wallet_info.password = ""
            Growl.notice "The wallet was successfully imported."
            refresh_account()

    $scope.send = ->
        WalletAPI.transfer($scope.amount, $scope.symbol, $scope.account.name, $scope.payto, $scope.memo).then (response) ->
            $scope.payto = ""
            $scope.amount = ""
            $scope.memo = ""
            Growl.notice "", "Transaction broadcasted (#{angular.toJson(response.result)})"
            refresh_account()
            $scope.t_active=true

    $scope.toggleVoteUp = ->
        if name not of Wallet.trust_levels or Wallet.trust_levels[name] < 1
            Wallet.set_trust(name, 1)
        else
            Wallet.set_trust(name, 0)

    $scope.toggleFavorite = ->
        if (Wallet.accounts[name].private_data)
            private_data=Wallet.accounts[name].private_data
        else
            private_data={}
        if !(private_data.gui_data)
            private_data.gui_data={}
        private_data.gui_data.favorite=!(private_data.gui_data.favorite)
        Wallet.account_update_private_data(name, private_data).then ->
            $scope.account.private_data=Wallet.accounts[name].private_data
            console.log($scope.account.private_data)

    $scope.regDial = ->
        if Wallet.nonZeroBalance
          $modal.open
            templateUrl: "registration.html"
            controller: "RegistrationController"
            scope: $scope
            resolve:
              refresh:  -> $scope.refresh_addresses
        else
          Growl.error '','Account registration requires funds.  Please fund one of your accounts.'

    $scope.accountSuggestions = (input) ->
        console.log(input)
        Wallet.blockchain_list_registered_accounts(input, 20).then (response) ->
            console.log(response)
            response<commit_msg>Clinet-side filtering for autocompletion<commit_after>angular.module("app").controller "AccountController", ($scope, $filter, $location, $stateParams, Growl, Wallet, Utils, WalletAPI, $modal, Blockchain) ->

    name = $stateParams.name
    #$scope.accounts = Wallet.receive_accounts
    #$scope.account.balances = Wallet.balances[name]
    $scope.utils = Utils
    $scope.account = Wallet.accounts[name]
    console.log('act')
    console.log(Wallet.accounts[name])


    $scope.balances = Wallet.balances[name]
    $scope.formatAsset = Utils.formatAsset

    #Wallet.refresh_accounts()
    $scope.trust_level=Wallet.trust_levels[name]
    $scope.wallet_info = {file : "", password : ""}
    
    $scope.private_key = {value : ""}

    refresh_account = ->
        Wallet.get_account(name).then (acct) ->
            $scope.account = acct
            $scope.balances = Wallet.balances[name]
            Wallet.refresh_transactions_on_update()
    refresh_account()

    Blockchain.get_config().then (config) ->
        $scope.memo_size_max = config.memo_size_max

    $scope.import_key = ->
        WalletAPI.import_private_key($scope.private_key.value, $scope.account.name).then (response) ->
            $scope.private_key.value = ""
            Growl.notice "", "Your private key was successfully imported."
            refresh_account()

    $scope.register = ->
        console.log "paying with:"
        console.log $scope.payWith
        WalletAPI.account_register($scope.account.name, $scope.payWith).then (response) ->
            Wallet.refresh_account()

    $scope.import_wallet = ->
        WalletAPI.import_bitcoin($scope.wallet_info.file,$scope.wallet_info.password,$scope.account.name).then (response) ->
            $scope.wallet_info.file = ""
            $scope.wallet_info.password = ""
            Growl.notice "The wallet was successfully imported."
            refresh_account()

    $scope.send = ->
        WalletAPI.transfer($scope.amount, $scope.symbol, $scope.account.name, $scope.payto, $scope.memo).then (response) ->
            $scope.payto = ""
            $scope.amount = ""
            $scope.memo = ""
            Growl.notice "", "Transaction broadcasted (#{angular.toJson(response.result)})"
            refresh_account()
            $scope.t_active=true

    $scope.toggleVoteUp = ->
        if name not of Wallet.trust_levels or Wallet.trust_levels[name] < 1
            Wallet.set_trust(name, 1)
        else
            Wallet.set_trust(name, 0)

    $scope.toggleFavorite = ->
        if (Wallet.accounts[name].private_data)
            private_data=Wallet.accounts[name].private_data
        else
            private_data={}
        if !(private_data.gui_data)
            private_data.gui_data={}
        private_data.gui_data.favorite=!(private_data.gui_data.favorite)
        Wallet.account_update_private_data(name, private_data).then ->
            $scope.account.private_data=Wallet.accounts[name].private_data
            console.log($scope.account.private_data)

    $scope.regDial = ->
        if Wallet.nonZeroBalance
          $modal.open
            templateUrl: "registration.html"
            controller: "RegistrationController"
            scope: $scope
            resolve:
              refresh:  -> $scope.refresh_addresses
        else
          Growl.error '','Account registration requires funds.  Please fund one of your accounts.'

    $scope.accountSuggestions = (input) ->
        console.log(input)
        Wallet.blockchain_list_registered_accounts(input, 20).then (response) ->
            console.log(response)
            $filter('filter')(response, input)
{'fraction_non_alphanumeric': 0.12288253262982504, 'fraction_numerical': 0.0013885031935573452, 'mean_word_length': 2.5051094890510948, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '6624961', 'n_tokens_mistral': 2166, 'n_tokens_neox': 2132, 'n_words': 322}