<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

# TODO: This should run again if TableSaw changes the
# layout.
findStartingPosition = (scroller_frame) ->
  scroller_panel = scroller_frame.find('.scroller-panel')

  frame_width = scroller_frame.width()
  panel_width = scroller_panel.width()

  if frame_width + 1 < panel_width
    scroller_frame.addClass("panel-scrollable")
    scroller_frame.addClass("panel-scrolled-left")
  else
    scroller_frame.removeClass("panel-scrolled-right")
    scroller_frame.removeClass("panel-scrolled-left")
    scroller_frame.removeClass("panel-scrolled-middle")

setScrollWatcher = (scroller_frame) ->
  scroller_panel = scroller_frame.find('.scroller-panel')
  frame_width = scroller_frame.width()
  panel_width = scroller_panel.width()

  scroller_frame.scroll ->
    scroller_frame = $(this)
    scroller_panel = scroller_frame.find('.scroller-panel')

    frame_width = scroller_frame.width()
    panel_width = scroller_panel.width()

    if scroller_frame.scrollLeft() == 0
      scroller_frame.addClass("panel-scrolled-left")
      scroller_frame.removeClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-middle")
    else if scroller_frame.scrollLeft() + frame_width + 2 > panel_width
      scroller_frame.addClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-left")
      scroller_frame.removeClass("panel-scrolled-middle")
    else
      scroller_frame.addClass("panel-scrolled-middle")
      scroller_frame.removeClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-left")

setScrollerFadeEffect = ->
  console.log("In setScrollerFadeEffect")
  if $('.scroller-frame') && $('.scroller-panel')
    scroller_frame = $('#data-table .scroller-frame')

    findStartingPosition(scroller_frame)
    setScrollWatcher(scroller_frame)

    tab_links = []
    tab_links = $('#data-table .nav-tabs a')

    tab_links.each ->
      $(this).on 'shown.bs.tab', (e) ->
        active_tab = $($(this).attr('href'))
        scroller_frame = active_tab.find('.scroller-frame')

        setScrollWatcher(scroller_frame)
        findStartingPosition(scroller_frame)

$ -> setScrollerFadeEffect()

# 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()
    $('time[data-time-ago]').timeago()<commit_msg>Remove debug logging to js console<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

# TODO: This should run again if TableSaw changes the
# layout.
findStartingPosition = (scroller_frame) ->
  scroller_panel = scroller_frame.find('.scroller-panel')

  frame_width = scroller_frame.width()
  panel_width = scroller_panel.width()

  if frame_width + 1 < panel_width
    scroller_frame.addClass("panel-scrollable")
    scroller_frame.addClass("panel-scrolled-left")
  else
    scroller_frame.removeClass("panel-scrolled-right")
    scroller_frame.removeClass("panel-scrolled-left")
    scroller_frame.removeClass("panel-scrolled-middle")

setScrollWatcher = (scroller_frame) ->
  scroller_panel = scroller_frame.find('.scroller-panel')
  frame_width = scroller_frame.width()
  panel_width = scroller_panel.width()

  scroller_frame.scroll ->
    scroller_frame = $(this)
    scroller_panel = scroller_frame.find('.scroller-panel')

    frame_width = scroller_frame.width()
    panel_width = scroller_panel.width()

    if scroller_frame.scrollLeft() == 0
      scroller_frame.addClass("panel-scrolled-left")
      scroller_frame.removeClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-middle")
    else if scroller_frame.scrollLeft() + frame_width + 2 > panel_width
      scroller_frame.addClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-left")
      scroller_frame.removeClass("panel-scrolled-middle")
    else
      scroller_frame.addClass("panel-scrolled-middle")
      scroller_frame.removeClass("panel-scrolled-right")
      scroller_frame.removeClass("panel-scrolled-left")

setScrollerFadeEffect = ->
  if $('.scroller-frame') && $('.scroller-panel')
    scroller_frame = $('#data-table .scroller-frame')

    findStartingPosition(scroller_frame)
    setScrollWatcher(scroller_frame)

    tab_links = []
    tab_links = $('#data-table .nav-tabs a')

    tab_links.each ->
      $(this).on 'shown.bs.tab', (e) ->
        active_tab = $($(this).attr('href'))
        scroller_frame = active_tab.find('.scroller-frame')

        setScrollWatcher(scroller_frame)
        findStartingPosition(scroller_frame)

$ -> setScrollerFadeEffect()

# 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()
    $('time[data-time-ago]').timeago()
{'fraction_non_alphanumeric': 0.1175330396475771, 'fraction_numerical': 0.0010572687224669603, 'mean_word_length': 4.359773371104816, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '5757218', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1747, 'n_words': 306}