<commit_before>(function($) {
  $.widget('ui.combobox', {

    options: {
      source_url: null  // caller must provide this
    },

    _create: function() {
      var input,
          that = this,
          wasOpen = false,
          loaded = false,  // options list loaded with ajax already?
          select = this.element.hide(),
          selected = select.children(':selected'),
          value = selected.val() ? selected.text() : "",
          wrapper = this.wrapper = $('<span>')
            .addClass('ui-combobox')
            .insertAfter(select);

      function populateSelect(data) {
        for (var i = 0; i < data.options.length; i++) {
          var label = data.options[i].label,
              value = data.options[i].value;
          $('<option>' + label + '</option>')
            .val(value)
            .appendTo(select);
        }
        loaded = true;
        input.autocomplete('search', input.val());  // trigger search to re-render options
      }

      // Load options list with ajax and populate underlying select with loaded data
      $.get(this.options.source_url, populateSelect);

      function removeIfInvalid(element) {
        var value = $(element).val(),
            matcher = new RegExp('^' + $.ui.autocomplete.escapeRegex(value) + '$'),
            valid = false;
        select.children('option').each(function() {
          if ($(this).text().match(matcher)) {
            this.selected = valid = true;
            return false;
          }
        });

        if (!valid) {
          $(element).val('');
          select.val('');
          input.data('autocomplete').term = '';
        }
      }<commit_msg>[#4299] ticket:281 Select user if username is typed in combobox and not selected from the list<commit_after>(function($) {
  $.widget('ui.combobox', {

    options: {
      source_url: null  // caller must provide this
    },

    _create: function() {
      var input,
          that = this,
          wasOpen = false,
          loaded = false,  // options list loaded with ajax already?
          select = this.element.hide(),
          selected = select.children(':selected'),
          value = selected.val() ? selected.text() : "",
          wrapper = this.wrapper = $('<span>')
            .addClass('ui-combobox')
            .insertAfter(select);

      function populateSelect(data) {
        for (var i = 0; i < data.options.length; i++) {
          var label = data.options[i].label,
              value = data.options[i].value;
          $('<option>' + label + '</option>')
            .val(value)
            .appendTo(select);
        }
        loaded = true;
        input.autocomplete('search', input.val());  // trigger search to re-render options
      }

      // Load options list with ajax and populate underlying select with loaded data
      $.get(this.options.source_url, populateSelect);

      function removeIfInvalid(element) {
        var value = $(element).val(),
            matcher = new RegExp('^' + $.ui.autocomplete.escapeRegex(value) + '$'),
            valid = false;
        select.children('option').each(function() {
          if ($(this).val().match(matcher)) {
            this.selected = valid = true;
            input.val(this.text);
            return false;
          }
        });

        if (!valid) {
          $(element).val('');
          select.val('');
          input.data('autocomplete').term = '';
        }
      }
{'fraction_non_alphanumeric': 0.1483100233100233, 'fraction_numerical': 0.0026223776223776225, 'mean_word_length': 1.8301731244847486, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '523447', 'n_tokens_mistral': 952, 'n_tokens_neox': 908, 'n_words': 222}