<commit_before>#= require trix/watchdog/deserializer

class Trix.Watchdog.PlayerView
  @playingClassName: "trix-watchdog-player-playing"

  constructor: (@element) ->
    @frame = document.createElement("iframe")
    @frame.style.border = "none"
    @frame.style.width = "100%"
    @frame.onload = @frameDidLoadDefaultDocument
    @frame.onblur = @frameDidLoseFocus

    controlsContainer = document.createElement("div")

    @playButton = document.createElement("button")
    @playButton.textContent = "Play"
    @playButton.onclick = @didClickPlayButton

    @slider = document.createElement("input")
    @slider.type = "range"
    @slider.oninput = @didChangeSliderValue

    speedControls = document.createElement("div")

    @decreaseSpeedButton = document.createElement("button")
    @decreaseSpeedButton.textContent = "–"
    @decreaseSpeedButton.onclick = @didClickDecreaseSpeedButton

    @speedMultiplierLabel = document.createElement("span")

    @increaseSpeedButton = document.createElement("button")
    @increaseSpeedButton.textContent = "+"
    @increaseSpeedButton.onclick = @didClickIncreaseSpeedButton

    logContainer = document.createElement("div")

    @log = document.createElement("textarea")
    @log.setAttribute("readonly", "")
    @log.rows = 4

    render(speedControls, @decreaseSpeedButton, @speedMultiplierLabel, @increaseSpeedButton)
    render(controlsContainer, @playButton, @slider, speedControls)
    render(logContainer, @log)
    render(@element, @frame, controlsContainer, logContainer)
    @setIndex(0)

  renderSnapshot: (snapshot) ->
    if @body
      {element, range} = @deserializeSnapshot(snapshot)
      render(@body, element)
      select(@document, range)
      @updateFrame()
    else
      @snapshot = snapshot

  renderEvents: (events) ->
    renderedEvents = for event, index in events by -1
      @renderEvent(event, index)
    @log.innerText = renderedEvents.join("\n")

  setIndex: (index) ->
    @slider.value = index

  setLength: (length) ->
    @slider.max = length

  setSpeed: (speed) -><commit_msg>Fix slider length<commit_after>#= require trix/watchdog/deserializer

class Trix.Watchdog.PlayerView
  @playingClassName: "trix-watchdog-player-playing"

  constructor: (@element) ->
    @frame = document.createElement("iframe")
    @frame.style.border = "none"
    @frame.style.width = "100%"
    @frame.onload = @frameDidLoadDefaultDocument
    @frame.onblur = @frameDidLoseFocus

    controlsContainer = document.createElement("div")

    @playButton = document.createElement("button")
    @playButton.textContent = "Play"
    @playButton.onclick = @didClickPlayButton

    @slider = document.createElement("input")
    @slider.type = "range"
    @slider.oninput = @didChangeSliderValue

    speedControls = document.createElement("div")

    @decreaseSpeedButton = document.createElement("button")
    @decreaseSpeedButton.textContent = "–"
    @decreaseSpeedButton.onclick = @didClickDecreaseSpeedButton

    @speedMultiplierLabel = document.createElement("span")

    @increaseSpeedButton = document.createElement("button")
    @increaseSpeedButton.textContent = "+"
    @increaseSpeedButton.onclick = @didClickIncreaseSpeedButton

    logContainer = document.createElement("div")

    @log = document.createElement("textarea")
    @log.setAttribute("readonly", "")
    @log.rows = 4

    render(speedControls, @decreaseSpeedButton, @speedMultiplierLabel, @increaseSpeedButton)
    render(controlsContainer, @playButton, @slider, speedControls)
    render(logContainer, @log)
    render(@element, @frame, controlsContainer, logContainer)
    @setIndex(0)

  renderSnapshot: (snapshot) ->
    if @body
      {element, range} = @deserializeSnapshot(snapshot)
      render(@body, element)
      select(@document, range)
      @updateFrame()
    else
      @snapshot = snapshot

  renderEvents: (events) ->
    renderedEvents = for event, index in events by -1
      @renderEvent(event, index)
    @log.innerText = renderedEvents.join("\n")

  setIndex: (index) ->
    @slider.value = index

  setLength: (length) ->
    @slider.max = length - 1

  setSpeed: (speed) ->
{'fraction_non_alphanumeric': 0.12457668118045477, 'fraction_numerical': 0.0031446540880503146, 'mean_word_length': 4.16875, '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': '3852277', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1188, 'n_words': 221}