aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/network.js
blob: 9f728737117982ad7ec8fc0100bb2457146fb558 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits

module.exports = Network

inherits(Network, Component)

function Network () {
  Component.call(this)
}

Network.prototype.render = function () {
  const state = this.props
  const networkNumber = state.network
  let iconName, hoverText

  if (networkNumber === 'loading') {
    return h('img', {
      title: 'Attempting to connect to blockchain.',
      onClick: (event) => this.props.onClick(event),
      style: {
        width: '27px',
        marginRight: '-27px',
      },
      src: 'images/loading.svg',
    })
  } else if (parseInt(networkNumber) === 1) {
    hoverText = 'Main Ethereum Network'
    iconName = 'ethereum-network'
  } else if (parseInt(networkNumber) === 2) {
    hoverText = 'Morden Test Network'
    iconName = 'morden-test-network'
  } else {
    hoverText = 'Unknown Private Network'
    iconName = 'unknown-private-network'
  }
  return (
    h('#network_component.flex-center.pointer', {
      style: {
        marginRight: '-27px',
        marginLeft: '-3px',
      },
      title: hoverText,
      onClick: (event) => this.props.onClick(event),
    }, [
      (function () {
        switch (iconName) {
          case 'ethereum-network':
            return h('.menu-icon.diamond')
          case 'morden-test-network':
            return h('.menu-icon.red-dot')
          default:
            return h('i.fa.fa-question-circle.fa-lg', {
              ariaHidden: true,
              style: {
                margin: '10px',
                color: 'rgb(125, 128, 130)',
              },
            })
        }
      })(),
    ])
  )
}