let app = angular.module('app-calculator', []); app.controller('mainController', function($scope, $http){ $scope.reward = 12.5; $scope.difficulty = 0; $scope.hashingPower = 1; // $scope.minpayout = 0.0; $scope.bitcoin = { time: Date.now(), exchangerates: { usd: 0, gbp: 0, eur: 0 } }; $scope.hashingUnitOptions = { availablehashingUnits: [ {value: 1, name: 'H/s'}, {value: 1000, name: 'KH/s'}, {value: 1000000, name: 'MH/s'}, {value: 1000000000, name: 'GH/s'}, {value: 1000000000000, name: 'TH/s'}, ], selectedHashingUnit: {value: 1000000000000, name: 'TH/s'} }; $scope.providerUnitOptions = { availableproviderUnits: [ {value: 0, name: 'Mining Anbieter ausw\u00e4hlen'}, {value: 0.0035, name: 'Hashflare SHA-256'}, {value: 0.005, name: 'Hashflare Scrypt'}, {value: 0.0028, name: 'Genesis SHA'}, {value: 1/150, name: 'CCG Mining'}, {value: 0.0047, name: 'fflak mining'}, ], selectedProviderUnit: {value: 0, name: 'Mining Anbieter ausw\u00e4hlen'} }; $scope.timeUnitOptions = { availabletimeUnits: [ {value: 0, name: 'Vertragslaufzeit ausw\u00e4len'}, {value: 1, name: '1 Jahr '}, {value: 2, name: '2 Jahre'}, {value: 3, name: '3 Jahre'}, {value: 4, name: '4 Jahre'}, {value: 5, name: '5 Jahre / Lifetime'}, ], selectedTimeUnit: {value: 0, name: 'Vertragslaufzeit ausw\u00e4len'} }; $http.get('http://api.coindesk.com/v1/bpi/currentprice.json').then(function (response) { let cdr = response.data; $scope.bitcoin.exchangerates.usd = parseFloat(cdr.bpi.USD.rate.replace(',','')); $scope.bitcoin.exchangerates.gbp = parseFloat(cdr.bpi.GBP.rate.replace(',','')); $scope.bitcoin.exchangerates.eur = parseFloat(cdr.bpi.EUR.rate.replace(',','')); }); $http.get('https://blockchain.info/q/getdifficulty?cors=true').then(function (response) { $scope.difficulty = parseFloat(response.data); }); $scope.getBTCPerDay_Exact = function () { return 86400 / ($scope.difficulty * (Math.pow(2,48)/65535) / ($scope.hashingPower * $scope.hashingUnitOptions.selectedHashingUnit.value)) * $scope.reward; }; $scope.getBTCPerDay = function () { let temp = $scope.getBTCPerDay_Exact(); return temp.toPrecision(2); }; $scope.getUSDPerDay = function () { let temp = $scope.getBTCPerDay_Exact(); temp *= $scope.bitcoin.exchangerates.usd; return temp.toFixed(2); }; $scope.getGBPPerDay = function () { let temp = $scope.getBTCPerDay_Exact(); temp *= $scope.bitcoin.exchangerates.gbp; return temp.toFixed(2); }; $scope.getEURPerDay = function () { let temp = $scope.getBTCPerDay_Exact(); temp *= $scope.bitcoin.exchangerates.eur; return temp.toFixed(2); }; $scope.getminingfeePerDay = function () { let temp =$scope.providerUnitOptions.selectedProviderUnit.value * ($scope.hashingPower * $scope.hashingUnitOptions.selectedHashingUnit.value) / 10000000000 ; return temp.toFixed(2); }; $scope.getProfitPerDay = function () { let temp = $scope.getUSDPerDay() - $scope.getminingfeePerDay(); return temp.toFixed(2); }; $scope.getROI = function () { let temp = $scope.contractPrice / $scope.getProfitPerDay(); return temp.toFixed(0); }; $scope.getminPayout = function () { let temp = $scope.minpayout; return temp.toFixed(4); }; $scope.getPayoutdays = function () { let temp = $scope.minPayout / $scope.getBTCPerDay() ; return temp.toFixed(0); }; $scope.getRuntime = function () { let temp = $scope.timeUnitOptions.selectedTimeUnit.value ; return temp.toFixed(0); }; $scope.getKurs = function () { let temp = $scope.bitcoin.exchangerates.usd; return temp.toFixed(2); }; $scope.getDi = function () { let temp = $scope.difficulty; return temp.toFixed(2); }; });