First, create a js/ directory inside the src/ directory, and then create an empty file named app.js.
At the top of the file, create the variables we'll need later:
App = { web3Provider: null, contracts: {}, account: '0x0', loading: false, tokenPrice: 0, tokensSold: 0, tokensAvailable: 500000, ...
Next, define the main initialization function:
init: function() { return App.initWeb3(); },
This calls our web3 initialization function:
initWeb3: function() { if (typeof web3 !== 'undefined') { App.web3Provider = web3.currentProvider; web3 = new Web3(web3.currentProvider); } else { App.web3Provider = new Web3.providers.HttpProvider('http://localhost:8545'); web3 = new Web3(App.web3Provider); } return App.initContracts();},
This is a standard ...