remove temporary vars

This commit is contained in:
Esteban Ordano 2014-08-27 17:19:28 -03:00
parent 3225553d78
commit 0f0e7b78d5
2 changed files with 7 additions and 17 deletions

View File

@ -6,12 +6,9 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.title = 'Send'; $scope.title = 'Send';
$scope.loading = false; $scope.loading = false;
var satToUnit = 1 / config.unitToSatoshi; var satToUnit = 1 / config.unitToSatoshi;
var configAlternativeToSatoshi = (1 / 512 / 1e-8);
var satToAlternative = 1 / configAlternativeToSatoshi; // TODO: Change
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit; $scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN; $scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
$scope.minAmount = config.limits.minAmountSatoshi * satToUnit; $scope.minAmount = config.limits.minAmountSatoshi * satToUnit;
$scope.minAlternativeAmount = config.limits.minAmountSatoshi * satToAlternative;
this.alternativeName = config.alternativeName; this.alternativeName = config.alternativeName;
this.alternativeIsoCode = config.alternativeIsoCode; this.alternativeIsoCode = config.alternativeIsoCode;
@ -19,16 +16,9 @@ angular.module('copayApp.controllers').controller('SendController',
$scope._amount = 0; $scope._amount = 0;
$scope._alternative = 0; $scope._alternative = 0;
this.amountFilter = function(val) { var makeNumber = function(val) {
if (val) { return -(-val);
return val.toFixed(config.unitDecimals);
}
}; };
this.fiatFilter = function(val) {
if (val) {
return val.toFixed(2);
}
}
Object.defineProperty($scope, Object.defineProperty($scope,
"alternative", { "alternative", {
@ -38,8 +28,8 @@ angular.module('copayApp.controllers').controller('SendController',
set: function (newValue) { set: function (newValue) {
this._alternative = newValue; this._alternative = newValue;
if (typeof(newValue) === 'number') { if (typeof(newValue) === 'number') {
this._amount = -(-( this._amount = makeNumber(
rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit (rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit
).toFixed(config.unitDecimals)); ).toFixed(config.unitDecimals));
} }
}, },
@ -54,8 +44,8 @@ angular.module('copayApp.controllers').controller('SendController',
set: function (newValue) { set: function (newValue) {
this._amount = newValue; this._amount = newValue;
if (newValue) { if (newValue) {
this._alternative = -(-( this._alternative = makeNumber(
rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode) (rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)
).toFixed(2)); ).toFixed(2));
} }
}, },

View File

@ -90,7 +90,7 @@
<input type="number" id="alternative_amount" <input type="number" id="alternative_amount"
ng-disabled="loading || !ctrl.rateService.isAvailable " ng-disabled="loading || !ctrl.rateService.isAvailable "
name="alternative" placeholder="Amount" ng-model="alternative" name="alternative" placeholder="Amount" ng-model="alternative"
min="{{minAlternativeAmount}}" max="10000000000" enough-amount required enough-amount required
autocomplete="off" autocomplete="off"
> >
</div> </div>