<commit_before>'use strict'
var style = require('./styles/sliderStyles')
var util = require('../helpers/global')
var EventManager = require('../lib/eventManager')
var yo = require('yo-yo')
var ui = require('../helpers/ui')

function Slider (_traceManager) {
  util.extend(this, new EventManager())
  this.traceManager = _traceManager
  this.max
  this.disabled = true
  this.view
}

Slider.prototype.render = function () {
  var self = this
  var view = yo`<div>
        <input
          id='slider'
          style=${ui.formatCss(style.rule)}
          type='range'
          min=0
          max=${this.max}
          value=0
          onkeyup=${function () { self.onChange() }}
          onmouseup=${function () { self.onChange() }}
          disabled=${this.disabled} />
      </div>`
  if (!this.view) {
    this.view = view
  }
  return view
}

Slider.prototype.init = function (length) {
  var slider = document.getElementById('slider')
  slider.setAttribute('max', length - 1)
  this.max = length - 1
  this.updateDisabled(length === 0)
  this.disabled = length === 0
  this.setValue(0)
}

Slider.prototype.onChange = function (event) {
  var value = document.getElementById('slider').value
  this.trigger('moved', [parseInt(value)])
}<commit_msg>Trigger slider events while moving.<commit_after>'use strict'
var style = require('./styles/sliderStyles')
var util = require('../helpers/global')
var EventManager = require('../lib/eventManager')
var yo = require('yo-yo')
var ui = require('../helpers/ui')

function Slider (_traceManager) {
  util.extend(this, new EventManager())
  this.traceManager = _traceManager
  this.max
  this.disabled = true
  this.view

  this.previousValue = null
}

Slider.prototype.render = function () {
  var self = this
  var view = yo`<div>
        <input
          id='slider'
          style=${ui.formatCss(style.rule)}
          type='range'
          min=0
          max=${this.max}
          value=0
          onchange=${function () { self.onChange() }}
          oninput=${function () { self.onChange() }}
          disabled=${this.disabled} />
      </div>`
  if (!this.view) {
    this.view = view
  }
  return view
}

Slider.prototype.init = function (length) {
  var slider = document.getElementById('slider')
  slider.setAttribute('max', length - 1)
  this.max = length - 1
  this.updateDisabled(length === 0)
  this.disabled = length === 0
  this.setValue(0)
}

Slider.prototype.onChange = function (event) {
  var value = parseInt(document.getElementById('slider').value)
  if (value === this.previousValue) return
  this.previousValue = value
  this.trigger('moved', [value])
}
{'fraction_non_alphanumeric': 0.15475285171102662, 'fraction_numerical': 0.00532319391634981, 'mean_word_length': 2.9924127465857357, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6565132', 'n_tokens_mistral': 807, 'n_tokens_neox': 807, 'n_words': 176}