-
-
Save IgorMinar/1030586 to your computer and use it in GitHub Desktop.
Angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://code.angularjs.org/angular-0.9.16.min.js" ng:autobind></script> | |
<script> | |
function CalculatorController() { | |
this.integer = /^\d+$/; | |
this.fraction = /^\d+\.*\d*$/; | |
this.difficulty = 877226; | |
this.hashtime = function() { return Math.round(this.difficulty * Math.pow(2, 32) / (this.hashrate * 1000))/(3600*24) }; | |
this.opex = function() { return this.time*24 * this.electricity * this.power / 1000 }; | |
this.income = function() { return Math.round(this.rate * this.btcperblock * this.time / this.hashtime()); }; | |
this.profit = function() { return this.income() - this.opex() - this.capex }; | |
} | |
</script> | |
<body ng:controller="CalculatorController"> | |
<table> | |
<tr> | |
<td>Difficulty:</td> | |
<td><input type="text" size="8" name="difficulty" value="880000" ng:required ng:validate="regexp:integer"/></td> | |
</tr> | |
<tr> | |
<td>Hash rate:</td> | |
<td><input type="text" size="8" name="hashrate" value="225000" ng:required ng:validate="regexp:integer"/></td> | |
<td>khash/s</td> | |
</tr> | |
<tr> | |
<td>Time frame:</td> | |
<td><input type="text" size="8" name="time" value="30" ng:required ng:validate="regexp:integer"/></td> | |
<td>days</td> | |
</tr> | |
<tr> | |
<td>Cost of hardware:</td> | |
<td><input type="text" size="8" name="capex" value="0" ng:required ng:validate="regexp:fraction"/></td> | |
<td>USD</td> | |
</tr> | |
<tr> | |
<td>Cost of electricity:</td> | |
<td><input type="text" size="8" name="electricity" value="0.15" ng:required ng:validate="regexp:fraction"/></td> | |
<td>USD/kWh</td> | |
</tr> | |
<tr> | |
<td>Power consumption:</td> | |
<td><input type="text" size="8" name="power" value="500" ng:required ng:validate="regexp:integer"/></td> | |
<td>W</td> | |
</tr> | |
<tr> | |
<td>Coins generated per block:</td> | |
<td><input type="text" size="8" name="btcperblock" value="50" ng:required ng:validate="regexp:integer"/></td> | |
<td>BTC/block</td> | |
</tr> | |
<tr> | |
<td>Exchange rate:</td> | |
<td><input type="text" size="8" name="rate" value="20" ng:required ng:validate="regexp:fraction"/></td> | |
<td>USD/BTC</td> | |
</tr> | |
<tr> | |
<td>Operational cost:</td> | |
<td>{{opex()}}</td> | |
<td>USD/{{time}} days</td> | |
</tr> | |
<tr> | |
<td>Hash time:</td> | |
<td>{{hashtime()}}</td> | |
<td>days</td> | |
</tr> | |
<tr> | |
<td>Income:</td> | |
<td>{{income()}}</td> | |
<td>USD</td> | |
</tr> | |
<tr> | |
<td>Profit:</td> | |
<td>{{profit()}}</td> | |
<td>USD/{{time}} days</td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment