<commit_before># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

console_scroll_to_bottom = ->
  objDiv = document.getElementById("log_lines")
  if objDiv != null
    objDiv.scrollTop = objDiv.scrollHeight

# Always start with the console scrolled to the end
$ -> console_scroll_to_bottom()

class Sync.LogLineLogLine extends Sync.View
  afterInsert: -> console_scroll_to_bottom()

class Sync.ScraperShowPartial extends Sync.View
  afterUpdate: -> console_scroll_to_bottom()

class Sync.ScraperShowPartial extends Sync.View
  afterUpdate: -> $('time[data-time-ago]').timeago()

bindCapitalise = (j) ->
  j.on "input", ->
    input = $(this)
    start = input[0].selectionStart
    val = input.val()
    val = val.toUpperCase()
    if val[0..5] != "MORPH_"
      val = "MORPH_"
      start = 6
    input.val(val)
    input[0].selectionStart = start
    input[0].selectionEnd = start


$ ->
  bindCapitalise($("form.scraper .nested-fields .name"))
  $('#variables').on 'cocoon:before-insert', (e, insertedItem) ->
    name = insertedItem.find(".name")
    name.val("MORPH_")
    bindCapitalise(name)<commit_msg>Add a little animation<commit_after># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

console_scroll_to_bottom = ->
  objDiv = document.getElementById("log_lines")
  if objDiv != null
    objDiv.scrollTop = objDiv.scrollHeight

# Always start with the console scrolled to the end
$ -> console_scroll_to_bottom()

class Sync.LogLineLogLine extends Sync.View
  afterInsert: -> console_scroll_to_bottom()

class Sync.ScraperShowPartial extends Sync.View
  afterUpdate: -> console_scroll_to_bottom()

class Sync.ScraperShowPartial extends Sync.View
  afterUpdate: -> $('time[data-time-ago]').timeago()

bindCapitalise = (j) ->
  j.on "input", ->
    input = $(this)
    start = input[0].selectionStart
    val = input.val()
    val = val.toUpperCase()
    if val[0..5] != "MORPH_"
      val = "MORPH_"
      start = 6
    input.val(val)
    input[0].selectionStart = start
    input[0].selectionEnd = start


$ ->
  bindCapitalise($("form.scraper .nested-fields .name"))
  $('#variables')
    .on 'cocoon:before-insert', (e, insertedItem) ->
      name = insertedItem.find(".name")
      name.val("MORPH_")
      bindCapitalise(name)
      insertedItem.fadeIn('fast')
    .on 'cocoon:before-remove', (e, removedItem) ->
      $(this).data('remove-timeout', 500)
      removedItem.fadeOut('fast')
{'fraction_non_alphanumeric': 0.12958883994126286, 'fraction_numerical': 0.005506607929515419, 'mean_word_length': 3.772329246935201, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '4999293', 'n_tokens_mistral': 889, 'n_tokens_neox': 873, 'n_words': 213}