<commit_before>var utils = require('../core/utils/index')

var CONFIG = {
  D: buildItem('hours', null, function (rows) {
    return rows.length / 2
  }),
  H: buildItem('minutes', function (v, i, setRotate) {
    return i % 5 === 0 ? ('<i style="' + setRotate(i, true) + '">' + utils.pad(v, 2) + '</i>') : '<b></b>'
  })
}
function TimePanel (picker) {
  this.picker = picker
  this.main = null
  this.mainStyle = null
  this.headActiveEle = null
  this.activeEle = null
  this.pickerLineEle = null
  this.type = picker.options.type
}

utils.extend(TimePanel.prototype, {
  render: function () {
    if (!this.main) {
      this._init()
    }
    var isHours = this.type === 'D'
    this.picker.head.innerHTML = (
      '<div class="picker-hour' + (isHours ? ' picker-head-active' : '') + '"' + (isHours ? '' : ' data-click="toHours"') + '>' +
        utils.formatDate(this.picker.dateTime.now, 'HH') +
      '</div>:' +
      '<div class="picker-minute' + (!isHours ? ' picker-head-active' : '') + '"' + (!isHours ? '' : ' data-click="toMinutes"') + '>' +
        utils.formatDate(this.picker.dateTime.now, 'mm') +
      '</div>'
    )
    this.main.innerHTML = CONFIG[this.type](this.picker.dateTime, this.rows)
    this.afterRender()
  },
  afterRender: function () {
    this.headActiveEle = this.picker.head.querySelector('.picker-head-active')
    this.activeEle = this.main.querySelector('.picker-active')
    this.pickerLineEle = this.main.querySelector('.time-picker-line')
  },
  _init: function () {
    this.rows = this.picker.dateTime.getRows()
    this._initMain()
  },
  _initMain: function () {
    this.main = utils.createElement('div', {
      className: 'time-picker-main ' + (this.type === 'D' ? 'time-picker-main-hours' : 'time-picker-main-minutes')
    })
    this.mainStyle = this.main.style
    this.picker.content.appendChild(this.main)
  },
  show: function () {
    this.mainStyle.display = 'block'
  },
  hide: function () {
    this.mainStyle.display = 'none'
  },
  selfChange: function () {
    var v = this.picker.dateTime.getLevelValue()
    this.headActiveEle.innerHTML = utils.pad(v, 2)
    var newActiveEle = this.main.querySelector('.picker-cell[data-val="' + v + '"]')
    this.activeEle && this.activeEle.classList.remove('picker-active')
    newActiveEle.classList.add('picker-active')
    this.activeEle = newActiveEle
    var r = +newActiveEle.style[utils.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1]
    r = r - 90
    this.pickerLineEle.style[utils.prefixNames.transform] = 'rotate(' + r + 'deg)'
    this.pickerLineEle.classList[newActiveEle.classList.contains('picker-cell-inner') ? 'add' : 'remove']('time-picker-line-inner')
  },
  _start: function (e) {
    var that = this
    var finalTarget = null
    var setToTarget = function (point) {
      var targetEle = document.elementFromPoint(point.pageX, point.pageY)
      if (targetEle && targetEle.classList.contains('picker-cell') || (targetEle = targetEle.parentElement) && targetEle.classList.contains('picker-cell')) {
        finalTarget = targetEle
        that.picker.changeTo(targetEle.getAttribute('data-val'), true)
      }
    }
    setToTarget(e.touches[0])
    this.__move = function (e) {
      setToTarget(e.touches[0])
    }
    this.__end = function (e) {
      this.__move = null
      this.__end = null
      finalTarget && that.picker.selV({
        realTarget: finalTarget
      })
    }
  },
  destroy: function () {
    this.picker.content.removeChild(this.main)
    utils.set2Null(['picker', 'main', 'mainStyle', 'headActiveEle', 'activeEle', 'pickerLineEle', '__move', '__end'], this)
  }
})

module.exports = TimePanel

