<commit_before>(function () {
'use strict';
var module = angular.module('fim.base');
module.controller('TransactionCreateModalController', function(items, $modalInstance, $scope, nxt, 
  modals, $sce, $q, plugins, i18n, $timeout, accountsService, $rootScope, Emoji) {

  $scope.sendSuccess          = false;
  $scope.show                 = {};
  $scope.show.advanced        = false;
  $scope.show.message         = !!items.showMessage;
  $scope.items                = items;
  $scope.emoji                = { groups: Emoji.groups };
  $scope.ui                   = {};
  $scope.ui.emojiCollapse     = true;

  var api                     = nxt.get($rootScope.currentAccount.id_rs);
  $scope.items.senderRS       = $rootScope.currentAccount.id_rs;
  $scope.items.secretPhrase   = $rootScope.currentAccount.secretPhrase;

  $scope.items.title          = items.title || 'Create Transaction';
  $scope.items.txnMessageType = items.txnMessageType || ($scope.items.canHaveRecipient ? 'to_recipient' : 'note');
  $scope.items.txnMessage     = items.txnMessage || '';  
  $scope.items.symbol         = items.symbol || api.engine.symbol;
  $scope.items.deadline       = items.deadline || '1440';
  $scope.items.feeNXT         = items.feeNXT || api.engine.feeCost;
  $scope.items.message        = $sce.getTrustedHtml(items.message);
  $scope.items.accounts       = [];

  if ($scope.items.editRecipient) {
    var promise = accountsService.getAll(api.engine.type == nxt.TYPE_FIM ? accountsService.FIM_FILTER : accountsService.NXT_FILTER);
    promise.then(function (accounts) {
      $scope.$evalAsync(function () {
        $scope.items.accounts = accounts;
      });
    });
  }

  /* Add watches for fields supporting a show expression */
  angular.forEach($scope.items.fields, function (field) {
    field.__show = true;
    if (field.show) {
      field.__show = !!$scope.$eval(field.show);
      $scope.$watch(field.show, function (val) {
        field.__show = !!val;
      });
    }
  });

  $scope.insertEmoji = function (name) {
    $scope.$evalAsync(function () {
      $scope.items.txnMessage += ':'+Emoji.toBase32(name)+':';
    });
  }

  $scope.validateAddress = function (id_rs) {
    var address = api.createAddress();
    return address.set(id_rs);
  }

  $scope.dismiss = function () {
    $modalInstance.dismiss();
  };

  $scope.close = function () {
    if ($scope.sendSuccess) {
      $modalInstance.close($scope.items);
    }
    else {

      /* Makes fields available on items by name */
      angular.forEach($scope.items.fields, function (field) {
        $scope.items[field.name] = field.value;
      });

      var args = {
        feeNQT:   nxt.util.convertToNQT($scope.items.feeNXT),
        deadline: $scope.items.deadline,
        sender:   $scope.items.senderRS
      };
      args = angular.extend(args, $scope.items.createArguments($scope.items));
      /*
      -- DISABLED FOR NOW --

      if ($scope.items.transient) {
        args.referencedTransactionFullHash = converters.stringToHexString('00000000000000000000000000000000');
      }*/

      var message = null, type = null;<commit_msg>Add onclose support to transaction plugins<commit_after>(function () {
'use strict';
var module = angular.module('fim.base');
module.controller('TransactionCreateModalController', function(items, $modalInstance, $scope, nxt, 
  modals, $sce, $q, plugins, i18n, $timeout, accountsService, $rootScope, Emoji) {

  $scope.sendSuccess          = false;
  $scope.show                 = {};
  $scope.show.advanced        = false;
  $scope.show.message         = !!items.showMessage;
  $scope.items                = items;
  $scope.emoji                = { groups: Emoji.groups };
  $scope.ui                   = {};
  $scope.ui.emojiCollapse     = true;

  var api                     = nxt.get($rootScope.currentAccount.id_rs);
  $scope.items.senderRS       = $rootScope.currentAccount.id_rs;
  $scope.items.secretPhrase   = $rootScope.currentAccount.secretPhrase;

  $scope.items.title          = items.title || 'Create Transaction';
  $scope.items.txnMessageType = items.txnMessageType || ($scope.items.canHaveRecipient ? 'to_recipient' : 'note');
  $scope.items.txnMessage     = items.txnMessage || '';  
  $scope.items.symbol         = items.symbol || api.engine.symbol;
  $scope.items.deadline       = items.deadline || '1440';
  $scope.items.feeNXT         = items.feeNXT || api.engine.feeCost;
  $scope.items.message        = $sce.getTrustedHtml(items.message);
  $scope.items.accounts       = [];

  if ($scope.items.editRecipient) {
    var promise = accountsService.getAll(api.engine.type == nxt.TYPE_FIM ? accountsService.FIM_FILTER : accountsService.NXT_FILTER);
    promise.then(function (accounts) {
      $scope.$evalAsync(function () {
        $scope.items.accounts = accounts;
      });
    });
  }

  /* Add watches for fields supporting a show expression */
  angular.forEach($scope.items.fields, function (field) {
    field.__show = true;
    if (field.show) {
      field.__show = !!$scope.$eval(field.show);
      $scope.$watch(field.show, function (val) {
        field.__show = !!val;
      });
    }
  });

  $scope.insertEmoji = function (name) {
    $scope.$evalAsync(function () {
      $scope.items.txnMessage += ':'+Emoji.toBase32(name)+':';
    });
  }

  $scope.validateAddress = function (id_rs) {
    var address = api.createAddress();
    return address.set(id_rs);
  }

  $scope.dismiss = function () {
    $modalInstance.dismiss();
  };

  $scope.close = function () {
    /* Makes fields available on items by name */
    angular.forEach($scope.items.fields, function (field) { 
      $scope.items[field.name] = field.value;
    });

    if ($scope.sendSuccess) {
      $modalInstance.close($scope.items);
    }
    else if ($scope.items.onclose) {
      $scope.items.onclose($scope.items).then(
        function () {
          $modalInstance.close($scope.items);
        }
      );
    }
    else {
      var args = {
        feeNQT:   nxt.util.convertToNQT($scope.items.feeNXT),
        deadline: $scope.items.deadline,
        sender:   $scope.items.senderRS
      };
      args = angular.extend(args, $scope.items.createArguments($scope.items));
      /*
      -- DISABLED FOR NOW --

      if ($scope.items.transient) {
        args.referencedTransactionFullHash = converters.stringToHexString('00000000000000000000000000000000');
      }*/

      var message = null, type = null;
{'fraction_non_alphanumeric': 0.14891304347826087, 'fraction_numerical': 0.012422360248447204, 'mean_word_length': 2.6389830508474574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2396470', 'n_tokens_mistral': 2116, 'n_tokens_neox': 1996, 'n_words': 326}