<commit_before>Spree.ready(function(){
  validator = new AddressValidator();
  validator.bindListeners();
})

function AddressValidator(){
  this.lineHash = {
    address1: 'Line1',
    address2: 'Line2',
    city: 'City',
    zipcode: 'PostalCode',
    country: 'Country',
    state: 'Region'
  }
}

AddressValidator.prototype = {
  bindListeners: function(){
    $('.address_validator').on('click', this.validate.bind(this))
  },
  validate: function(){
    event.preventDefault()
    var address = this.formatAddress()

    $.ajax({
      url: Spree.routes.validate_address,
      data: {
        address: address
      }
    }).done(function(data){
      var address = data.Address;
      var controller = this;
      $.each(['Line1', 'Line2', 'City', 'PostalCode'], function(index, value){
        var keyVal = controller.getKeyByValue(value);
        $("#shipping input[id*='" + keyVal + "']").val(address[value])
      }.bind(address))

      this.showFlash(data)
    }.bind(this))
  },
  formatAddress: function() {
    var address = {}
    controller = this;
    var wrapper = controller.addressWrapper();

    $(wrapper + ' input').not("[name$='name]']").not("[class*=select2]").each(function(){<commit_msg>using wrapper to grab correct element<commit_after>Spree.ready(function(){
  validator = new AddressValidator();
  validator.bindListeners();
})

function AddressValidator(){
  this.lineHash = {
    address1: 'Line1',
    address2: 'Line2',
    city: 'City',
    zipcode: 'PostalCode',
    country: 'Country',
    state: 'Region'
  }
}

AddressValidator.prototype = {
  bindListeners: function(){
    $('.address_validator').on('click', this.validate.bind(this))
  },
  validate: function(){
    event.preventDefault()
    var address = this.formatAddress()

    $.ajax({
      url: Spree.routes.validate_address,
      data: {
        address: address
      }
    }).done(function(data){
      var address = data.Address;
      var controller = this;
      var wrapper = controller.addressWrapper();

      $.each(['Line1', 'Line2', 'City', 'PostalCode'], function(index, value){
        var keyVal = controller.getKeyByValue(value);
        $(wrapper + " input[id*='" + keyVal + "']").val(address[value])
      }.bind(address))

      this.showFlash(data)
    }.bind(this))
  },
  formatAddress: function() {
    var address = {}
    controller = this;
    var wrapper = controller.addressWrapper();

    $(wrapper + ' input').not("[name$='name]']").not("[class*=select2]").each(function(){
{'fraction_non_alphanumeric': 0.17497010761259466, 'fraction_numerical': 0.005579912315663611, 'mean_word_length': 3.342560553633218, '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': '4666915', 'n_tokens_mistral': 766, 'n_tokens_neox': 767, 'n_words': 149}