<commit_before>angular.module("app.directives").directive "focusMe", ($timeout) ->
  scope:
    trigger: "@focusMe"
  link: (scope, element) ->
    scope.$watch "trigger", ->
      $timeout ->
        element[0].focus()

angular.module("app.directives").directive "pwCheck", ->
  require: "ngModel"
  link: (scope, elem, attrs, ctrl) ->
    firstPassword = "#" + attrs.pwCheck
    elem.add(firstPassword).on "keyup", ->
      scope.$apply ->
        v = elem.val() is $(firstPassword).val()
        ctrl.$setValidity "pwmatch", v


angular.module("app.directives").directive "inputName", ->
  template: '<input placeholder="Account Name (Required)" autofocus ng-model="$parent.ngModel" ng-blur="removeTrailingDashes()" popover="Name can only contain lowercase alphanumeric characters and dashes, must start with a letter, and cannot end with a dash.  It can be at most 63 characters long.  Invalid characters are blocked and letters are lowercased automatically."  popover-trigger="focus" ng-keydown="kd()" ng-change="ku()" uncapitalize type="text" class="form-control">'
  restrict: "E"
  scope:
    ngModel: "="
  controller: ($scope, $element) ->
    oldname=$scope.ngModel
    $scope.kd = ->
        oldname=$scope.ngModel
       
    $scope.ku = ->
        valid=/^[a-z]+(?:[a-z0-9\-])*$/.test($scope.ngModel) && $scope.ngModel.length<63 || $scope.ngModel is ""
        if(!valid)
            $scope.ngModel=oldname

    $scope.removeTrailingDashes = ->
        $scope.ngModel = $scope.ngModel.replace(/\-+$/, "")
  ###
  link: (scope, elem, attrs, ngModel) ->
      elem.on("click", ->
          console.log(ngModel.$viewValue)
          ngModel.$setViewValue(ngModel.$viewValue+'1')
          scope.$apply()
      )
###
<commit_msg>add reusable ng-enter directive to remove trailing dashes when enter is pressed<commit_after>angular.module("app.directives").directive "focusMe", ($timeout) ->
  scope:
    trigger: "@focusMe"
  link: (scope, element) ->
    scope.$watch "trigger", ->
      $timeout ->
        element[0].focus()

angular.module("app.directives").directive "pwCheck", ->
  require: "ngModel"
  link: (scope, elem, attrs, ctrl) ->
    firstPassword = "#" + attrs.pwCheck
    elem.add(firstPassword).on "keyup", ->
      scope.$apply ->
        v = elem.val() is $(firstPassword).val()
        ctrl.$setValidity "pwmatch", v

angular.module("app.directives").directive "ngEnter", ->
  (scope, element, attrs) ->
      element.bind "keydown keypress", (event) ->
        if event.which is 13
          scope.$apply ->
            scope.$eval attrs.ngEnter


angular.module("app.directives").directive "inputName", ->
  template: '<input placeholder="Account Name (Required)" autofocus ng-model="$parent.ngModel" ng-blur="removeTrailingDashes()" ng-enter="removeTrailingDashes()" popover="Name can only contain lowercase alphanumeric characters and dashes, must start with a letter, and cannot end with a dash.  It can be at most 63 characters long.  Invalid characters are blocked and letters are lowercased automatically."  popover-trigger="focus" ng-keydown="kd()" ng-change="ku()" uncapitalize type="text" class="form-control">'
  restrict: "E"
  scope:
    ngModel: "="
  controller: ($scope, $element) ->
    oldname=$scope.ngModel
    $scope.kd = ->
        oldname=$scope.ngModel
       
    $scope.ku = ->
        valid=/^[a-z]+(?:[a-z0-9\-])*$/.test($scope.ngModel) && $scope.ngModel.length<63 || $scope.ngModel is ""
        if(!valid)
            $scope.ngModel=oldname

    $scope.removeTrailingDashes = ->
        $scope.ngModel = $scope.ngModel.replace(/\-+$/, "")
  ###
  link: (scope, elem, attrs, ngModel) ->
      elem.on("click", ->
          console.log(ngModel.$viewValue)
          ngModel.$setViewValue(ngModel.$viewValue+'1')
          scope.$apply()
      )
###

{'fraction_non_alphanumeric': 0.16990546218487396, 'fraction_numerical': 0.004726890756302521, 'mean_word_length': 3.1673960612691467, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, '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': '4305943', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1193, 'n_words': 262}