<commit_before>goog.provide 'app.react.pages.Songs'

goog.require 'goog.async.Delay'

class app.react.pages.Songs

  ###*
    @param {app.Routes} routes
    @param {app.react.Link} link
    @param {app.react.Songs} songs
    @param {app.songs.Store} songsStore
    @constructor
  ###
  constructor: (routes, link, songs, songsStore) ->
    {div,input,p} = React.DOM
    searchQuery = ''

    @component = React.createFactory React.createClass

      render: ->
        div className: 'page',
          div className: 'form-group',
            input
              autoFocus: goog.labs.userAgent.device.isDesktop()
              className: 'form-control'
              onChange: @onSearchChange
              placeholder: Songs.MSG_SEARCH_FIELD_PLACEHOLDER
              value: searchQuery
          songs.component songs: songsStore.foundSongs
          p {},
            link.to routes.recentlyUpdatedSongs, Songs.MSG_RECENTLY_UPDATED_SONGS

      componentDidMount: ->
        @delay = new goog.async.Delay @onDelayAction, 300

      onDelayAction: ->
        songsStore.search searchQuery

      componentWillUnmount: ->
        @delay.dispose()

      onSearchChange: (e) ->
        searchQuery = e.target.value.slice 0, Songs.SEARCH_QUERY_MAX_LENGTH
        @forceUpdate()
        @delay.start()

  @SEARCH_QUERY_MAX_LENGTH: 100
  @MSG_RECENTLY_UPDATED_SONGS: goog.getMsg 'Recently updated songs.'
  @MSG_SEARCH_FIELD_PLACEHOLDER: goog.getMsg 'Search song by name, artist, or lyrics.'<commit_msg>Renaming.<commit_after>goog.provide 'app.react.pages.Songs'

goog.require 'goog.async.Delay'

class app.react.pages.Songs

  ###*
    @param {app.Actions} actions
    @param {app.Routes} routes
    @param {app.react.Link} link
    @param {app.react.Songs} songs
    @param {app.songs.Store} songsStore
    @constructor
  ###
  constructor: (actions, routes, link, songs, songsStore) ->
    {div,input,p} = React.DOM
    query = ''

    @component = React.createFactory React.createClass

      render: ->
        div className: 'page',
          div className: 'form-group',
            input
              autoFocus: goog.labs.userAgent.device.isDesktop()
              className: 'form-control'
              onChange: @onSearchChange
              placeholder: Songs.MSG_SEARCH_FIELD_PLACEHOLDER
              value: query
          songs.component songs: songsStore.foundSongs
          p {},
            link.to routes.recentlyUpdatedSongs, Songs.MSG_RECENTLY_UPDATED_SONGS

      componentDidMount: ->
        @delay = new goog.async.Delay @onDelayAction, 300

      onDelayAction: ->
        actions.searchSong query

      componentWillUnmount: ->
        @delay.dispose()

      onSearchChange: (e) ->
        query = e.target.value.slice 0, Songs.SEARCH_QUERY_MAX_LENGTH
        @forceUpdate()
        @delay.start()

  @SEARCH_QUERY_MAX_LENGTH: 100
  @MSG_RECENTLY_UPDATED_SONGS: goog.getMsg 'Recently updated songs.'
  @MSG_SEARCH_FIELD_PLACEHOLDER: goog.getMsg 'Search song by name, artist, or lyrics.'
{'fraction_non_alphanumeric': 0.10613598673300166, 'fraction_numerical': 0.004643449419568822, 'mean_word_length': 2.552414605418139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4610849', 'n_tokens_mistral': 964, 'n_tokens_neox': 913, 'n_words': 183}