<commit_before>var Search = {
  source : '/people.json',

  selector : '#global_search input#q',
  formatItem: function(row){
    if(row['search']) {
      return $.mustache(Diaspora.widgets.i18n.t('search_for'), { name: row['name'] });
    } else {
      return "<img src='"+ row['avatar'] +"' class='avatar'/>" + row['name'];
    }
  },
  formatResult: function(row){
     return row['name'];
   },
  parse : function(data) {
    results =  data.map(function(person){
      return {data : person, value : person['name']}
    });
    results.push(Search.searchLinkli());
    return results;
  },
  selectItemCallback :  function(event, data, formatted) {
    $(Search.selector).val(formatted);
    window.location = data['url'];
  },
  options : function(){return {
      minChars : 3,
      onSelect: Search.selectItemCallback,
      max : 5,
      scroll : false,
      delay : 200,
      cacheLength : 15,
      extraParams : {limit : 4},
      formatItem : Search.formatItem,
      formatResult : Search.formatResult,
      parse : Search.parse,
  };},

  searchLinkli : function() {<commit_msg>prevent timing issue when autosuggest is too slow<commit_after>var Search = {
  source : '/people.json',

  selector : '#global_search input#q',
  formatItem: function(row){
    if(row['search']) {
      return $.mustache(Diaspora.widgets.i18n.t('search_for'), { name: row['name'] });
    } else {
      return "<img src='"+ row['avatar'] +"' class='avatar'/>" + row['name'];
    }
  },
  formatResult: function(row){
     return row['name'];
   },
  parse : function(data) {
    results =  data.map(function(person){
      return {data : person, value : person['name']}
    });
    results.push(Search.searchLinkli());
    return results;
  },
  selectItemCallback :  function(event, data, formatted) {
    if (data['id'] !== undefined) { // actual result
      $(Search.selector).val(formatted);
      window.location = data['url'];
    } else { //use form val to eliminate timing issue
      window.location = '/people?q='+$(Search.selector).val();
    }
  },
  options : function(){return {
      minChars : 3,
      onSelect: Search.selectItemCallback,
      max : 5,
      scroll : false,
      delay : 200,
      cacheLength : 15,
      extraParams : {limit : 4},
      formatItem : Search.formatItem,
      formatResult : Search.formatResult,
      parse : Search.parse
  };},

  searchLinkli : function() {
{'fraction_non_alphanumeric': 0.16563146997929606, 'fraction_numerical': 0.008281573498964804, 'mean_word_length': 2.960655737704918, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7221287', 'n_tokens_mistral': 775, 'n_tokens_neox': 742, 'n_words': 160}