<commit_before>
define([
  'jquery',
  'underscore',
  'backbone',
  'collections/topic',
  'collections/search',
  'select2'
], function ($, _, Backbone, TopicCollection, SearchCollection) {

  var SearchView = Backbone.View.extend ({

    el: '#search',
    timeout: false,

    initialize: function () {
      this.topicCollection = new TopicCollection ();
      this.searchCollection = new SearchCollection ();

      var that = this;

      $(this.el).select2 ({
        minimumInputLength: 1,
        query: function (query) {
          if (that.timeout)
            clearTimeout (that.timeout);
          that.timeout = setTimeout (function () {
            that.query (query);
          }, 400);
        }
      });

      // events property doesn't work on select2
      $(this.el).on ('change', function (ev) { that.change (ev); });

    },


    query: function (query) {

      var data = { results: [] };

      this.searchCollection.query = query.term;
      this.searchCollection.fetch ({
        success: function (topics) {

          for (var i = 0; i < topics.length; ++i) {

            data.results.push ({
              id: topics.at (i).get ('title'),
              text: topics.at (i).get ('title'),
            });

          }
          query.callback (data);

        }
      });
    },


    openEntry: function (val) {
      var that = this;
      this.topicCollection.reset ();
      // FIXME: topicCollection needs to deal with this, not this view
      this.topicCollection.external_url = '?q=' + escape (val);
      this.topicCollection.fetch ({
        success: function () {
          location.href = '#t/0/' + that.topicCollection.external_url;
        }
      });
    },


    openUser: function (val) {
      location.href = '#tl/biri/' + escape (val.substr (1)) + '/son-entryleri';
    },

    change: function (ev) {
      if (ev.val.charAt (0) == '@')
        this.openUser (ev.val)
      else
        this.openEntry (ev.val);
    }


  });

  return SearchView;

});<commit_msg>fix user url on search<commit_after>
define([
  'jquery',
  'underscore',
  'backbone',
  'collections/topic',
  'collections/search',
  'select2'
], function ($, _, Backbone, TopicCollection, SearchCollection) {

  var SearchView = Backbone.View.extend ({

    el: '#search',
    timeout: false,

    initialize: function () {
      this.topicCollection = new TopicCollection ();
      this.searchCollection = new SearchCollection ();

      var that = this;

      $(this.el).select2 ({
        minimumInputLength: 1,
        query: function (query) {
          if (that.timeout)
            clearTimeout (that.timeout);
          that.timeout = setTimeout (function () {
            that.query (query);
          }, 400);
        }
      });

      // events property doesn't work on select2
      $(this.el).on ('change', function (ev) { that.change (ev); });

    },


    query: function (query) {

      var data = { results: [] };

      this.searchCollection.query = query.term;
      this.searchCollection.fetch ({
        success: function (topics) {

          for (var i = 0; i < topics.length; ++i) {

            data.results.push ({
              id: topics.at (i).get ('title'),
              text: topics.at (i).get ('title'),
            });

          }
          query.callback (data);

        }
      });
    },


    openEntry: function (val) {
      var that = this;
      this.topicCollection.reset ();
      // FIXME: topicCollection needs to deal with this, not this view
      this.topicCollection.external_url = '?q=' + escape (val);
      this.topicCollection.fetch ({
        success: function () {
          location.href = '#t/0/' + that.topicCollection.external_url;
        }
      });
    },


    openUser: function (val) {
      location.href = '#tl/basliklar/istatistik/' + escape (val.substr (1)) + '/son-entryleri';
    },

    change: function (ev) {
      if (ev.val.charAt (0) == '@')
        this.openUser (ev.val)
      else
        this.openEntry (ev.val);
    }


  });

  return SearchView;

});
{'fraction_non_alphanumeric': 0.14981549815498155, 'fraction_numerical': 0.005412054120541206, 'mean_word_length': 1.9506531204644413, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7353525', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1185, 'n_words': 278}