<commit_before>const $ = require('jquery');

class AddressAjax {
  init(){
    this.housenumber = $('#input-houseNumber');
    this.postcode = $('#input-postcode');
    this.csrf = $('input[name=\'csrf\']').val();
    this.addressButton = $('#addressbutton');
    this.endpoint = '/address';
    this.formFields = $('.form-fields');
    this.addressButton.on('click', this.formHandler.bind(this));
    this.resultListContainerElem = $('.address-results');
    this.resultListContainerElem.on('click', '.select-link', this.resultItemClickHandler.bind(this));
    this.addressContinue = $('#address-lookup-continue');
    this.manualContinue = $('#manualcontinue');
    this.manualContinue.on('click', this.fillManual.bind(this));
    this.manualDiv = $('#manualDiv');
    this.manualDiv.on('click', '.details__summary', this.cleanResults.bind(this));
    this.confirmContainer = $('.address-confirm');
    this.confirmResetButton = $('.confirm-reset');
    this.confirmResetButton.on('click',this.confirmReset.bind(this));
    this.disableEnter();
  }

  static getResultTemplate (){
    return $.parseHTML('' +
          '<li class="address-item result">' +
            '<div class="first-line">' +
              '<span class="name"></span>' +
              '<a href="#" class="select-link">Select</a>' +
            '</div>' +
            '<small class="address"></small>' +
          '</li>'
        );
  }
  confirmReset(){
    this.housenumber.val('');
    this.postcode.val('');
    this.confirmContainer.hide();
    this.addressButton.show();
    this.addressContinue.hide();
    this.formFields.show();
    this.manualDiv.show();
  }

  validationFunction() {
    if($('#addresscontinue') === null) {
      return true;
    } else if($('#addresscontinue').is(':focus')) {
      return true;
    }
    return false;
  }

  disableEnter() {
    const _this = this;
    $(document).ready(function() {
      $(window).keydown(function(event){
        if( (event.keyCode == 13) && (_this.validationFunction() === false) ) {
          event.preventDefault();
          return false;
        }
      });
    });
  }

  selectAddress (elem){
    $('#input-address1').val(elem.data('address1'));
    $('#input-address2').val(elem.data('address2'));
    $('#input-address3').val(elem.data('address3'));
    $('#input-town').val(elem.data('town'));
    $('#input-county').val(elem.data('county'));
    $('#confirmAddress1').text(elem.data('address1'));
    $('#confirmAddress2').text(elem.data('address2'));
    $('#confirmAddress3').text(elem.data('address3'));
    $('#confirmTown').text(elem.data('town'));
    $('#confirmCounty').text(elem.data('county'));
    $('#confirmPostcode').text(this.postcode.val());
    this.confirmContainer.show();
    this.resultListContainerElem.hide();
    this.formFields.hide();
    this.addressButton.hide();
    this.addressContinue.show();
    this.manualDiv.hide();    
  }<commit_msg>lint fixed<commit_after>const $ = require('jquery');

class AddressAjax {
  init(){
    this.housenumber = $('#input-houseNumber');
    this.postcode = $('#input-postcode');
    this.csrf = $('input[name=\'csrf\']').val();
    this.addressButton = $('#addressbutton');
    this.endpoint = '/address';
    this.formFields = $('.form-fields');
    this.addressButton.on('click', this.formHandler.bind(this));
    this.resultListContainerElem = $('.address-results');
    this.resultListContainerElem.on('click', '.select-link', this.resultItemClickHandler.bind(this));
    this.addressContinue = $('#address-lookup-continue');
    this.manualContinue = $('#manualcontinue');
    this.manualContinue.on('click', this.fillManual.bind(this));
    this.manualDiv = $('#manualDiv');
    this.manualDiv.on('click', '.details__summary', this.cleanResults.bind(this));
    this.confirmContainer = $('.address-confirm');
    this.confirmResetButton = $('.confirm-reset');
    this.confirmResetButton.on('click',this.confirmReset.bind(this));
    this.disableEnter();
  }

  static getResultTemplate (){
    return $.parseHTML('' +
          '<li class="address-item result">' +
            '<div class="first-line">' +
              '<span class="name"></span>' +
              '<a href="#" class="select-link">Select</a>' +
            '</div>' +
            '<small class="address"></small>' +
          '</li>'
        );
  }
  confirmReset(){
    this.housenumber.val('');
    this.postcode.val('');
    this.confirmContainer.hide();
    this.addressButton.show();
    this.addressContinue.hide();
    this.formFields.show();
    this.manualDiv.show();
  }

  validationFunction() {
    if($('#addresscontinue') === null) {
      return true;
    } else if($('#addresscontinue').is(':focus')) {
      return true;
    }
    return false;
  }

  disableEnter() {
    const _this = this;
    $(document).ready(function() {
      $(window).keydown(function(event){
        if( (event.keyCode == 13) && (_this.validationFunction() === false) ) {
          event.preventDefault();
          return false;
        }
      });
    });
  }

  selectAddress (elem){
    $('#input-address1').val(elem.data('address1'));
    $('#input-address2').val(elem.data('address2'));
    $('#input-address3').val(elem.data('address3'));
    $('#input-town').val(elem.data('town'));
    $('#input-county').val(elem.data('county'));
    $('#confirmAddress1').text(elem.data('address1'));
    $('#confirmAddress2').text(elem.data('address2'));
    $('#confirmAddress3').text(elem.data('address3'));
    $('#confirmTown').text(elem.data('town'));
    $('#confirmCounty').text(elem.data('county'));
    $('#confirmPostcode').text(this.postcode.val());
    this.confirmContainer.show();
    this.resultListContainerElem.hide();
    this.formFields.hide();
    this.addressButton.hide();
    this.addressContinue.show();
    this.manualDiv.hide();
  }
{'fraction_non_alphanumeric': 0.2133927042301764, 'fraction_numerical': 0.004795341668093852, 'mean_word_length': 3.4108761329305137, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '2872748', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1761, 'n_words': 223}