function buildItem (type, parser, getLen) {
  if (!parser) {
    parser = function (v, i, setRotate) {<commit_msg>fix targetEle is null error<commit_after>var utils = require('../core/utils/index')

var CONFIG = {
  D: buildItem('hours', null, function (rows) {
    return rows.length / 2
  }),
  H: buildItem('minutes', function (v, i, setRotate) {
    return i % 5 === 0 ? ('<i style="' + setRotate(i, true) + '">' + utils.pad(v, 2) + '</i>') : '<b></b>'
  })
}
function TimePanel (picker) {
  this.picker = picker
  this.main = null
  this.mainStyle = null
  this.headActiveEle = null
  this.activeEle = null
  this.pickerLineEle = null
  this.type = picker.options.type
}

utils.extend(TimePanel.prototype, {
  render: function () {
    if (!this.main) {
      this._init()
    }
    var isHours = this.type === 'D'
    this.picker.head.innerHTML = (
      '<div class="picker-hour' + (isHours ? ' picker-head-active' : '') + '"' + (isHours ? '' : ' data-click="toHours" data-active="active"') + '>' +
        utils.formatDate(this.picker.dateTime.now, 'HH') +
      '</div>:' +
      '<div class="picker-minute' + (!isHours ? ' picker-head-active' : '') + '"' + (!isHours ? '' : ' data-click="toMinutes" data-active="active"') + '>' +
        utils.formatDate(this.picker.dateTime.now, 'mm') +
      '</div>'
    )
    this.main.innerHTML = CONFIG[this.type](this.picker.dateTime, this.rows)
    this.afterRender()
  },
  afterRender: function () {
    this.headActiveEle = this.picker.head.querySelector('.picker-head-active')
    this.activeEle = this.main.querySelector('.picker-active')
    this.pickerLineEle = this.main.querySelector('.time-picker-line')
  },
  _init: function () {
    this.rows = this.picker.dateTime.getRows()
    this._initMain()
  },
  _initMain: function () {
    this.main = utils.createElement('div', {
      className: 'time-picker-main ' + (this.type === 'D' ? 'time-picker-main-hours' : 'time-picker-main-minutes')
    })
    this.mainStyle = this.main.style
    this.picker.content.appendChild(this.main)
  },
  show: function () {
    this.mainStyle.display = 'block'
  },
  hide: function () {
    this.mainStyle.display = 'none'
  },
  selfChange: function () {
    var v = this.picker.dateTime.getLevelValue()
    this.headActiveEle.innerHTML = utils.pad(v, 2)
    var newActiveEle = this.main.querySelector('.picker-cell[data-val="' + v + '"]')
    this.activeEle && this.activeEle.classList.remove('picker-active')
    newActiveEle.classList.add('picker-active')
    this.activeEle = newActiveEle
    var r = +newActiveEle.style[utils.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1]
    r = r - 90
    this.pickerLineEle.style[utils.prefixNames.transform] = 'rotate(' + r + 'deg)'
    this.pickerLineEle.classList[newActiveEle.classList.contains('picker-cell-inner') ? 'add' : 'remove']('time-picker-line-inner')
  },
  _start: function (e) {
    var that = this
    var finalTarget = null
    var setToTarget = function (point) {
      var targetEle = document.elementFromPoint(point.pageX, point.pageY)
      if (targetEle && (targetEle.classList.contains('picker-cell') || (targetEle = targetEle.parentElement) && targetEle.classList.contains('picker-cell'))) {
        finalTarget = targetEle
        that.picker.changeTo(targetEle.getAttribute('data-val'), true)
      }
    }
    setToTarget(e.touches[0])
    this.__move = function (e) {
      setToTarget(e.touches[0])
    }
    this.__end = function (e) {
      this.__move = null
      this.__end = null
      finalTarget && that.picker.selV({
        realTarget: finalTarget
      })
    }
  },
  destroy: function () {
    this.picker.content.removeChild(this.main)
    utils.set2Null(['picker', 'main', 'mainStyle', 'headActiveEle', 'activeEle', 'pickerLineEle', '__move', '__end'], this)
  }
})

module.exports = TimePanel

function buildItem (type, parser, getLen) {
  if (!parser) {
    parser = function (v, i, setRotate) {
{'fraction_non_alphanumeric': 0.17732175743225467, 'fraction_numerical': 0.0028939752696658773, 'mean_word_length': 3.2356545961002787, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5728543', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2571, 'n_words': 434}