<commit_before>import React from 'react'

var DownloadButton = React.createClass({
  propTypes: {
    onClick: React.PropTypes.func.isRequired,
    enable: React.PropTypes.bool.isRequired,
    text: React.PropTypes.string.isRequired,
    cookieName: React.PropTypes.string.isRequired,
    working: React.PropTypes.string.isRequired
  },

  defaults: {
    isWorking: false,
    url: 'about:blank'
  },

  getInitialState () {
    return this.defaults
  },

  _getCookie (name) {
    if (document.cookie.length > 0) {
      var c_start = document.cookie.indexOf(name + '=')
      if (c_start !== -1) {
        c_start = c_start + name.length + 1
        var c_end = document.cookie.indexOf(';', c_start)
        if (c_end === -1) {
          c_end = document.cookie.length
        }
        return document.cookie.substring(c_start, c_end)
      }
    }
    return ''
  },

  _download () {
    if (!this.props.enable || this.state.isWorking) return

    let url = this.props.onClick()
    this.setState({
      url: url,
      isWorking: true
    })

    var self = this
    var refreshIntervalId = window.setInterval(() => {
      var cookieValue = self._getCookie(self.props.cookieName)
      if (cookieValue === 'true') {
        this._isCompleteDownload(refreshIntervalId)
      }
    }, 1000)
  },

  _isCompleteDownload (refreshIntervalId) {
    this.setState({
      isWorking: false,
      url: 'about:blank'
    })
    document.cookie = this.props.cookieName + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
    window.clearInterval(refreshIntervalId)
  },

  render () {
    let text = !this.state.isWorking ? this.props.text : this.props.working
    let download = (
      <div className='medium-12 columns text-right'>
        <br />
        <a role='button'
          className={this.props.enable && !this.state.isWorking ? 'button success' : 'button success disabled'}
          onClick={this._download}>
          <i className='fa fa-fw fa-download' />&emsp; {text}
        </a>
      </div>
    )
    return (
      <div>
        {download}
        <iframe width='0' height='0' className='hidden' src={this.state.url}></iframe>
      </div>
    )
  }
})

export default DownloadButton<commit_msg>update the download button.<commit_after>import React from 'react'

var DownloadButton = React.createClass({
  propTypes: {
    onClick: React.PropTypes.func.isRequired,
    enable: React.PropTypes.bool.isRequired,
    text: React.PropTypes.string.isRequired,
    cookieName: React.PropTypes.string.isRequired,
    working: React.PropTypes.string.isRequired
  },

  defaults: {
    isWorking: false,
    url: 'about:blank'
  },

  getInitialState () {
    return this.defaults
  },

  _getCookie (name) {
    if (document.cookie.length > 0) {
      var c_start = document.cookie.indexOf(name + '=')
      if (c_start !== -1) {
        c_start = c_start + name.length + 1
        var c_end = document.cookie.indexOf(';', c_start)
        if (c_end === -1) {
          c_end = document.cookie.length
        }
        return document.cookie.substring(c_start, c_end)
      }
    }
    return ''
  },

  _download () {
    if (!this.props.enable || this.state.isWorking) return

    let url = this.props.onClick()
    this.setState({
      url: url,
      isWorking: true
    })

    var self = this
    var refreshIntervalId = window.setInterval(() => {
      var cookieValue = self._getCookie(self.props.cookieName)
      if (cookieValue === 'true') {
        this._completeDownload(refreshIntervalId)
      }
    }, 1000)
  },

  _completeDownload (refreshIntervalId) {
    this.setState({
      isWorking: false,
      url: 'about:blank'
    })
    document.cookie = this.props.cookieName + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
    window.clearInterval(refreshIntervalId)
  },

  render () {
    let text = this.state.isWorking ? this.props.working : this.props.text
    let download = (
      <div className='medium-12 columns text-right'>
        <br />
        <a role='button'
          className={this.props.enable && !this.state.isWorking ? 'button success' : 'button success disabled'}
          onClick={this._download}>
          <i className='fa fa-fw fa-download' />&emsp; {text}
        </a>
      </div>
    )
    return (
      <div>
        {download}
        <iframe width='0' height='0' className='hidden' src={this.state.url}></iframe>
      </div>
    )
  }
})

export default DownloadButton
{'fraction_non_alphanumeric': 0.137744767049291, 'fraction_numerical': 0.010803511141120865, 'mean_word_length': 2.490966221523959, 'pattern_counts': {'":': 0, '<': 23, '<?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': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1872486', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1396, 'n_words': 284}