<commit_before>/* eslint-env browser, jquery */
/* global HMDA, initRules */
!(function() {
  //Given a list of institutions, create units of html for each of them
  function buildList(institutions) {
    $('#institutions')
      .empty()
      .append(
        makeInstitutionsLabel(institutions),
        makeHelpContent(),
        makeInstitutionsList(institutions)
      )
    addInstitutionsToInput()
  }

  //Given a list of institutions, return a label element describing them
  function makeInstitutionsLabel(institutions) {
    var labelContent = 'Select your institution'
    if (institutions.length > 1) {
      labelContent =
        'Select all available institutions you wish to file for. You may select more than one.'
    }
    return $('<label>').text(labelContent)
  }

  function makeHelpContent() {
    var span = $('<span class="usa-text-small">')
    span.append(
      'If any of the information listed is incorrect, please fill out and submit ',
      getHelpFormLink(),
      ' with the correct information.'
    )

    return span
  }

  function getHelpFormLink() {
    return $('<a>')
      .attr({
        href: 'https://hmdahelp.consumerfinance.gov/accounthelp/'
      })
      .text('this form')
  }

  function makeInstitutionsList(institutions) {
    var list = $('<ul class="usa-unstyled-list">')

    for (var i = 0; i < institutions.length; i++) {
      var li = $('<li>')
      var input = $('<input class="institutionsCheck">').attr({
        type: 'checkbox',
        name: 'institutions',
        id: institutions[i].lei,
        value: institutions[i].lei
      })
      var label = $('<label>').attr({
        for: institutions[i].lei
      })
      var strong = $('<strong>').text(institutions[i].respondent.name)
      // var dl = makeDataList(institutions[i].externalIds)
      var dl = makeDataList([
        { value: institutions[i].lei, externalIdType: { name: 'LEI' } },
        { value: institutions[i].taxId, externalIdType: { name: 'Tax ID' } },
        {
          value: institutions[i].agency,
          externalIdType: { name: 'Agency Code' }
        }
      ])
      label.append(strong, dl)
      li.append(input, label)
      list.append(li)
    }
    return list
  }

  //Create description list from a list of ids
  function makeDataList(externalIds) {
    var dl = $('<dl>').addClass('usa-text-small')
    for (var i = 0; i < externalIds.length; i++) {
      var dt = $('<dt>').text(externalIds[i].externalIdType.name + ':')
      var dd = $('<dd>').text(externalIds[i].value)
      dl.append(dt, dd)
    }

    return dl
  }

  //Get checked institutions' values and add them to a hidden input field to be submitted
  function addInstitutionsToInput() {
    var listOfInstitutions = []
    // add to the user.attributes.institutions input
    $('.institutionsCheck').each(function(index) {
      if ($(this).prop('checked')) {
        listOfInstitutions.push($(this).val())
      }
    })
    $('#user\\.attributes\\.institutions').val(listOfInstitutions.join(','))
  }

  //AJAX call to get data, calls buildList with returned institutions
  function getInstitutions(domain) {
    $.ajax({
      url: '/v2/public/institutions',
      statusCode: {
        404: function() {
          $('#institutions')
            .empty()
            .append(
              $('<span class="hmda-error-message">').append(
                $(
                  "<span>Sorry, we couldn't find that email domain. For help getting registered, please contact </span>"
                ),
                getEmailLink(),
                $(
                  '<span> and provide your institution name, RSSD, and Tax ID. If your institution is a non-depository and does not have an RSSD, please provide your NMLS ID in place of the RSSD.</span>'
                )<commit_msg>update messaging for no domain found<commit_after>/* eslint-env browser, jquery */
/* global HMDA, initRules */
!(function() {
  //Given a list of institutions, create units of html for each of them
  function buildList(institutions) {
    $('#institutions')
      .empty()
      .append(
        makeInstitutionsLabel(institutions),
        makeHelpContent(),
        makeInstitutionsList(institutions)
      )
    addInstitutionsToInput()
  }

  //Given a list of institutions, return a label element describing them
  function makeInstitutionsLabel(institutions) {
    var labelContent = 'Select your institution'
    if (institutions.length > 1) {
      labelContent =
        'Select all available institutions you wish to file for. You may select more than one.'
    }
    return $('<label>').text(labelContent)
  }

  function makeHelpContent() {
    var span = $('<span class="usa-text-small">')
    span.append(
      'If any of the information listed is incorrect, please fill out and submit ',
      getHelpFormLink(),
      ' with the correct information.'
    )

    return span
  }

  function getHelpFormLink() {
    return $('<a>')
      .attr({
        href: 'https://hmdahelp.consumerfinance.gov/accounthelp/'
      })
      .text('this form')
  }

  function makeInstitutionsList(institutions) {
    var list = $('<ul class="usa-unstyled-list">')

    for (var i = 0; i < institutions.length; i++) {
      var li = $('<li>')
      var input = $('<input class="institutionsCheck">').attr({
        type: 'checkbox',
        name: 'institutions',
        id: institutions[i].lei,
        value: institutions[i].lei
      })
      var label = $('<label>').attr({
        for: institutions[i].lei
      })
      var strong = $('<strong>').text(institutions[i].respondent.name)
      // var dl = makeDataList(institutions[i].externalIds)
      var dl = makeDataList([
        { value: institutions[i].lei, externalIdType: { name: 'LEI' } },
        { value: institutions[i].taxId, externalIdType: { name: 'Tax ID' } },
        {
          value: institutions[i].agency,
          externalIdType: { name: 'Agency Code' }
        }
      ])
      label.append(strong, dl)
      li.append(input, label)
      list.append(li)
    }
    return list
  }

  //Create description list from a list of ids
  function makeDataList(externalIds) {
    var dl = $('<dl>').addClass('usa-text-small')
    for (var i = 0; i < externalIds.length; i++) {
      var dt = $('<dt>').text(externalIds[i].externalIdType.name + ':')
      var dd = $('<dd>').text(externalIds[i].value)
      dl.append(dt, dd)
    }

    return dl
  }

  //Get checked institutions' values and add them to a hidden input field to be submitted
  function addInstitutionsToInput() {
    var listOfInstitutions = []
    // add to the user.attributes.institutions input
    $('.institutionsCheck').each(function(index) {
      if ($(this).prop('checked')) {
        listOfInstitutions.push($(this).val())
      }
    })
    $('#user\\.attributes\\.institutions').val(listOfInstitutions.join(','))
  }

  //AJAX call to get data, calls buildList with returned institutions
  function getInstitutions(domain) {
    $.ajax({
      url: '/v2/public/institutions',
      statusCode: {
        404: function() {
          $('#institutions')
            .empty()
            .append(
              $('<span class="hmda-error-message">').append(
                $(
                  "<span>Sorry, we couldn't find that email domain. For help getting registered, please fill out and submit </span>"
                ),
                getHelpFormLink(),
                $('<span>.</span>')
{'fraction_non_alphanumeric': 0.14036734146668453, 'fraction_numerical': 0.0018769272020378066, 'mean_word_length': 2.4569045412418906, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '3405719', 'n_tokens_mistral': 2243, 'n_tokens_neox': 2172, 'n_words': 577}