<commit_before>class StatusBar extends View
  type: 'status'
  constructor: (@cfg) ->
    super @cfg # with auto init
  ### static ###
  @create: (cfg) -> super @, cfg
  ### public ###
  init: ->
    super()
    @nick = @query '#user-nick'
    @list = @query '#users-list'
    @conn = @query '#conn-status'
    @
  _text: (el, txt) ->
    el[if el.innerText? then 'innerText' else 'textContent'] = txt
  update: ->
    return @ unless @init
    # user nick
    @_text @nick, @channel.user.nick
    # users list
    online_u = 0 #@channel.users.filter (u) -> u.status isnt 'offline'
    @list.title = @channel.users.map((u) ->
      online_u++ if u.status isnt 'offline'
      "* #{u.nick} #{u.status}").join '\n'
    @_text @list, @list.counter = "#{online_u} / #{channel.users.length}"
    @list.onclick ?= =>
      @channel.system "*Users in this channel #{@list.counter}*\n\n#{@list.title}"
      false
    @
  online: (online = on) ->
    @_text @conn, if online then 'online' else 'offline'
    @
# end of class

class EntryArea extends View
  type: 'entry'
  mode: type: 'gfm' # default type for now
  constructor: (@cfg) ->
    super @cfg # with auto init
    @history = [] # todo: save history with cur value together
    @history.cur = -1 # for prev is 0
    ### public ###
    Object.defineProperties @,
      value:
        get: -> @el?.value # do not trim
        set: (value) -> if @el? and value isnt @el.value
          @el.value = value # wont auto fire change event
          @fire event: 'change' # return
  ### static ###
  @create: (cfg) -> super @, cfg
  ### public ###
  init: ->
    super()
    _resize = @resize.bind @ # JS 1.8.5
    # enter / up / down
    _trvl_history = (e, up = yes) =>
      return if @history.cur < 0 and @value or /\n/.test @value
      e.preventDefault()
      cur = @history.cur + if up then 1 else -1
      #console.log 'history', cur
      return false if cur < 0 or cur >= @history.length
      @history.cur = cur
      @value = @history[cur]
      false
    @on event: 'keydown', handler: (e) =>
      if e.keyCode is 13 and not (e.ctrlKey or e.metaKey or e.shiftKey or e.altKey)
        e.preventDefault()
        return false unless @value.trim()
        @send()
        return false
      else if e.keyCode is 38
        _trvl_history e, yes
      else if e.keyCode is 40
        _trvl_history e, no
      else if e.keyCode is 13 # new line
        _resize()
      else
        
      return
    # end of fire_change
    # @on event: 'keydown', handler: _resize
    @on event: 'cut', handler: _resize
    @on event: 'past', handler: _resize
    @on event: 'drop', handler: _resize
    @on event: 'change', handler: _resize
    # placeholder
    @on event: 'focus', handler: -> @placeholder = ''
    @on event: 'blur', handler: -> @placeholder = '_'
    # auto save on exit
    @on el: window, event: 'unload', handler: =><commit_msg>a temp solution for notification permission<commit_after>class StatusBar extends View
  type: 'status'
  constructor: (@cfg) ->
    super @cfg # with auto init
  ### static ###
  @create: (cfg) -> super @, cfg
  ### public ###
  init: ->
    super()
    @nick = @query '#user-nick'
    @list = @query '#users-list'
    @conn = @query '#conn-status'
    # check add permition button
    @_check()
    @
  _text: (el, txt) ->
    el[if el.innerText? then 'innerText' else 'textContent'] = txt
  _check: ->
    return unless (api = window.webkitNotifications)?.checkPermission() > 0
    li = document.createElement 'li'
    btn = document.createElement 'input'
    btn.type = 'button'
    btn.value = 'Allow Desktop Notifications'
    btn.onclick = ->
      api.requestPermission =>
        @parentNode.removeChild @
    li.appendChild btn
    @el.appendChild li
    console.log 'check', li, @el
    @
  # end of check
  update: ->
    return @ unless @init
    # user nick
    @_text @nick, @channel.user.nick
    # users list
    online_u = 0 #@channel.users.filter (u) -> u.status isnt 'offline'
    @list.title = @channel.users.map((u) ->
      online_u++ if u.status isnt 'offline'
      "* #{u.nick} #{u.status}").join '\n'
    @_text @list, @list.counter = "#{online_u} / #{channel.users.length}"
    @list.onclick ?= =>
      @channel.system "*Users in this channel #{@list.counter}*\n\n#{@list.title}"
      false
    @
  online: (online = on) ->
    @_text @conn, if online then 'online' else 'offline'
    @
# end of class

class EntryArea extends View
  type: 'entry'
  mode: type: 'gfm' # default type for now
  constructor: (@cfg) ->
    super @cfg # with auto init
    @history = [] # todo: save history with cur value together
    @history.cur = -1 # for prev is 0
    ### public ###
    Object.defineProperties @,
      value:
        get: -> @el?.value # do not trim
        set: (value) -> if @el? and value isnt @el.value
          @el.value = value # wont auto fire change event
          @fire event: 'change' # return
  ### static ###
  @create: (cfg) -> super @, cfg
  ### public ###
  init: ->
    super()
    _resize = @resize.bind @ # JS 1.8.5
    # enter / up / down
    _trvl_history = (e, up = yes) =>
      return if @history.cur < 0 and @value or /\n/.test @value
      e.preventDefault()
      cur = @history.cur + if up then 1 else -1
      #console.log 'history', cur
      return false if cur < 0 or cur >= @history.length
      @history.cur = cur
      @value = @history[cur]
      false
    @on event: 'keydown', handler: (e) =>
      if e.keyCode is 13 and not (e.ctrlKey or e.metaKey or e.shiftKey or e.altKey)
        e.preventDefault()
        return false unless @value.trim()
        @send()
        return false
      else if e.keyCode is 38
        _trvl_history e, yes
      else if e.keyCode is 40
        _trvl_history e, no
      else if e.keyCode is 13 # new line
        _resize()
      else
        # todo: delay _resize
      return
    # end of fire_change
    # @on event: 'keydown', handler: _resize
    @on event: 'cut', handler: _resize
    @on event: 'past', handler: _resize
    @on event: 'drop', handler: _resize
    @on event: 'change', handler: _resize
    # placeholder
    @on event: 'focus', handler: -> @placeholder = ''
    @on event: 'blur', handler: -> @placeholder = '_'
    # auto save on exit
    @on el: window, event: 'unload', handler: =>
{'fraction_non_alphanumeric': 0.1458035855941615, 'fraction_numerical': 0.005870220529906394, 'mean_word_length': 2.342523860021209, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '323977', 'n_tokens_mistral': 2084, 'n_tokens_neox': 2063, 'n_words': 665}