Skip to content

Commit

Permalink
converter calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
smervs committed Feb 16, 2018
1 parent 252882c commit 1c5c04a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
Binary file modified .vs/SteemMoney/v15/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion SteemMoney/SteemMoney.jsproj.user
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Android'">
<DebuggerFlavor>SimulateNexus6</DebuggerFlavor>
<DebuggerFlavor>AndroidEmulator</DebuggerFlavor>
<AndroidEmulatorID>AndroidDevice;Device</AndroidEmulatorID>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Android'">
Expand Down
10 changes: 0 additions & 10 deletions SteemMoney/bin/Android/Debug/VSBuildInfo.xml

This file was deleted.

Binary file modified SteemMoney/bin/Android/Debug/android-debug-unaligned.apk
Binary file not shown.
Binary file modified SteemMoney/bin/Android/Debug/android-debug.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion SteemMoney/www/views/conversion/conversion.html
Expand Up @@ -3,7 +3,7 @@
<ion-nav-back-button class="button-icon ion-arrow-left-c">
</ion-nav-back-button>
</ion-nav-bar>
<ion-content>
<ion-content ng-controller="ConversionController">
<div style="margin:10px;text-align:center;vertical-align:middle;">
<img src="./images/logo.png" alt="Wallet" width="100" /><br /> <br />
<span style="font-size:30px;">CONVERTER</span>
Expand Down
38 changes: 30 additions & 8 deletions SteemMoney/www/views/conversion/conversion.js
Expand Up @@ -46,14 +46,14 @@

vm.SBD = {};
vm.STEEM = {};
vm.rates = {};

getRates();

function getRates() {
$http.get('https://api.fixer.io/latest?base=USD')
.then(function (response) {
var rates = response.data.rates;
console.log(rates);
vm.rates = response.data.rates;
});

$http.get('https://api.coinmarketcap.com/v1/ticker/steem-dollars/')
Expand All @@ -69,21 +69,43 @@

vm.calculate = function () {
if (vm.currency_from == 'STEEM') {
console.log(vm.currency_to);
console.log(vm.currency_value);
console.log(vm.STEEM);
if (vm.currency_to.id == 'BTC') {
vm.result = parseFloat(vm.currency_value) * parseFloat(vm.STEEM.price_btc);
vm.result = getBTCValue(vm.STEEM.price_btc);
}
else if (vm.currency_to.id == 'USD') {
vm.result = parseFloat(vm.currency_value) * parseFloat(vm.STEEM.price_usd);
vm.result = getUSDValue(vm.STEEM.price_usd);
}
else {

vm.result = getUSDValue(vm.STEEM.price_usd) * parseFloat(vm.rates[vm.currency_to.id]);
}
}
else {
if (vm.currency_to.id == 'BTC') {
vm.result = getBTCValue(vm.SBD.price_btc);
}
else if (vm.currency_to.id == 'USD') {
vm.result = getUSDValue(vm.SBD.price_usd);
}
else {
vm.result = getUSDValue(vm.SBD.price_usd) * parseFloat(vm.rates[vm.currency_to.id]);
}
}

if (isNaN(vm.result)) {
vm.result = '0.000';
}
else {
vm.result = vm.result.toFixed(3);
}

vm.result = vm.result + ' ' + vm.currency_to.id;
}

function getUSDValue(usd) {
return vm.result = parseFloat(vm.currency_value) * parseFloat(usd);
}

function getBTCValue(btc) {
return vm.result = parseFloat(vm.currency_value) * parseFloat(btc);
}
});

0 comments on commit 1c5c04a

Please sign in to comment.