<commit_before>ManageIQ.angular.app.directive('verifypasswd', function() {
  return {
    require: 'ngModel',
    link: function (scope, _elem, attr, ctrl) {
      var log_password = attr.prefix + "_password";
      var log_verify = attr.prefix + "_verify";
      var logVerifyCtrl = attr.prefix + "_VerifyCtrl";

      scope.$watch(attr.ngModel, function() {
        if((ctrl.$modelValue != undefined && scope.afterGet) || scope.formId == "new") {
          if(ctrl.$name == log_verify) {
            scope[logVerifyCtrl] = ctrl;

            setValidity(scope, ctrl, ctrl.$viewValue, scope[scope.model][log_password]);
          }else if(ctrl.$name == log_password && scope[logVerifyCtrl] != undefined) {
            setValidity(scope, scope[logVerifyCtrl], ctrl.$viewValue, scope[scope.model][log_verify]);
          }
        }
      });

      ctrl.$parsers.push(function(value) {
        if (ctrl.$name == log_verify) {
          setValidity(scope, ctrl, ctrl.$viewValue, scope[scope.model][log_password]);
        }else if(ctrl.$name == log_password && scope[logVerifyCtrl] != undefined) {
          setValidity(scope, scope[logVerifyCtrl], ctrl.$viewValue, scope[scope.model][log_verify]);
        }
        return value;
      });

      var setValidity = function(_scope, logVerifyCtrl, valueNew, valueOrig) {
        if (valueNew == valueOrig) {
          logVerifyCtrl.$setValidity("verifypasswd", true);
        } else if (logVerifyCtrl.$dirty || valueOrig != "") {
          logVerifyCtrl.$setValidity("verifypasswd", false);
        }
      };
    }
  }
});<commit_msg>Adjustments to use the main scope and the model that lives there<commit_after>ManageIQ.angular.app.directive('verifypasswd', function() {
  return {
    require: 'ngModel',
    link: function (scope, _elem, attr, ctrl) {
      var model = function() {
        if (scope.$parent.angularForm) {
          return scope.$parent.$eval(scope.$parent.angularForm.model || scope.$parent.model);
        } else {
          return scope.$eval(scope.angularForm.model || scope.model);
        }
      };

      var vmScope = function() {
        if (scope.$parent.angularForm) {
          return scope.$parent;
        } else {
          return scope;
        }
      };

      var log_password = attr.prefix + "_password";
      var log_verify = attr.prefix + "_verify";
      var logVerifyCtrl = attr.prefix + "_VerifyCtrl";

      scope.$watch(attr.ngModel, function() {
        if((ctrl.$modelValue != undefined && vmScope().afterGet) || vmScope().formId == "new") {
          if(ctrl.$name == log_verify) {
            scope[logVerifyCtrl] = ctrl;

            setValidity(vmScope(), ctrl, ctrl.$viewValue, model()[log_password]);
          }else if(ctrl.$name == log_password && scope[logVerifyCtrl] != undefined) {
            setValidity(vmScope(), scope[logVerifyCtrl], ctrl.$viewValue, model()[log_verify]);
          }
        }
      });

      ctrl.$parsers.push(function(value) {
        if (ctrl.$name == log_verify) {
          setValidity(vmScope(), ctrl, ctrl.$viewValue, model()[log_password]);
        }else if(ctrl.$name == log_password && scope[logVerifyCtrl] != undefined) {
          setValidity(vmScope(), scope[logVerifyCtrl], ctrl.$viewValue, model()[log_verify]);
        }
        return value;
      });

      var setValidity = function(_scope, logVerifyCtrl, valueNew, valueOrig) {
        if (valueNew == valueOrig) {
          logVerifyCtrl.$setValidity("verifypasswd", true);
        } else if (logVerifyCtrl.$dirty || valueOrig != "") {
          logVerifyCtrl.$setValidity("verifypasswd", false);
        }
      };
    }
  }
});

{'fraction_non_alphanumeric': 0.1489010989010989, 'fraction_numerical': 0.0, 'mean_word_length': 2.6519558676028083, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4325936', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1068, 'n_words': 199}