<commit_before>var React = require('react')
var Nav = require('./nav.jsx')
var RouteHandler = require('react-router').RouteHandler

// TODO: get this address from a config
var ipfs = require('ipfs-api')('localhost', 5001)
var ipfsHost = 'localhost:5001'

module.exports = React.createClass({
  getInitialState: function() {
    var t = this
    ipfs.version(function(err, res) {
      if(err) return console.error(err)
      t.setState({ version: res.Version })
    })

    ipfs.update.check(function(err, res) {
      console.log(err, res)
      if(!err) t.setState({ updateAvailable: true })
    })

    return {
      version: '',
      updateAvailable: false,
      updating: false
    }
  },

  update: function() {
    var t = this
    ipfs.update.apply(function(err, res) {
      console.log(err, res)
      t.setState({ updating: false })
      if(!err) window.location = window.location.toString()
    })<commit_msg>Use current hostname for IPFS API client address<commit_after>var React = require('react')
var Nav = require('./nav.jsx')
var RouteHandler = require('react-router').RouteHandler

// TODO: get this address from a config
var ipfs = require('ipfs-api')(window.location.hostname, window.location.port)
var ipfsHost = window.location.host

module.exports = React.createClass({
  getInitialState: function() {
    var t = this
    ipfs.version(function(err, res) {
      if(err) return console.error(err)
      t.setState({ version: res.Version })
    })

    ipfs.update.check(function(err, res) {
      console.log(err, res)
      if(!err) t.setState({ updateAvailable: true })
    })

    return {
      version: '',
      updateAvailable: false,
      updating: false
    }
  },

  update: function() {
    var t = this
    ipfs.update.apply(function(err, res) {
      console.log(err, res)
      t.setState({ updating: false })
      if(!err) window.location = window.location.toString()
    })
{'fraction_non_alphanumeric': 0.14337851929092804, 'fraction_numerical': 0.004171011470281543, 'mean_word_length': 3.1004273504273505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2800947', 'n_tokens_mistral': 601, 'n_tokens_neox': 598, 'n_words': 141}