<commit_before>/* ==========================================================
 * autocomplete.js
 * Deal with the Typeahead.js/Bloodhound library to build the search field autocomplete
 *
 * Author: Yann, <EMAIL>
 * Date:   2014-05-01 14:23:18
 *
 * Copyright 2014 Federal Chancellery of Switzerland
 * Licensed under MIT
 ========================================================== */

(function($, data) {
  var $searchFields = $('.form-search .search-field');
  if (data) {
    // Init the Bloodhound suggestion engine
    var bloodhound = new Bloodhound({
      datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      local: $.map(data, function(state) { return { value: state }; })
    });
    bloodhound.initialize();

    // Init Typeahead on search-fields
    $searchFields.typeahead({
      hint: true,
      highlight: true,
      minLength: 1,
    },
    {
      name: 'search',
      displayKey: 'value',
      source: bloodhound.ttAdapter()
    });
  }

  // Insert the icons
  $searchFields.after('<span class="icon icon--close" data-form-search-clear></span>');
  $('.form-search').append('<button class="icon icon--search icon--before"></button>');

  $('body').on('click', '[data-form-search-clear]', function () {
    $(this).siblings('.search-field').focus().val('');
  });

}) (jQuery, (typeof searchData === 'undefined' ? false : searchData));<commit_msg>lose focus delete value searchfield<commit_after>/* ==========================================================
 * autocomplete.js
 * Deal with the Typeahead.js/Bloodhound library to build the search field autocomplete
 *
 * Author: Yann, <EMAIL>
 * Date:   2014-05-01 14:23:18
 *
 * Copyright 2014 Federal Chancellery of Switzerland
 * Licensed under MIT
 ========================================================== */

(function($, data) {
  var $searchFields = $('.form-search .search-field');
  if (data) {
    // Init the Bloodhound suggestion engine
    var bloodhound = new Bloodhound({
      datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      local: $.map(data, function(state) { return { value: state }; })
    });
    bloodhound.initialize();

    // Init Typeahead on search-fields
    $searchFields.typeahead({
      hint: true,
      highlight: true,
      minLength: 1,
    },
    {
      name: 'search',
      displayKey: 'value',
      source: bloodhound.ttAdapter()
    });
  }

  // Insert the icons
  $searchFields.after('<span class="icon icon--close" data-form-search-clear></span>');
  $('.form-search').append('<button class="icon icon--search icon--before"></button>');

  $('body').on('click', '[data-form-search-clear]', function () {
    $(this).siblings('.search-field').focus().val('');
  });

  $('body').on('click', function () {
    $('#search-field').val('');
  });

}) (jQuery, (typeof searchData === 'undefined' ? false : searchData));
{'fraction_non_alphanumeric': 0.2375209380234506, 'fraction_numerical': 0.012730318257956449, 'mean_word_length': 3.7321711568938194, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4790761', 'n_tokens_mistral': 918, 'n_tokens_neox': 855, 'n_words': 194}