<commit_before>Backbone = require "backbone"
Backbone.$ = $
sd = require("sharify").data
mediator = require '../../../lib/mediator.coffee'
UserBlocks = require '../../../collections/user_blocks.coffee'

ConnectResultsView = require './connect_results_view.coffee'

connectTemplate = -> require('../templates/connect.jade') arguments...

module.exports = class ConnectView extends Backbone.View

  events:
    'keyup .new-connection__search' : 'onKeyUp'
    'blur .new-connection__search' : 'clear'
    'click .new-connection__done-button' : 'clear'

  initialize: (options)->
    @block = options.block
    @$input = @$('.new-connection__search')
    @render()
    super

  clear: (e)->
    e.stopPropagation()
    e.preventDefault()
    @$el.html ""
    @$el.removeClass 'is-active'
    @undelegateEvents()
    mediator.trigger "connection:#{@block.id}:complete"

  onKeyUp: (e)->
    e.preventDefault()
    e.stopPropagation()

    $('body').stop()

    switch e.keyCode
      when 13
        console.log 'enter'
      when 40
        console.log 'down'
      when 38
        console.log 'up'
      else
        @search(e)

  search: (e) ->
    e.preventDefault()

    return @reset() unless query = @getQuery()
    return if (query.length < 2) or (query is @lastQuery)<commit_msg>blur connect log<commit_after>Backbone = require "backbone"
Backbone.$ = $
sd = require("sharify").data
mediator = require '../../../lib/mediator.coffee'
UserBlocks = require '../../../collections/user_blocks.coffee'

ConnectResultsView = require './connect_results_view.coffee'

connectTemplate = -> require('../templates/connect.jade') arguments...

module.exports = class ConnectView extends Backbone.View

  events:
    'keyup .new-connection__search' : 'onKeyUp'
    'blur .new-connection__search' : 'clear'
    'click .new-connection__done-button' : 'clear'

  initialize: (options)->
    @block = options.block
    @$input = @$('.new-connection__search')
    @render()
    super

  clear: (e)->
    console.log 'should clear'
    e.stopPropagation()
    e.preventDefault()
    @$el.html ""
    @$el.removeClass 'is-active'
    @undelegateEvents()
    mediator.trigger "connection:#{@block.id}:complete"

  onKeyUp: (e)->
    e.preventDefault()
    e.stopPropagation()

    $('body').stop()

    switch e.keyCode
      when 13
        console.log 'enter'
      when 40
        console.log 'down'
      when 38
        console.log 'up'
      else
        @search(e)

  search: (e) ->
    e.preventDefault()

    return @reset() unless query = @getQuery()
    return if (query.length < 2) or (query is @lastQuery)
{'fraction_non_alphanumeric': 0.15653846153846154, 'fraction_numerical': 0.005384615384615384, 'mean_word_length': 2.864784546805349, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4323423', 'n_tokens_mistral': 853, 'n_tokens_neox': 826, 'n_words': 180}